Skip to content

Commit d09e5f1

Browse files
committed
rebase woes
1 parent a343d10 commit d09e5f1

File tree

9 files changed

+34
-84
lines changed

9 files changed

+34
-84
lines changed

nova_cli/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::{cell::RefCell, collections::VecDeque, fmt::Debug};
77
use clap::{Parser as ClapParser, Subcommand};
88
use nova_vm::ecmascript::{
99
execution::{
10-
agent::{GcAgent, Options},
11-
initialize_host_defined_realm, Agent, DefaultHostHooks, Realm,
10+
agent::{GcAgent, HostHooks, Job, Options},
11+
initialize_host_defined_realm, Agent, Realm,
1212
},
1313
scripts_and_modules::script::{parse_script, script_evaluation},
1414
types::{Object, Value},
@@ -121,11 +121,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
121121
Ok(script) => script,
122122
Err((file, errors)) => exit_with_parse_errors(errors, &path, &file),
123123
};
124-
let result = script_evaluation(agent, script);
124+
let mut result = script_evaluation(agent, script);
125125

126126
if result.is_ok() {
127127
while let Some(job) = host_hooks.pop_promise_job() {
128-
if let Err(err) = job.run(&mut agent) {
128+
if let Err(err) = job.run(agent) {
129129
result = Err(err);
130130
break;
131131
}

nova_vm/src/ecmascript/builtins/data_view.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,6 @@ impl InternalSlots for DataView {
122122

123123
impl InternalMethods for DataView {}
124124

125-
impl HeapMarkAndSweep for DataView {
126-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
127-
queues.data_views.push(*self);
128-
}
129-
130-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
131-
todo!()
132-
}
133-
}
134-
135125
impl CreateHeapData<DataViewHeapData, DataView> for Heap {
136126
fn create(&mut self, data: DataViewHeapData) -> DataView {
137127
self.data_views.push(Some(data));

nova_vm/src/ecmascript/builtins/finalization_registry.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,6 @@ impl IndexMut<FinalizationRegistry> for Vec<Option<FinalizationRegistryHeapData>
131131
}
132132
}
133133

134-
impl HeapMarkAndSweep for FinalizationRegistry {
135-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
136-
queues.finalization_registrys.push(*self);
137-
}
138-
139-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
140-
todo!()
141-
}
142-
}
143-
144134
impl CreateHeapData<FinalizationRegistryHeapData, FinalizationRegistry> for Heap {
145135
fn create(&mut self, data: FinalizationRegistryHeapData) -> FinalizationRegistry {
146136
self.finalization_registrys.push(Some(data));

nova_vm/src/ecmascript/builtins/promise/data.rs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,47 @@ impl HeapMarkAndSweep for PromiseReactions {
9494
impl HeapMarkAndSweep for PromiseHeapData {
9595
fn mark_values(&self, queues: &mut WorkQueues) {
9696
self.object_index.mark_values(queues);
97-
match self.promise_state {
97+
self.promise_state.mark_values(queues);
98+
}
99+
100+
fn sweep_values(&mut self, compactions: &CompactionLists) {
101+
self.object_index.sweep_values(compactions);
102+
self.promise_state.sweep_values(compactions);
103+
}
104+
}
105+
106+
impl HeapMarkAndSweep for PromiseState {
107+
fn mark_values(&self, queues: &mut WorkQueues) {
108+
match self {
109+
PromiseState::Pending {
110+
fulfill_reactions,
111+
reject_reactions,
112+
..
113+
} => {
114+
fulfill_reactions.mark_values(queues);
115+
reject_reactions.mark_values(queues);
116+
}
98117
PromiseState::Fulfilled { promise_result }
99118
| PromiseState::Rejected { promise_result, .. } => {
100119
promise_result.mark_values(queues);
101120
}
102-
_ => {}
103121
}
104-
self.promise_fulfill_reactions.mark_values(queues);
105-
self.promise_reject_reactions.mark_values(queues);
106122
}
107123

108124
fn sweep_values(&mut self, compactions: &CompactionLists) {
109-
self.object_index.sweep_values(compactions);
110-
match &mut self.promise_state {
125+
match self {
126+
PromiseState::Pending {
127+
fulfill_reactions,
128+
reject_reactions,
129+
..
130+
} => {
131+
fulfill_reactions.sweep_values(compactions);
132+
reject_reactions.sweep_values(compactions);
133+
}
111134
PromiseState::Fulfilled { promise_result }
112-
| PromiseState::Rejected { promise_result } => {
135+
| PromiseState::Rejected { promise_result, .. } => {
113136
promise_result.sweep_values(compactions);
114137
}
115-
_ => {}
116138
}
117-
self.promise_fulfill_reactions.sweep_values(compactions);
118-
self.promise_reject_reactions.sweep_values(compactions);
119139
}
120140
}

nova_vm/src/ecmascript/builtins/proxy.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,6 @@ impl IndexMut<Proxy> for Vec<Option<ProxyHeapData>> {
229229
}
230230
}
231231

232-
impl HeapMarkAndSweep for Proxy {
233-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
234-
queues.proxys.push(*self);
235-
}
236-
237-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
238-
todo!()
239-
}
240-
}
241-
242232
impl CreateHeapData<ProxyHeapData, Proxy> for Heap {
243233
fn create(&mut self, data: ProxyHeapData) -> Proxy {
244234
self.proxys.push(Some(data));

nova_vm/src/ecmascript/builtins/typed_array.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,6 @@ impl InternalSlots for TypedArray {
194194

195195
impl InternalMethods for TypedArray {}
196196

197-
impl HeapMarkAndSweep for TypedArrayIndex {
198-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
199-
queues.typed_arrays.push(*self);
200-
}
201-
202-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
203-
todo!()
204-
}
205-
}
206-
207197
impl CreateHeapData<TypedArrayHeapData, TypedArray> for Heap {
208198
fn create(&mut self, data: TypedArrayHeapData) -> TypedArray {
209199
self.typed_arrays.push(Some(data));

nova_vm/src/ecmascript/builtins/weak_map.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@ impl IndexMut<WeakMap> for Vec<Option<WeakMapHeapData>> {
133133
}
134134
}
135135

136-
impl HeapMarkAndSweep for WeakMap {
137-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
138-
queues.weak_maps.push(*self);
139-
}
140-
141-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
142-
todo!()
143-
}
144-
}
145-
146136
impl CreateHeapData<WeakMapHeapData, WeakMap> for Heap {
147137
fn create(&mut self, data: WeakMapHeapData) -> WeakMap {
148138
self.weak_maps.push(Some(data));

nova_vm/src/ecmascript/builtins/weak_ref.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,6 @@ impl IndexMut<WeakRef> for Vec<Option<WeakRefHeapData>> {
132132
}
133133
}
134134

135-
impl HeapMarkAndSweep for WeakRef {
136-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
137-
queues.weak_refs.push(*self);
138-
}
139-
140-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
141-
todo!()
142-
}
143-
}
144-
145135
impl CreateHeapData<WeakRefHeapData, WeakRef> for Heap {
146136
fn create(&mut self, data: WeakRefHeapData) -> WeakRef {
147137
self.weak_refs.push(Some(data));

nova_vm/src/ecmascript/builtins/weak_set.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@ impl IndexMut<WeakSet> for Vec<Option<WeakSetHeapData>> {
143143
}
144144
}
145145

146-
impl HeapMarkAndSweep for WeakSet {
147-
fn mark_values(&self, queues: &mut crate::heap::WorkQueues) {
148-
queues.weak_sets.push(*self);
149-
}
150-
151-
fn sweep_values(&mut self, _compactions: &crate::heap::CompactionLists) {
152-
todo!()
153-
}
154-
}
155-
156146
impl CreateHeapData<WeakSetHeapData, WeakSet> for Heap {
157147
fn create(&mut self, data: WeakSetHeapData) -> WeakSet {
158148
self.weak_sets.push(Some(data));

0 commit comments

Comments
 (0)