Skip to content

Commit a75ad6b

Browse files
committed
Fix naming
1 parent 4f8fec5 commit a75ad6b

File tree

5 files changed

+48
-34
lines changed

5 files changed

+48
-34
lines changed

nova_vm/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_abstract_operations/promise_all_record.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ use crate::{
2020
};
2121

2222
#[derive(Debug, Clone, Copy)]
23-
pub struct PromiseAllRecord<'a> {
24-
promise_capability: &'a PromiseCapability<'a>,
25-
remaining_unresolved_promise_count: u32,
26-
result_array: Array<'a>,
23+
pub struct PromiseAllRecordHeapData<'a> {
24+
pub promise_capability: &'a PromiseCapability<'a>,
25+
pub remaining_unresolved_promise_count: u32,
26+
pub result_array: Array<'a>,
2727
}
2828

2929
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
3030
#[repr(transparent)]
31-
pub struct PromiseAllRecordHeapData<'a>(BaseIndex<'a, PromiseAllRecord<'a>>);
31+
pub struct PromiseAllRecord<'a>(pub(crate) BaseIndex<'a, PromiseAllRecordHeapData<'a>>);
3232

33-
impl<'a> PromiseAllRecord<'a> {
33+
impl<'a> PromiseAllRecordHeapData<'a> {
3434
pub(crate) fn new(
3535
agent: &mut Agent,
3636
promise_capability: &'a PromiseCapability<'a>,
@@ -81,47 +81,47 @@ impl<'a> PromiseAllRecord<'a> {
8181
}
8282
}
8383

84-
impl PromiseAllRecordHeapData<'_> {
84+
impl PromiseAllRecord<'_> {
8585
pub(crate) const fn get_index(self) -> usize {
8686
self.0.into_index()
8787
}
8888
}
8989

90-
impl Index<PromiseAllRecordHeapData<'_>> for Agent {
91-
type Output = PromiseAllRecord<'static>;
90+
impl Index<PromiseAllRecord<'_>> for Agent {
91+
type Output = PromiseAllRecordHeapData<'static>;
9292

93-
fn index(&self, index: PromiseAllRecordHeapData) -> &Self::Output {
93+
fn index(&self, index: PromiseAllRecord) -> &Self::Output {
9494
&self.heap.promise_all_records[index]
9595
}
9696
}
9797

98-
impl IndexMut<PromiseAllRecordHeapData<'_>> for Agent {
99-
fn index_mut(&mut self, index: PromiseAllRecordHeapData) -> &mut Self::Output {
98+
impl IndexMut<PromiseAllRecord<'_>> for Agent {
99+
fn index_mut(&mut self, index: PromiseAllRecord) -> &mut Self::Output {
100100
&mut self.heap.promise_all_records[index]
101101
}
102102
}
103103

104-
impl Index<PromiseAllRecordHeapData<'_>> for Vec<Option<PromiseAllRecord<'static>>> {
105-
type Output = PromiseAllRecord<'static>;
104+
impl Index<PromiseAllRecord<'_>> for Vec<Option<PromiseAllRecordHeapData<'static>>> {
105+
type Output = PromiseAllRecordHeapData<'static>;
106106

107-
fn index(&self, index: PromiseAllRecordHeapData) -> &Self::Output {
107+
fn index(&self, index: PromiseAllRecord) -> &Self::Output {
108108
self.get(index.get_index())
109109
.expect("PromiseAllRecord out of bounds")
110110
.as_ref()
111111
.expect("PromiseAllRecord slot empty")
112112
}
113113
}
114114

115-
impl IndexMut<PromiseAllRecordHeapData<'_>> for Vec<Option<PromiseAllRecord<'static>>> {
116-
fn index_mut(&mut self, index: PromiseAllRecordHeapData) -> &mut Self::Output {
115+
impl IndexMut<PromiseAllRecord<'_>> for Vec<Option<PromiseAllRecordHeapData<'static>>> {
116+
fn index_mut(&mut self, index: PromiseAllRecord) -> &mut Self::Output {
117117
self.get_mut(index.get_index())
118118
.expect("PromiseAllRecord out of bounds")
119119
.as_mut()
120120
.expect("PromiseAllRecord slot empty")
121121
}
122122
}
123123

124-
impl HeapMarkAndSweep for PromiseAllRecord<'static> {
124+
impl HeapMarkAndSweep for PromiseAllRecordHeapData<'static> {
125125
fn mark_values(&self, queues: &mut WorkQueues) {
126126
self.result_array.mark_values(queues);
127127
self.promise_capability.mark_values(queues);
@@ -133,8 +133,8 @@ impl HeapMarkAndSweep for PromiseAllRecord<'static> {
133133
}
134134
}
135135

136-
unsafe impl Bindable for PromiseAllRecord<'_> {
137-
type Of<'a> = PromiseAllRecord<'a>;
136+
unsafe impl Bindable for PromiseAllRecordHeapData<'_> {
137+
type Of<'a> = PromiseAllRecordHeapData<'a>;
138138

139139
#[inline(always)]
140140
fn unbind(self) -> Self::Of<'static> {
@@ -147,7 +147,7 @@ unsafe impl Bindable for PromiseAllRecord<'_> {
147147
}
148148
}
149149

150-
impl HeapMarkAndSweep for PromiseAllRecordHeapData<'static> {
150+
impl HeapMarkAndSweep for PromiseAllRecord<'static> {
151151
fn mark_values(&self, queues: &mut WorkQueues) {
152152
queues.promise_all_records.push(*self);
153153
}
@@ -157,8 +157,8 @@ impl HeapMarkAndSweep for PromiseAllRecordHeapData<'static> {
157157
}
158158
}
159159

