Skip to content

Commit 48f95ea

Browse files
committed
Implemented heap data
1 parent a75ad6b commit 48f95ea

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::ops::{Index, IndexMut};
77
use crate::{
88
ecmascript::{
99
builtins::{
10-
Array,
10+
Array, promise::Promise,
1111
promise_objects::promise_abstract_operations::promise_capability_records::PromiseCapability,
1212
},
1313
execution::Agent,
@@ -21,7 +21,6 @@ use crate::{
2121

2222
#[derive(Debug, Clone, Copy)]
2323
pub struct PromiseAllRecordHeapData<'a> {
24-
pub promise_capability: &'a PromiseCapability<'a>,
2524
pub remaining_unresolved_promise_count: u32,
2625
pub result_array: Array<'a>,
2726
}
@@ -31,16 +30,10 @@ pub struct PromiseAllRecordHeapData<'a> {
3130
pub struct PromiseAllRecord<'a>(pub(crate) BaseIndex<'a, PromiseAllRecordHeapData<'a>>);
3231

3332
impl<'a> PromiseAllRecordHeapData<'a> {
34-
pub(crate) fn new(
35-
agent: &mut Agent,
36-
promise_capability: &'a PromiseCapability<'a>,
37-
num_promises: u32,
38-
gc: NoGcScope<'a, '_>,
39-
) -> Self {
33+
pub(crate) fn new(agent: &mut Agent, num_promises: u32, gc: NoGcScope<'a, '_>) -> Self {
4034
let undefined_values = vec![Value::Undefined; num_promises as usize];
4135
let result_array = Array::from_slice(agent, &undefined_values, gc);
4236
Self {
43-
promise_capability,
4437
remaining_unresolved_promise_count: num_promises,
4538
result_array,
4639
}
@@ -75,8 +68,6 @@ impl<'a> PromiseAllRecordHeapData<'a> {
7568
"All promises fulfilled, should resolve main promise: {:#?}",
7669
self.result_array
7770
);
78-
// self.promise_capability
79-
// .resolve(agent, self.result_array, gc.into_nogc());
8071
}
8172
}
8273
}
@@ -124,12 +115,10 @@ impl IndexMut<PromiseAllRecord<'_>> for Vec<Option<PromiseAllRecordHeapData<'sta
124115
impl HeapMarkAndSweep for PromiseAllRecordHeapData<'static> {
125116
fn mark_values(&self, queues: &mut WorkQueues) {
126117
self.result_array.mark_values(queues);
127-
self.promise_capability.mark_values(queues);
128118
}
129119

130120
fn sweep_values(&mut self, compactions: &CompactionLists) {
131121
self.result_array.sweep_values(compactions);
132-
self.promise_capability.sweep_values(compactions);
133122
}
134123
}
135124

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ impl PromiseConstructor {
310310
let args: [Value<'gc>; 1] = [Value::Undefined; 1];
311311
let result_array = Array::from_slice(agent, &args, gc.nogc());
312312
let promise_all_record = agent.heap.create(PromiseAllRecordHeapData {
313-
promise_capability: &result_capability,
314313
remaining_unresolved_promise_count: 1,
315314
result_array,
316315
});
@@ -325,7 +324,7 @@ impl PromiseConstructor {
325324
promise_to_await,
326325
promise_all_handler,
327326
PromiseReactionHandler::Empty,
328-
None,
327+
Some(result_capability),
329328
gc.nogc(),
330329
);
331330

nova_vm/src/heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use crate::{
7979
},
8080
primitive_objects::PrimitiveObjectHeapData,
8181
promise::data::PromiseHeapData,
82-
promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecord,
82+
promise_objects::promise_abstract_operations::promise_all_record::PromiseAllRecordHeapData,
8383
proxy::data::ProxyHeapData,
8484
text_processing::string_objects::string_iterator_objects::StringIteratorHeapData,
8585
},
@@ -168,7 +168,7 @@ pub struct Heap {
168168
pub promise_reaction_records: Vec<Option<PromiseReactionRecord<'static>>>,
169169
pub promise_resolving_functions: Vec<Option<PromiseResolvingFunctionHeapData<'static>>>,
170170
pub promises: Vec<Option<PromiseHeapData<'static>>>,
171-
pub promise_all_records: Vec<Option<PromiseAllRecord<'static>>>,
171+
pub promise_all_records: Vec<Option<PromiseAllRecordHeapData<'static>>>,
172172
pub proxys: Vec<Option<ProxyHeapData<'static>>>,
173173
pub realms: Vec<Option<RealmRecord<'static>>>,
174174
#[cfg(feature = "regexp")]

0 commit comments

Comments
 (0)