[weakrefs] Rename FinalizationGroup to FinalizationRegistry for JS

The deprecated legacy FinalizationGroup APIs are left unchanged for
compat.

Bug: v8:8179
Change-Id: I9bdcaa92360db318c96fc8524c04163ece25118e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2071236
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66437}
This commit is contained in:
Shu-yu Guo 2020-02-24 17:19:48 -08:00 committed by Commit Bot
parent 4c357f203b
commit ff89c6bc6f
49 changed files with 133 additions and 130 deletions

View File

@ -5897,14 +5897,15 @@ class V8_EXPORT RegExp : public Object {
};
/**
* An instance of the built-in FinalizationGroup constructor.
* An instance of the built-in FinalizationRegistry constructor.
*
* This API is experimental and may change significantly.
* The C++ name is FinalizationGroup for backwards compatibility. This API is
* experimental and deprecated.
*/
class V8_EXPORT FinalizationGroup : public Object {
public:
/**
* Runs the cleanup callback of the given FinalizationGroup.
* Runs the cleanup callback of the given FinalizationRegistry.
*
* V8 will inform the embedder that there are finalizer callbacks be
* called through HostCleanupFinalizationGroupCallback.
@ -8500,12 +8501,12 @@ class V8_EXPORT Isolate {
AbortOnUncaughtExceptionCallback callback);
/**
* This specifies the callback to be called when finalization groups
* This specifies the callback to be called when FinalizationRegistries
* are ready to be cleaned up and require FinalizationGroup::Cleanup()
* to be called in a future task.
*/
V8_DEPRECATED(
"FinalizationGroup cleanup is automatic if "
"FinalizationRegistry cleanup is automatic if "
"HostCleanupFinalizationGroupCallback is not set")
void SetHostCleanupFinalizationGroupCallback(
HostCleanupFinalizationGroupCallback callback);
@ -9120,7 +9121,7 @@ class V8_EXPORT Isolate {
/**
* Optional notification that a context has been disposed. V8 uses these
* notifications to guide the GC heuristic and cancel FinalizationGroup
* notifications to guide the GC heuristic and cancel FinalizationRegistry
* cleanup tasks. Returns the number of context disposals - including this one
* - since the last time V8 had a chance to clean up.
*

View File

@ -578,11 +578,11 @@ namespace internal {
T(WeakRefsUnregisterTokenMustBeObject, \
"unregisterToken ('%') must be an object") \
T(WeakRefsCleanupMustBeCallable, \
"FinalizationGroup: cleanup must be callable") \
"FinalizationRegistry: cleanup must be callable") \
T(WeakRefsRegisterTargetMustBeObject, \
"FinalizationGroup.prototype.register: target must be an object") \
"FinalizationRegistry.prototype.register: target must be an object") \
T(WeakRefsRegisterTargetAndHoldingsMustNotBeSame, \
"FinalizationGroup.prototype.register: target and holdings must not " \
"FinalizationRegistry.prototype.register: target and holdings must not " \
"be same") \
T(WeakRefsWeakRefConstructorTargetMustBeObject, \
"WeakRef: target must be an object") \

View File

@ -2680,7 +2680,7 @@ void Heap::ProcessDirtyJSFinalizationRegistries(WeakObjectRetainer* retainer) {
this, dirty_js_finalization_registries_list(), retainer);
set_dirty_js_finalization_registries_list(head);
// If the list is empty, set the tail to undefined. Otherwise the tail is set
// by WeakListVisitor<JSFinalizationGroup>::VisitLiveObject.
// by WeakListVisitor<JSFinalizationRegistry>::VisitLiveObject.
if (head.IsUndefined(isolate())) {
set_dirty_js_finalization_registries_list_tail(head);
}

View File

@ -4309,7 +4309,7 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
{
// Create %FinalizationRegistryPrototype%
Handle<String> finalization_registry_name =
factory->NewStringFromStaticChars("FinalizationGroup");
factory->NewStringFromStaticChars("FinalizationRegistry");
Handle<JSObject> finalization_registry_prototype = factory->NewJSObject(
isolate()->object_function(), AllocationType::kOld);
@ -4394,7 +4394,7 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
JSObject::ForceSetPrototype(cleanup_iterator_prototype, iterator_prototype);
InstallToStringTag(isolate(), cleanup_iterator_prototype,
"FinalizationGroup Cleanup Iterator");
"FinalizationRegistry Cleanup Iterator");
SimpleInstallFunction(isolate(), cleanup_iterator_prototype, "next",
Builtins::kFinalizationRegistryCleanupIteratorNext, 0,

View File

@ -20,7 +20,7 @@ Handle<JSFinalizationRegistry> ConstructJSFinalizationRegistry(
Isolate* isolate) {
Factory* factory = isolate->factory();
Handle<String> finalization_registry_name =
factory->NewStringFromStaticChars("FinalizationGroup");
factory->NewStringFromStaticChars("FinalizationRegistry");
Handle<Object> global =
handle(isolate->native_context()->global_object(), isolate);
Handle<JSFunction> finalization_registry_fun = Handle<JSFunction>::cast(

View File

@ -1,6 +0,0 @@
*%(basename)s:7: TypeError: FinalizationGroup: cleanup must be callable
let fg = new FinalizationGroup();
^
TypeError: FinalizationGroup: cleanup must be callable
at new FinalizationGroup (<anonymous>)
at *%(basename)s:7:10

View File

@ -1,6 +0,0 @@
*%(basename)s:7: TypeError: FinalizationGroup: cleanup must be callable
let fg = new FinalizationGroup({});
^
TypeError: FinalizationGroup: cleanup must be callable
at new FinalizationGroup (<anonymous>)
at *%(basename)s:7:10

View File

@ -4,4 +4,4 @@
// Flags: --harmony-weak-refs
let fg = new FinalizationGroup();
let fg = new FinalizationRegistry();

View File

@ -0,0 +1,6 @@
*%(basename)s:7: TypeError: FinalizationRegistry: cleanup must be callable
let fg = new FinalizationRegistry();
^
TypeError: FinalizationRegistry: cleanup must be callable
at new FinalizationRegistry (<anonymous>)
at *%(basename)s:7:10

View File

@ -4,4 +4,4 @@
// Flags: --harmony-weak-refs
let fg = new FinalizationGroup({});
let fg = new FinalizationRegistry({});

View File

@ -0,0 +1,6 @@
*%(basename)s:7: TypeError: FinalizationRegistry: cleanup must be callable
let fg = new FinalizationRegistry({});
^
TypeError: FinalizationRegistry: cleanup must be callable
at new FinalizationRegistry (<anonymous>)
at *%(basename)s:7:10

View File

@ -4,5 +4,5 @@
// Flags: --harmony-weak-refs
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
fg.register(1);

View File

@ -1,6 +1,6 @@
*%(basename)s:8: TypeError: FinalizationGroup.prototype.register: target must be an object
*%(basename)s:8: TypeError: FinalizationRegistry.prototype.register: target must be an object
fg.register(1);
^
TypeError: FinalizationGroup.prototype.register: target must be an object
at FinalizationGroup.register (<anonymous>)
TypeError: FinalizationRegistry.prototype.register: target must be an object
at FinalizationRegistry.register (<anonymous>)
at *%(basename)s:8:4

View File

@ -4,6 +4,6 @@
// Flags: --harmony-weak-refs
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
let o = {};
fg.register(o, o);

View File

@ -1,6 +1,6 @@
*%(basename)s:9: TypeError: FinalizationGroup.prototype.register: target and holdings must not be same
*%(basename)s:9: TypeError: FinalizationRegistry.prototype.register: target and holdings must not be same
fg.register(o, o);
^
TypeError: FinalizationGroup.prototype.register: target and holdings must not be same
at FinalizationGroup.register (<anonymous>)
TypeError: FinalizationRegistry.prototype.register: target and holdings must not be same
at FinalizationRegistry.register (<anonymous>)
at *%(basename)s:9:4

View File

@ -4,5 +4,5 @@
// Flags: --harmony-weak-refs
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
fg.unregister(1);

View File

@ -2,5 +2,5 @@
fg.unregister(1);
^
TypeError: unregisterToken ('1') must be an object
at FinalizationGroup.unregister (<anonymous>)
at FinalizationRegistry.unregister (<anonymous>)
at *%(basename)s:8:4

View File

@ -13,8 +13,8 @@ function callback(iter) {
throw new Error('callback');
};
const fg1 = new FinalizationGroup(callback);
const fg2 = new FinalizationGroup(callback);
const fg1 = new FinalizationRegistry(callback);
const fg2 = new FinalizationRegistry(callback);
(function() {
let x = {};

View File

@ -4,52 +4,52 @@
// Flags: --harmony-weak-refs
(function TestConstructFinalizationGroup() {
let fg = new FinalizationGroup(() => {});
assertEquals(fg.toString(), "[object FinalizationGroup]");
(function TestConstructFinalizationRegistry() {
let fg = new FinalizationRegistry(() => {});
assertEquals(fg.toString(), "[object FinalizationRegistry]");
assertNotSame(fg.__proto__, Object.prototype);
assertSame(fg.__proto__.__proto__, Object.prototype);
})();
(function TestFinalizationGroupConstructorCallAsFunction() {
(function TestFinalizationRegistryConstructorCallAsFunction() {
let caught = false;
let message = "";
try {
let f = FinalizationGroup(() => {});
let f = FinalizationRegistry(() => {});
} catch (e) {
message = e.message;
caught = true;
} finally {
assertTrue(caught);
assertEquals(message, "Constructor FinalizationGroup requires 'new'");
assertEquals(message, "Constructor FinalizationRegistry requires 'new'");
}
})();
(function TestConstructFinalizationGroupCleanupNotCallable() {
let message = "FinalizationGroup: cleanup must be callable";
assertThrows(() => { let fg = new FinalizationGroup(); }, TypeError, message);
assertThrows(() => { let fg = new FinalizationGroup(1); }, TypeError, message);
assertThrows(() => { let fg = new FinalizationGroup(null); }, TypeError, message);
(function TestConstructFinalizationRegistryCleanupNotCallable() {
let message = "FinalizationRegistry: cleanup must be callable";
assertThrows(() => { let fg = new FinalizationRegistry(); }, TypeError, message);
assertThrows(() => { let fg = new FinalizationRegistry(1); }, TypeError, message);
assertThrows(() => { let fg = new FinalizationRegistry(null); }, TypeError, message);
})();
(function TestConstructFinalizationGroupWithCallableProxyAsCleanup() {
(function TestConstructFinalizationRegistryWithCallableProxyAsCleanup() {
let handler = {};
let obj = () => {};
let proxy = new Proxy(obj, handler);
let fg = new FinalizationGroup(proxy);
let fg = new FinalizationRegistry(proxy);
})();
(function TestConstructFinalizationGroupWithNonCallableProxyAsCleanup() {
let message = "FinalizationGroup: cleanup must be callable";
(function TestConstructFinalizationRegistryWithNonCallableProxyAsCleanup() {
let message = "FinalizationRegistry: cleanup must be callable";
let handler = {};
let obj = {};
let proxy = new Proxy(obj, handler);
assertThrows(() => { let fg = new FinalizationGroup(proxy); }, TypeError, message);
assertThrows(() => { let fg = new FinalizationRegistry(proxy); }, TypeError, message);
})();
(function TestRegisterWithNonObjectTarget() {
let fg = new FinalizationGroup(() => {});
let message = "FinalizationGroup.prototype.register: target must be an object";
let fg = new FinalizationRegistry(() => {});
let message = "FinalizationRegistry.prototype.register: target must be an object";
assertThrows(() => fg.register(1, "holdings"), TypeError, message);
assertThrows(() => fg.register(false, "holdings"), TypeError, message);
assertThrows(() => fg.register("foo", "holdings"), TypeError, message);
@ -62,40 +62,40 @@
let handler = {};
let obj = {};
let proxy = new Proxy(obj, handler);
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
fg.register(proxy);
})();
(function TestRegisterTargetAndHoldingsSameValue() {
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
let obj = {a: 1};
// SameValue(target, holdings) not ok
assertThrows(() => fg.register(obj, obj), TypeError,
"FinalizationGroup.prototype.register: target and holdings must not be same");
"FinalizationRegistry.prototype.register: target and holdings must not be same");
let holdings = {a: 1};
fg.register(obj, holdings);
})();
(function TestRegisterWithoutFinalizationGroup() {
assertThrows(() => FinalizationGroup.prototype.register.call({}, {}, "holdings"), TypeError);
(function TestRegisterWithoutFinalizationRegistry() {
assertThrows(() => FinalizationRegistry.prototype.register.call({}, {}, "holdings"), TypeError);
// Does not throw:
let fg = new FinalizationGroup(() => {});
FinalizationGroup.prototype.register.call(fg, {}, "holdings");
let fg = new FinalizationRegistry(() => {});
FinalizationRegistry.prototype.register.call(fg, {}, "holdings");
})();
(function TestUnregisterWithNonExistentKey() {
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
let success = fg.unregister({"k": "whatever"});
assertFalse(success);
})();
(function TestUnregisterWithNonFinalizationGroup() {
assertThrows(() => FinalizationGroup.prototype.unregister.call({}, {}),
(function TestUnregisterWithNonFinalizationRegistry() {
assertThrows(() => FinalizationRegistry.prototype.unregister.call({}, {}),
TypeError);
})();
(function TestUnregisterWithNonObjectUnregisterToken() {
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
assertThrows(() => fg.unregister(1), TypeError);
assertThrows(() => fg.unregister(1n), TypeError);
assertThrows(() => fg.unregister('one'), TypeError);
@ -149,16 +149,16 @@
let wr = new WeakRef(proxy);
})();
(function TestCleanupSomeWithoutFinalizationGroup() {
assertThrows(() => FinalizationGroup.prototype.cleanupSome.call({}), TypeError);
(function TestCleanupSomeWithoutFinalizationRegistry() {
assertThrows(() => FinalizationRegistry.prototype.cleanupSome.call({}), TypeError);
// Does not throw:
let fg = new FinalizationGroup(() => {});
let rv = FinalizationGroup.prototype.cleanupSome.call(fg);
let fg = new FinalizationRegistry(() => {});
let rv = FinalizationRegistry.prototype.cleanupSome.call(fg);
assertEquals(undefined, rv);
})();
(function TestCleanupSomeWithNonCallableCallback() {
let fg = new FinalizationGroup(() => {});
let fg = new FinalizationRegistry(() => {});
assertThrows(() => fg.cleanupSome(1), TypeError);
assertThrows(() => fg.cleanupSome(1n), TypeError);
assertThrows(() => fg.cleanupSome(Symbol()), TypeError);

View File

@ -39,8 +39,8 @@ let cleanup = function(iter) {
}
}
let fg = new FinalizationGroup(cleanup);
// Create 3 objects and register them in the FinalizationGroup. The objects need
let fg = new FinalizationRegistry(cleanup);
// Create 3 objects and register them in the FinalizationRegistry. The objects need
// to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -9,9 +9,9 @@ let r = Realm.create();
let cleanup = Realm.eval(r, "var stored_global; function cleanup() { stored_global = globalThis; } cleanup");
let realm_global_this = Realm.eval(r, "globalThis");
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
// Create an object and a register it in the FinalizationGroup. The object needs
// Create an object and a register it in the FinalizationRegistry. The object needs
// to be inside a closure so that we can reliably kill them!
let weak_cell;

View File

@ -24,7 +24,7 @@ let cleanup = (iter) => {
for (holdings of iter) { }
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let o = null;
(function() {

View File

@ -6,7 +6,7 @@
let cleanedUp = false;
let r = Realm.create();
let FG = Realm.eval(r, "FinalizationGroup");
let FG = Realm.eval(r, "FinalizationRegistry");
Realm.detachGlobal(r);
let fg_not_run = new FG(() => {

View File

@ -9,9 +9,9 @@ let r = Realm.create();
let cleanup = Realm.eval(r, "var stored_global; let cleanup = new Proxy(function() { stored_global = globalThis;}, {}); cleanup");
let realm_global_this = Realm.eval(r, "globalThis");
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
// Create an object and register it in the FinalizationGroup. The object needs
// Create an object and register it in the FinalizationRegistry. The object needs
// to be inside a closure so that we can reliably kill them!
let weak_cell;

View File

@ -13,7 +13,7 @@ let cleanup = function(iter) {
++cleanup_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
(function() {
let o = {};
fg.register(o, "holdings");

View File

@ -13,7 +13,7 @@ let cleanup = function(iter) {
++cleanup_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key = {"k": "this is the key"};
(function() {
let o = {};

View File

@ -17,7 +17,7 @@ let cleanup2 = function(iter) {
++cleanup_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
(function() {
let o = {};
fg.register(o, "holdings");

View File

@ -16,7 +16,7 @@ let cleanup = function(iter) {
cleanup_called = true;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let weak_ref;
(function() {
let o = {};
@ -25,7 +25,7 @@ let weak_ref;
})();
// Since the WeakRef was created during this turn, it is not cleared by GC. The
// pointer inside the FinalizationGroup is not cleared either, since the WeakRef
// pointer inside the FinalizationRegistry is not cleared either, since the WeakRef
// keeps the target object alive.
gc();
(function() {

View File

@ -10,7 +10,7 @@ function cleanup(iter) {
cleanup_called = true;
};
(function() {
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
(function() {
let x = {};
fg.register(x, {});

View File

@ -16,7 +16,7 @@ let cleanup = function(iter) {
cleanup_called = true;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let o1 = {};
let holdings = {'a': 'this is the holdings object'};
@ -32,7 +32,7 @@ assertFalse(cleanup_called);
// Drop the last references to o1.
(() => {o1 = null;})()
// Drop the last reference to the holdings. The FinalizationGroup keeps it
// Drop the last reference to the holdings. The FinalizationRegistry keeps it
// alive, so the cleanup function will be called as normal.
holdings = null;
gc();

View File

@ -25,10 +25,10 @@ let cleanup1 = function(iter) {
++cleanup1_call_count;
}
let fg0 = new FinalizationGroup(cleanup0);
let fg1 = new FinalizationGroup(cleanup1);
let fg0 = new FinalizationRegistry(cleanup0);
let fg1 = new FinalizationRegistry(cleanup1);
// Register 1 weak reference for each FinalizationGroup and kill the objects they point to.
// Register 1 weak reference for each FinalizationRegistry and kill the objects they point to.
(function() {
// The objects need to be inside a closure so that we can reliably kill them.
let objects = [];
@ -46,7 +46,7 @@ let fg1 = new FinalizationGroup(cleanup1);
gc();
// Before the cleanup task has a chance to run, do the same thing again, so both
// FinalizationGroups are (again) scheduled for cleanup. This has to be a IIFE function
// FinalizationRegistries are (again) scheduled for cleanup. This has to be a IIFE function
// (so that we can reliably kill the objects) so we cannot use the same function
// as before.
(function() {

View File

@ -21,7 +21,7 @@ let cleanup = function(iter) {
cleanup_called = true;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let o1 = {};
let o2 = {};

View File

@ -13,10 +13,10 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg1 = new FinalizationGroup(cleanup);
let fg2 = new FinalizationGroup(cleanup);
let fg1 = new FinalizationRegistry(cleanup);
let fg2 = new FinalizationRegistry(cleanup);
// Create two objects and register them in FinalizationGroups. The objects need
// Create two objects and register them in FinalizationRegistries. The objects need
// to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -12,7 +12,7 @@ let reentrant_gc =
call_count++;
}
let fg = new FinalizationGroup(reentrant_gc);
let fg = new FinalizationRegistry(reentrant_gc);
(function() {
fg.register({}, 42);

View File

@ -14,9 +14,9 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
// Create an object and register it in the FinalizationGroup. The object needs to be inside
// Create an object and register it in the FinalizationRegistry. The object needs to be inside
// a closure so that we can reliably kill them!
(function() {

View File

@ -14,9 +14,9 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key = {"k": "this is the key"};
// Create an object and register it in the FinalizationGroup. The object needs
// Create an object and register it in the FinalizationRegistry. The object needs
// to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -9,9 +9,9 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key = {"k": "this is the key"};
// Create an object and register it in the FinalizationGroup. The object needs
// Create an object and register it in the FinalizationRegistry. The object needs
// to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -9,9 +9,9 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key = {"k": "this is the key"};
// Create an object and register it in the FinalizationGroup. The object needs
// Create an object and register it in the FinalizationRegistry. The object needs
// to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -17,9 +17,9 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key = {"k": "the key"};
// Create an object and register it in the FinalizationGroup. The object needs
// Create an object and register it in the FinalizationRegistry. The object needs
// to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -17,8 +17,8 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
// Create an object and register it in the FinalizationGroup. The object needs to be inside
let fg = new FinalizationRegistry(cleanup);
// Create an object and register it in the FinalizationRegistry. The object needs to be inside
// a closure so that we can reliably kill them!
let key = {"k": "this is the key"};

View File

@ -17,10 +17,10 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key = {"k": "this is the key"};
// Create an object and register it in the FinalizationGroup. The object needs to be inside
// Create an object and register it in the FinalizationRegistry. The object needs to be inside
// a closure so that we can reliably kill them!
(function() {

View File

@ -22,10 +22,10 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key1 = {"k": "first key"};
let key2 = {"k": "second key"};
// Create two objects and register them in the FinalizationGroup. The objects
// Create two objects and register them in the FinalizationRegistry. The objects
// need to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -21,8 +21,8 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
// Create an object and register it in the FinalizationGroup. The object needs to be inside
let fg = new FinalizationRegistry(cleanup);
// Create an object and register it in the FinalizationRegistry. The object needs to be inside
// a closure so that we can reliably kill them!
let key = {"k": "this is the key"};

View File

@ -14,10 +14,10 @@ let cleanup = function(iter) {
++cleanup_call_count;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let key1 = {"k": "key1"};
let key2 = {"k": "key2"};
// Create three objects and register them in the FinalizationGroup. The objects
// Create three objects and register them in the FinalizationRegistry. The objects
// need to be inside a closure so that we can reliably kill them!
(function() {

View File

@ -10,8 +10,8 @@ let cleanup = function(iter) {
}
let key = {"k": "this is my key"};
let fg = new FinalizationGroup(cleanup);
// Create an object and register it in the FinalizationGroup. The object needs to be inside
let fg = new FinalizationRegistry(cleanup);
// Create an object and register it in the FinalizationRegistry. The object needs to be inside
// a closure so that we can reliably kill them!
(function() {
@ -25,7 +25,7 @@ let fg = new FinalizationGroup(cleanup);
gc();
assertEquals(0, cleanup_call_count);
// Unregister the object from the FinalizationGroup before cleanup has ran.
// Unregister the object from the FinalizationRegistry before cleanup has ran.
let success = fg.unregister(key);
assertTrue(success);

View File

@ -15,7 +15,7 @@ let cleanup = function(iter) {
cleanup_called = true;
}
let fg = new FinalizationGroup(cleanup);
let fg = new FinalizationRegistry(cleanup);
let o = {};
let holdings = {'h': 55};

View File

@ -4,7 +4,7 @@
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking
var FG = new FinalizationGroup (function (iter) { globalThis.FGRan = true; });
var FG = new FinalizationRegistry (function (iter) { globalThis.FRRan = true; });
{
let obj = {};
// obj is its own unregister token and becomes unreachable after this
@ -14,7 +14,7 @@ var FG = new FinalizationGroup (function (iter) { globalThis.FGRan = true; });
}
function tryAgain() {
gc();
if (globalThis.FGRan || FG.cleanupSome()) {
if (globalThis.FRRan || FG.cleanupSome()) {
return;
}
setTimeout(tryAgain, 0);

View File

@ -496,13 +496,15 @@
'language/comments/hashbang/use-strict': [SKIP],
# https://bugs.chromium.org/p/v8/issues/detail?id=8179
# Temporarily removed pending https://github.com/tc39/test262/issues/2339
#
# These tests require exception handling support which is currently
# blocked on landing https://chromium-review.googlesource.com/c/v8/v8/+/1655655
'built-ins/FinalizationGroup/FinalizationGroupCleanupIteratorPrototype/next-job-not-active-throws': [FAIL],
'built-ins/FinalizationGroup/prototype/cleanupSome/cleanup-throws-in-callback': [FAIL],
'built-ins/FinalizationGroup/prototype/cleanupSome/poisoned-callback-throws': [FAIL],
# FinalizationGroup is renamed to FinalizationRegistry, skip all of these as
# an intermediate state until the next roll which has the renamed tests.
'built-ins/FinalizationGroup/*': [SKIP],
'built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws': [SKIP],
'built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref': [SKIP],
# 'built-ins/FinalizationGroup/FinalizationGroupCleanupIteratorPrototype/next-job-not-active-throws': [FAIL],
# 'built-ins/FinalizationGroup/prototype/cleanupSome/cleanup-throws-in-callback': [FAIL],
# 'built-ins/FinalizationGroup/prototype/cleanupSome/poisoned-callback-throws': [FAIL],
# 'built-ins/FinalizationGroup/prototype/cleanupSome/poisoned-cleanup-callback-throws': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=9612