160-
unsafe impl Bindable for PromiseAllRecordHeapData<'_> {
161-
type Of<'a> = PromiseAllRecordHeapData<'a>;
160+
unsafe impl Bindable for PromiseAllRecord<'_> {
161+
type Of<'a> = PromiseAllRecord<'a>;
162162

163163
#[inline(always)]
164164
fn unbind(self) -> Self::Of<'static> {
@@ -171,10 +171,10 @@ unsafe impl Bindable for PromiseAllRecordHeapData<'_> {
171171
}
172172
}
173173

174-
impl<'a> CreateHeapData<PromiseAllRecord<'a>, PromiseAllRecordHeapData<'a>> for Heap {
175-
fn create(&mut self, data: PromiseAllRecord<'a>) -> PromiseAllRecordHeapData<'a> {
174+
impl<'a> CreateHeapData<PromiseAllRecordHeapData<'a>, PromiseAllRecord<'a>> for Heap {
175+
fn create(&mut self, data: PromiseAllRecordHeapData<'a>) -> PromiseAllRecord<'a> {
176176
self.promise_all_records.push(Some(data.unbind()));
177-
self.alloc_counter += core::mem::size_of::<Option<PromiseAllRecord<'static>>>();
178-
PromiseAllRecordHeapData(BaseIndex::last(&self.promise_all_records))
177+
self.alloc_counter += core::mem::size_of::<Option<PromiseAllRecordHeapData<'static>>>();
178+
PromiseAllRecord(BaseIndex::last(&self.promise_all_records))
179179
}
180180
}

nova_vm/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_abstract_operations/promise_reaction_records.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
Array, async_generator_objects::AsyncGenerator,
1111
control_abstraction_objects::async_function_objects::await_reaction::AwaitReaction,
1212
promise::Promise,
13-
promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecordHeapData,
13+
promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecord,
1414
},
1515
execution::Agent,
1616
scripts_and_modules::module::module_semantics::{
@@ -71,7 +71,7 @@ pub(crate) enum PromiseReactionHandler<'a> {
7171
},
7272
PromiseAll {
7373
index: u32,
74-
promise_all: PromiseAllRecordHeapData<'a>,
74+
promise_all: PromiseAllRecord<'a>,
7575
},
7676
Empty,
7777
}

