[weakrefs] Split out FinalizationRegistry#cleanupSome to a different flag
Apple currently objects to cleanupSome but agrees to shipping the rest of WeakRefs. Separate out cleanupSome to its own flag so the rest of WeakRefs may ship. Bug: v8:8179 Change-Id: I6159fc743c9cb658860d4260b0dcb95e54630fdc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2141011 Commit-Queue: Shu-yu Guo <syg@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#67070}
This commit is contained in:
parent
f902b9dd8d
commit
e3e81892a4
@ -207,15 +207,19 @@ DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features")
|
||||
DEFINE_IMPLICATION(es_staging, harmony)
|
||||
// Enabling import.meta requires to also enable import()
|
||||
DEFINE_IMPLICATION(harmony_import_meta, harmony_dynamic_import)
|
||||
// Enabling FinalizationRegistry#cleanupSome also enables weak refs
|
||||
DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs)
|
||||
|
||||
// Update bootstrapper.cc whenever adding a new feature flag.
|
||||
|
||||
// Features that are still work in progress (behind individual flags).
|
||||
#define HARMONY_INPROGRESS_BASE(V) \
|
||||
V(harmony_string_replaceall, "harmony String.prototype.replaceAll") \
|
||||
V(harmony_regexp_sequence, "RegExp Unicode sequence properties") \
|
||||
V(harmony_weak_refs, "harmony weak references") \
|
||||
V(harmony_regexp_match_indices, "harmony regexp match indices") \
|
||||
#define HARMONY_INPROGRESS_BASE(V) \
|
||||
V(harmony_string_replaceall, "harmony String.prototype.replaceAll") \
|
||||
V(harmony_regexp_sequence, "RegExp Unicode sequence properties") \
|
||||
V(harmony_weak_refs, "harmony weak references") \
|
||||
V(harmony_weak_refs_with_cleanup_some, \
|
||||
"harmony weak references with FinalizationRegistry.prototype.cleanupSome") \
|
||||
V(harmony_regexp_match_indices, "harmony regexp match indices") \
|
||||
V(harmony_top_level_await, "harmony top level await")
|
||||
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
|
@ -4344,10 +4344,6 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
|
||||
SimpleInstallFunction(isolate(), finalization_registry_prototype,
|
||||
"unregister",
|
||||
Builtins::kFinalizationRegistryUnregister, 1, false);
|
||||
|
||||
SimpleInstallFunction(isolate(), finalization_registry_prototype,
|
||||
"cleanupSome",
|
||||
Builtins::kFinalizationRegistryCleanupSome, 0, false);
|
||||
}
|
||||
{
|
||||
// Create %WeakRefPrototype%
|
||||
@ -4386,6 +4382,21 @@ void Genesis::InitializeGlobal_harmony_weak_refs() {
|
||||
}
|
||||
}
|
||||
|
||||
void Genesis::InitializeGlobal_harmony_weak_refs_with_cleanup_some() {
|
||||
if (!FLAG_harmony_weak_refs_with_cleanup_some) return;
|
||||
DCHECK(FLAG_harmony_weak_refs);
|
||||
|
||||
Handle<JSFunction> finalization_registry_fun =
|
||||
isolate()->js_finalization_registry_fun();
|
||||
Handle<JSObject> finalization_registry_prototype(
|
||||
JSObject::cast(finalization_registry_fun->instance_prototype()),
|
||||
isolate());
|
||||
|
||||
SimpleInstallFunction(isolate(), finalization_registry_prototype,
|
||||
"cleanupSome",
|
||||
Builtins::kFinalizationRegistryCleanupSome, 0, false);
|
||||
}
|
||||
|
||||
void Genesis::InitializeGlobal_harmony_promise_all_settled() {
|
||||
if (!FLAG_harmony_promise_all_settled) return;
|
||||
SimpleInstallFunction(isolate(), isolate()->promise_function(), "allSettled",
|
||||
|
25
test/mjsunit/harmony/weakrefs/basics-cleanupsome.js
Normal file
25
test/mjsunit/harmony/weakrefs/basics-cleanupsome.js
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-weak-refs-with-cleanup-some
|
||||
|
||||
(function TestCleanupSomeWithoutFinalizationRegistry() {
|
||||
assertThrows(() => FinalizationRegistry.prototype.cleanupSome.call({}), TypeError);
|
||||
// Does not throw:
|
||||
let fg = new FinalizationRegistry(() => {});
|
||||
let rv = FinalizationRegistry.prototype.cleanupSome.call(fg);
|
||||
assertEquals(undefined, rv);
|
||||
})();
|
||||
|
||||
(function TestCleanupSomeWithNonCallableCallback() {
|
||||
let fg = new FinalizationRegistry(() => {});
|
||||
assertThrows(() => fg.cleanupSome(1), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(1n), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(Symbol()), TypeError);
|
||||
assertThrows(() => fg.cleanupSome({}), TypeError);
|
||||
assertThrows(() => fg.cleanupSome('foo'), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(true), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(false), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(null), TypeError);
|
||||
})();
|
@ -148,23 +148,3 @@
|
||||
let proxy = new Proxy(obj, handler);
|
||||
let wr = new WeakRef(proxy);
|
||||
})();
|
||||
|
||||
(function TestCleanupSomeWithoutFinalizationRegistry() {
|
||||
assertThrows(() => FinalizationRegistry.prototype.cleanupSome.call({}), TypeError);
|
||||
// Does not throw:
|
||||
let fg = new FinalizationRegistry(() => {});
|
||||
let rv = FinalizationRegistry.prototype.cleanupSome.call(fg);
|
||||
assertEquals(undefined, rv);
|
||||
})();
|
||||
|
||||
(function TestCleanupSomeWithNonCallableCallback() {
|
||||
let fg = new FinalizationRegistry(() => {});
|
||||
assertThrows(() => fg.cleanupSome(1), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(1n), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(Symbol()), TypeError);
|
||||
assertThrows(() => fg.cleanupSome({}), TypeError);
|
||||
assertThrows(() => fg.cleanupSome('foo'), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(true), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(false), TypeError);
|
||||
assertThrows(() => fg.cleanupSome(null), TypeError);
|
||||
})();
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
|
||||
// Flags: --harmony-weak-refs-with-cleanup-some --expose-gc --noincremental-marking --allow-natives-syntax
|
||||
|
||||
let cleanup_count = 0;
|
||||
let cleanup_holdings = [];
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking
|
||||
// Flags: --harmony-weak-refs-with-cleanup-some --expose-gc --noincremental-marking
|
||||
|
||||
let cleanup_count = 0;
|
||||
let cleanup_holdings = [];
|
||||
|
13
test/mjsunit/harmony/weakrefs/cleanupsome-optional.js
Normal file
13
test/mjsunit/harmony/weakrefs/cleanupsome-optional.js
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-weak-refs
|
||||
|
||||
// FinalizationRegistry#cleanupSome is normative optional and has its own
|
||||
// flag. Test that it's not present with only --harmony-weak-refs.
|
||||
|
||||
assertEquals(undefined, Object.getOwnPropertyDescriptor(
|
||||
FinalizationRegistry.prototype, "cleanupSome"));
|
||||
assertEquals(undefined, FinalizationRegistry.prototype.cleanupSome);
|
||||
assertFalse('cleanupSome' in FinalizationRegistry.prototype);
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
|
||||
// Flags: --harmony-weak-refs-with-cleanup-some --expose-gc --noincremental-marking --allow-natives-syntax
|
||||
|
||||
let cleanup_count = 0;
|
||||
let cleanup_holdings = [];
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking
|
||||
// Flags: --harmony-weak-refs-with-cleanup-some --expose-gc --noincremental-marking
|
||||
|
||||
var FR = new FinalizationRegistry (function (holdings) { globalThis.FRRan = true; });
|
||||
{
|
||||
|
@ -53,8 +53,8 @@ FEATURE_FLAGS = {
|
||||
'Symbol.prototype.description': '--harmony-symbol-description',
|
||||
'export-star-as-namespace-from-module': '--harmony-namespace-exports',
|
||||
'Promise.allSettled': '--harmony-promise-all-settled',
|
||||
'FinalizationRegistry': '--harmony-weak-refs',
|
||||
'WeakRef': '--harmony-weak-refs',
|
||||
'FinalizationRegistry': '--harmony-weak-refs-with-cleanup-some',
|
||||
'WeakRef': '--harmony-weak-refs-with-cleanup-some',
|
||||
'host-gc-required': '--expose-gc-as=v8GC',
|
||||
'optional-chaining': '--harmony-optional-chaining',
|
||||
'top-level-await': '--harmony-top-level-await',
|
||||
|
Loading…
Reference in New Issue
Block a user