mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-25 15:29:43 -05:00
Don't run GC on isolate disposal (#1181)
Removing this garbage collection trigger removes the guarantee that "regular" FinalizerCallbacks will be called before the isolate goes away. It is fine as both spec and V8 do not provide this guarantee and we were overly strict in this case.
This commit is contained in:
parent
1269ad6ac5
commit
d3fff51d2d
3 changed files with 0 additions and 44 deletions
|
@ -954,10 +954,6 @@ impl FinalizerMap {
|
|||
id
|
||||
}
|
||||
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.map.is_empty()
|
||||
}
|
||||
|
||||
pub(crate) fn drain(
|
||||
&mut self,
|
||||
) -> impl Iterator<Item = FinalizerCallback> + '_ {
|
||||
|
|
|
@ -1182,15 +1182,6 @@ impl Isolate {
|
|||
// Drop the scope stack.
|
||||
ScopeData::drop_root(self);
|
||||
|
||||
// If there are finalizers left to call, we trigger GC to try and call as
|
||||
// many of them as possible.
|
||||
if !self.get_annex().finalizer_map.is_empty() {
|
||||
// A low memory notification triggers a synchronous GC, which means
|
||||
// finalizers will be called during the course of the call, rather than at
|
||||
// some later point.
|
||||
self.low_memory_notification();
|
||||
}
|
||||
|
||||
// Set the `isolate` pointer inside the annex struct to null, so any
|
||||
// IsolateHandle that outlives the isolate will know that it can't call
|
||||
// methods on the isolate.
|
||||
|
|
|
@ -7943,37 +7943,6 @@ fn drop_weak_from_raw_in_finalizer() {
|
|||
assert!(finalized.get());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finalizer_on_global_object() {
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
||||
let _setup_guard = setup::parallel_test();
|
||||
|
||||
let weak;
|
||||
let finalized = Rc::new(Cell::new(false));
|
||||
|
||||
{
|
||||
let isolate = &mut v8::Isolate::new(Default::default());
|
||||
let scope = &mut v8::HandleScope::new(isolate);
|
||||
let context = v8::Context::new(scope);
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
|
||||
let global_object = context.global(scope);
|
||||
weak = v8::Weak::with_finalizer(
|
||||
scope,
|
||||
global_object,
|
||||
Box::new({
|
||||
let finalized = finalized.clone();
|
||||
move |_| finalized.set(true)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
assert!(finalized.get());
|
||||
drop(weak);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finalizer_on_kept_global() {
|
||||
// If a global is kept alive after an isolate is dropped, regular finalizers
|
||||
|
|
Loading…
Reference in a new issue