nova_vm/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
use crate::ecmascript::abstract_operations::operations_on_objects::create_array_from_list;
6-
use crate::ecmascript::builtins::promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecord;
6+
use crate::ecmascript::builtins::promise_objects::promise_abstract_operations::promise_all_record::{PromiseAllRecordHeapData, PromiseAllRecord};
77
use crate::ecmascript::builtins::promise_objects::promise_abstract_operations::promise_reaction_records::PromiseReactionHandler;
88
use crate::ecmascript::builtins::promise_objects::promise_prototype::inner_promise_then;
99
use crate::ecmascript::builtins::{create_builtin_function, Array, BuiltinFunctionArgs};
@@ -309,8 +309,11 @@ impl PromiseConstructor {
309309

310310
let args: [Value<'gc>; 1] = [Value::Undefined; 1];
311311
let result_array = Array::from_slice(agent, &args, gc.nogc());
312-
let promise_all_record =
313-
PromiseAllRecord::new(agent, &result_capability.unbind(), 1, gc.nogc());
312+
let promise_all_record = agent.heap.create(PromiseAllRecordHeapData {
313+
promise_capability: &result_capability,
314+
remaining_unresolved_promise_count: 1,
315+
result_array,
316+
});
314317

315318
let promise_all_handler = PromiseReactionHandler::PromiseAll {
316319
index: 0,

nova_vm/src/heap/heap_bits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use crate::ecmascript::{
5050
ordinary::{caches::PropertyLookupCache, shape::ObjectShape},
5151
primitive_objects::PrimitiveObject,
5252
promise::Promise,
53-
promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecordHeapData,
53+
promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecord,
5454
proxy::Proxy,
5555
text_processing::string_objects::string_iterator_objects::StringIterator,
5656
},
@@ -210,7 +210,7 @@ pub(crate) struct WorkQueues {
210210
pub promises: Vec<Promise<'static>>,
211211
pub promise_reaction_records: Vec<PromiseReaction<'static>>,
212212
pub promise_resolving_functions: Vec<BuiltinPromiseResolvingFunction<'static>>,
213-
pub promise_all_records: Vec<PromiseAllRecordHeapData<'static>>,
213+
pub promise_all_records: Vec<PromiseAllRecord<'static>>,
214214
pub proxys: Vec<Proxy<'static>>,
215215
pub realms: Vec<Realm<'static>>,
216216
#[cfg(feature = "regexp")]

nova_vm/src/heap/heap_gc.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub fn heap_gc(agent: &mut Agent, root_realms: &mut [Option<Realm<'static>>], gc
159159
promise_reaction_records,
160160
promise_resolving_functions,
161161
promises,
162+
promise_all_records,
162163
proxys,
163164
realms,
164165
#[cfg(feature = "regexp")]
@@ -1290,6 +1291,7 @@ fn sweep(
12901291
promise_reaction_records,
12911292
promise_resolving_functions,
12921293
promises,
1294+
promise_all_records,
12931295
proxys,
12941296
realms,
12951297
#[cfg(feature = "regexp")]
@@ -1719,6 +1721,15 @@ fn sweep(
17191721
sweep_heap_vector_values(promises, &compactions, &bits.promises);
17201722
});
17211723
}
1724+
if !promise_all_records.is_empty() {
1725+
s.spawn(|| {
1726+
sweep_heap_vector_values(
1727+
promise_all_records,
1728+
&compactions,
1729+
&bits.promise_all_records,
1730+
);
1731+
});
1732+
}
17221733
if !proxys.is_empty() {
17231734
s.spawn(|| {
17241735
sweep_heap_vector_values(proxys, &compactions, &bits.proxys);

0 commit comments

Comments
 (0)