Skip to content

Commit a0875b2

Browse files
committed
Updated promise jobs
1 parent 1e222c1 commit a0875b2

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,31 @@ impl PromiseReactionJob {
301301
}
302302
return Ok(());
303303
}
304+
PromiseReactionHandler::PromiseAllSettled {
305+
promise_all_settled,
306+
index,
307+
} => {
308+
let reaction_type = agent[reaction].reaction_type;
309+
match reaction_type {
310+
PromiseReactionType::Fulfill => {
311+
promise_all_settled.on_promise_fulfilled(
312+
agent,
313+
index,
314+
argument.unbind(),
315+
gc.reborrow(),
316+
);
317+
}
318+
PromiseReactionType::Reject => {
319+
promise_all_settled.on_promise_rejected(
320+
agent,
321+
index,
322+
argument.unbind(),
323+
gc.reborrow(),
324+
);
325+
}
326+
}
327+
return Ok(());
328+
}
304329
};
305330

306331
// f. If promiseCapability is undefined, then
@@ -363,6 +388,7 @@ pub(crate) fn new_promise_reaction_job(
363388
| PromiseReactionHandler::DynamicImport { .. }
364389
| PromiseReactionHandler::DynamicImportEvaluate { .. }
365390
| PromiseReactionHandler::PromiseAll { .. } => None,
391+
PromiseReactionHandler::PromiseAllSettled { .. } => None,
366392
};
367393

368394
// 4. Return the Record { [[Job]]: job, [[Realm]]: handlerRealm }.

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use crate::{
1010
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::PromiseAll,
13+
promise_objects::promise_abstract_operations::{
14+
promise_all_record::PromiseAll, promise_all_settled_record::PromiseAllSettled,
15+
},
1416
},
1517
execution::Agent,
1618
scripts_and_modules::module::module_semantics::{
@@ -73,6 +75,10 @@ pub(crate) enum PromiseReactionHandler<'a> {
7375
index: u32,
7476
promise_all: PromiseAll<'a>,
7577
},
78+
PromiseAllSettled {
79+
index: u32,
80+
promise_all_settled: PromiseAllSettled<'a>,
81+
},
7682
Empty,
7783
}
7884
bindable_handle!(PromiseReactionHandler);
@@ -95,6 +101,10 @@ impl HeapMarkAndSweep for PromiseReactionHandler<'static> {
95101
index: _,
96102
promise_all,
97103
} => promise_all.mark_values(queues),
104+
Self::PromiseAllSettled {
105+
index: _,
106+
promise_all_settled,
107+
} => promise_all_settled.mark_values(queues),
98108
Self::Empty => {}
99109
}
100110
}
@@ -120,6 +130,10 @@ impl HeapMarkAndSweep for PromiseReactionHandler<'static> {
120130
} => {
121131
promise_all.sweep_values(compactions);
122132
}
133+
Self::PromiseAllSettled {
134+
index: _,
135+
promise_all_settled,
136+
} => promise_all_settled.sweep_values(compactions),
123137
Self::Empty => {}
124138
}
125139
}

0 commit comments

Comments
 (0)