Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions nova_vm/src/heap/heap_gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ use crate::{
EmbedderObject, Environments, Error, FinalizationRegistry, FunctionEnvironment, Generator,
GlobalEnvironment, HeapBigInt, HeapNumber, HeapString, Map, MapIterator, Module,
ModuleEnvironment, ModuleRequest, ObjectEnvironment, ObjectShape, OrdinaryObject,
PrimitiveObject, Promise, PromiseGroup, PromiseReaction, PropertyLookupCache, Proxy, Realm,
Script, SourceCode, SourceTextModule, StringIterator, Symbol,
PrimitiveObject, PrivateEnvironment, Promise, PromiseGroup, PromiseReaction,
PropertyLookupCache, Proxy, Realm, Script, SourceCode, SourceTextModule, StringIterator,
Symbol,
},
engine::{Bindable, Executable, GcScope},
heap::{
Expand Down Expand Up @@ -167,7 +168,7 @@ pub(crate) fn heap_gc(agent: &mut Agent, root_realms: &mut [Option<Realm<'static
global: global_environments,
module: module_environments,
object: object_environments,
private: _private_environments,
private: private_environments,
} = environments;
let ElementArrays {
e2pow1,
Expand Down Expand Up @@ -293,6 +294,19 @@ pub(crate) fn heap_gc(agent: &mut Agent, root_realms: &mut [Option<Realm<'static
});
}

if !queues.private_environments.is_empty() {
let mut private_environment_marks: Box<[PrivateEnvironment]> =
queues.private_environments.drain(..).collect();
private_environment_marks.sort();
private_environment_marks.iter().for_each(|&idx| {
let index = idx.get_index();
if bits.private_environments.set_bit(index, &bits.bits) {
// Did mark.
private_environments.get(index).mark_values(&mut queues);
}
});
}

if !queues.pending_ephemerons.is_empty() {
queues.pending_ephemerons.sort_by_key(|(key, _)| *key);
let new_values_to_mark = queues
Expand Down Expand Up @@ -1295,7 +1309,7 @@ fn sweep(
global,
module,
object,
private: _private_environments,
private,
} = environments;
let ElementArrays {
e2pow1,
Expand Down Expand Up @@ -1790,6 +1804,16 @@ fn sweep(
);
});
}
if !private.is_empty() {
s.spawn(|| {
sweep_heap_vector_values(
private,
&compactions,
&bits.private_environments,
&bits.bits,
);
});
}
if !object_shapes.is_empty() {
s.spawn(|| {
sweep_heap_vector_values(
Expand Down
Loading