Skip to content

Commit d59db06

Browse files
aduh95Commit Bot
authored andcommitted
[weakrefs] Remove --no-harmony-weak-refs flag
Bug: v8:8179 Change-Id: I7f699073807d1874d0c10a4f1641de6bfb0efe6f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2741582 Commit-Queue: Shu-yu Guo <[email protected]> Reviewed-by: Shu-yu Guo <[email protected]> Reviewed-by: Adam Klein <[email protected]> Reviewed-by: Sathya Gunasekaran <[email protected]> Cr-Commit-Position: refs/heads/master@{#73871}
1 parent 67a52e8 commit d59db06

46 files changed

Lines changed: 103 additions & 160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/flags/flag-definitions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ DEFINE_BOOL(use_strict, false, "enforce strict mode")
259259

260260
DEFINE_BOOL(harmony, false, "enable all completed harmony features")
261261
DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features")
262-
// Enabling FinalizationRegistry#cleanupSome also enables weak refs
263-
DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs)
264262

265263
// Update bootstrapper.cc whenever adding a new feature flag.
266264

@@ -299,7 +297,6 @@ DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs)
299297
#define HARMONY_SHIPPING_BASE(V) \
300298
V(harmony_sharedarraybuffer, "harmony sharedarraybuffer") \
301299
V(harmony_atomics, "harmony atomics") \
302-
V(harmony_weak_refs, "harmony weak references") \
303300
V(harmony_regexp_match_indices, "harmony regexp match indices") \
304301
V(harmony_private_brand_checks, "harmony private brand checks") \
305302
V(harmony_top_level_await, "harmony top level await")

src/heap/heap.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6277,8 +6277,6 @@ MaybeHandle<JSFinalizationRegistry> Heap::DequeueDirtyJSFinalizationRegistry() {
62776277
}
62786278

62796279
void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
6280-
if (!FLAG_harmony_weak_refs) return;
6281-
62826280
DisallowGarbageCollection no_gc;
62836281

62846282
Isolate* isolate = this->isolate();
@@ -6308,7 +6306,6 @@ void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
63086306
}
63096307

63106308
void Heap::KeepDuringJob(Handle<JSReceiver> target) {
6311-
DCHECK(FLAG_harmony_weak_refs);
63126309
DCHECK(weak_refs_keep_during_job().IsUndefined() ||
63136310
weak_refs_keep_during_job().IsOrderedHashSet());
63146311
Handle<OrderedHashSet> table;

src/heap/mark-compact.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,9 +2483,6 @@ void MarkCompactCollector::ClearWeakReferences() {
24832483
}
24842484

24852485
void MarkCompactCollector::ClearJSWeakRefs() {
2486-
if (!FLAG_harmony_weak_refs) {
2487-
return;
2488-
}
24892486
JSWeakRef weak_ref;
24902487
while (weak_objects_.js_weak_refs.Pop(kMainThreadTask, &weak_ref)) {
24912488
HeapObject target = HeapObject::cast(weak_ref.target());

src/heap/weak-object-worklists.cc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,17 @@ void WeakObjects::UpdateWeakObjectsInCode(
115115

116116
void WeakObjects::UpdateJSWeakRefs(
117117
WeakObjectWorklist<JSWeakRef>& js_weak_refs) {
118-
if (FLAG_harmony_weak_refs) {
119-
js_weak_refs.Update(
120-
[](JSWeakRef js_weak_ref_in, JSWeakRef* js_weak_ref_out) -> bool {
121-
JSWeakRef forwarded = ForwardingAddress(js_weak_ref_in);
122-
123-
if (!forwarded.is_null()) {
124-
*js_weak_ref_out = forwarded;
125-
return true;
126-
}
127-
128-
return false;
129-
});
130-
}
118+
js_weak_refs.Update(
119+
[](JSWeakRef js_weak_ref_in, JSWeakRef* js_weak_ref_out) -> bool {
120+
JSWeakRef forwarded = ForwardingAddress(js_weak_ref_in);
121+
122+
if (!forwarded.is_null()) {
123+
*js_weak_ref_out = forwarded;
124+
return true;
125+
}
126+
127+
return false;
128+
});
131129
}
132130

133131
void WeakObjects::UpdateWeakCells(WeakObjectWorklist<WeakCell>& weak_cells) {

src/init/bootstrapper.cc

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3871,6 +3871,61 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
38713871
native_context()->set_bound_function_with_constructor_map(*map);
38723872
}
38733873

3874+
{ // -- F i n a l i z a t i o n R e g i s t r y
3875+
Handle<JSFunction> finalization_registry_fun = InstallFunction(
3876+
isolate_, global, factory->FinalizationRegistry_string(),
3877+
JS_FINALIZATION_REGISTRY_TYPE, JSFinalizationRegistry::kHeaderSize, 0,
3878+
factory->the_hole_value(), Builtins::kFinalizationRegistryConstructor);
3879+
InstallWithIntrinsicDefaultProto(
3880+
isolate_, finalization_registry_fun,
3881+
Context::JS_FINALIZATION_REGISTRY_FUNCTION_INDEX);
3882+
3883+
finalization_registry_fun->shared().DontAdaptArguments();
3884+
finalization_registry_fun->shared().set_length(1);
3885+
3886+
Handle<JSObject> finalization_registry_prototype(
3887+
JSObject::cast(finalization_registry_fun->instance_prototype()),
3888+
isolate());
3889+
3890+
InstallToStringTag(isolate_, finalization_registry_prototype,
3891+
factory->FinalizationRegistry_string());
3892+
3893+
SimpleInstallFunction(isolate_, finalization_registry_prototype, "register",
3894+
Builtins::kFinalizationRegistryRegister, 2, false);
3895+
3896+
SimpleInstallFunction(isolate_, finalization_registry_prototype,
3897+
"unregister",
3898+
Builtins::kFinalizationRegistryUnregister, 1, false);
3899+
3900+
// The cleanupSome function is created but not exposed, as it is used
3901+
// internally by InvokeFinalizationRegistryCleanupFromTask.
3902+
//
3903+
// It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
3904+
Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction(
3905+
isolate_, factory->InternalizeUtf8String("cleanupSome"),
3906+
Builtins::kFinalizationRegistryPrototypeCleanupSome, 0, false);
3907+
native_context()->set_finalization_registry_cleanup_some(*cleanup_some_fun);
3908+
}
3909+
3910+
{ // -- W e a k R e f
3911+
Handle<JSFunction> weak_ref_fun = InstallFunction(
3912+
isolate_, global, "WeakRef", JS_WEAK_REF_TYPE, JSWeakRef::kHeaderSize,
3913+
0, factory->the_hole_value(), Builtins::kWeakRefConstructor);
3914+
InstallWithIntrinsicDefaultProto(isolate_, weak_ref_fun,
3915+
Context::JS_WEAK_REF_FUNCTION_INDEX);
3916+
3917+
weak_ref_fun->shared().DontAdaptArguments();
3918+
weak_ref_fun->shared().set_length(1);
3919+
3920+
Handle<JSObject> weak_ref_prototype(
3921+
JSObject::cast(weak_ref_fun->instance_prototype()), isolate());
3922+
3923+
InstallToStringTag(isolate_, weak_ref_prototype, factory->WeakRef_string());
3924+
3925+
SimpleInstallFunction(isolate_, weak_ref_prototype, "deref",
3926+
Builtins::kWeakRefDeref, 0, true);
3927+
}
3928+
38743929
{ // --- sloppy arguments map
38753930
Handle<String> arguments_string = factory->Arguments_string();
38763931
Handle<JSFunction> function = CreateFunctionForBuiltinWithPrototype(
@@ -4363,75 +4418,8 @@ void Genesis::InitializeGlobal_harmony_atomics() {
43634418
InstallToStringTag(isolate_, isolate()->atomics_object(), "Atomics");
43644419
}
43654420

4366-
void Genesis::InitializeGlobal_harmony_weak_refs() {
4367-
if (!FLAG_harmony_weak_refs) return;
4368-
4369-
Factory* factory = isolate()->factory();
4370-
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
4371-
4372-
{
4373-
// Create %FinalizationRegistry%
4374-
Handle<JSFunction> finalization_registry_fun = InstallFunction(
4375-
isolate(), global, factory->FinalizationRegistry_string(),
4376-
JS_FINALIZATION_REGISTRY_TYPE, JSFinalizationRegistry::kHeaderSize, 0,
4377-
factory->the_hole_value(), Builtins::kFinalizationRegistryConstructor);
4378-
InstallWithIntrinsicDefaultProto(
4379-
isolate(), finalization_registry_fun,
4380-
Context::JS_FINALIZATION_REGISTRY_FUNCTION_INDEX);
4381-
4382-
finalization_registry_fun->shared().DontAdaptArguments();
4383-
finalization_registry_fun->shared().set_length(1);
4384-
4385-
Handle<JSObject> finalization_registry_prototype(
4386-
JSObject::cast(finalization_registry_fun->instance_prototype()),
4387-
isolate());
4388-
4389-
InstallToStringTag(isolate(), finalization_registry_prototype,
4390-
factory->FinalizationRegistry_string());
4391-
4392-
SimpleInstallFunction(isolate(), finalization_registry_prototype,
4393-
"register", Builtins::kFinalizationRegistryRegister,
4394-
2, false);
4395-
4396-
SimpleInstallFunction(isolate(), finalization_registry_prototype,
4397-
"unregister",
4398-
Builtins::kFinalizationRegistryUnregister, 1, false);
4399-
4400-
// The cleanupSome function is created but not exposed, as it is used
4401-
// internally by InvokeFinalizationRegistryCleanupFromTask.
4402-
//
4403-
// It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
4404-
Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction(
4405-
isolate(), factory->InternalizeUtf8String("cleanupSome"),
4406-
Builtins::kFinalizationRegistryPrototypeCleanupSome, 0, false);
4407-
native_context()->set_finalization_registry_cleanup_some(*cleanup_some_fun);
4408-
}
4409-
{
4410-
// Create %WeakRef%
4411-
Handle<JSFunction> weak_ref_fun = InstallFunction(
4412-
isolate(), global, factory->WeakRef_string(), JS_WEAK_REF_TYPE,
4413-
JSWeakRef::kHeaderSize, 0, factory->the_hole_value(),
4414-
Builtins::kWeakRefConstructor);
4415-
InstallWithIntrinsicDefaultProto(isolate(), weak_ref_fun,
4416-
Context::JS_WEAK_REF_FUNCTION_INDEX);
4417-
4418-
weak_ref_fun->shared().DontAdaptArguments();
4419-
weak_ref_fun->shared().set_length(1);
4420-
4421-
Handle<JSObject> weak_ref_prototype(
4422-
JSObject::cast(weak_ref_fun->instance_prototype()), isolate());
4423-
4424-
InstallToStringTag(isolate(), weak_ref_prototype,
4425-
factory->WeakRef_string());
4426-
4427-
SimpleInstallFunction(isolate(), weak_ref_prototype, "deref",
4428-
Builtins::kWeakRefDeref, 0, true);
4429-
}
4430-
}
4431-
44324421
void Genesis::InitializeGlobal_harmony_weak_refs_with_cleanup_some() {
44334422
if (!FLAG_harmony_weak_refs_with_cleanup_some) return;
4434-
DCHECK(FLAG_harmony_weak_refs);
44354423

44364424
Handle<JSFunction> finalization_registry_fun =
44374425
isolate()->js_finalization_registry_fun();

test/cctest/test-js-weak-refs.cc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ Handle<JSWeakRef> MakeWeakRefAndKeepDuringJob(Isolate* isolate) {
209209
} // namespace
210210

211211
TEST(TestRegister) {
212-
FLAG_harmony_weak_refs = true;
213212
CcTest::InitializeVM();
214213
LocalContext context;
215214
Isolate* isolate = CcTest::i_isolate();
@@ -247,7 +246,6 @@ TEST(TestRegister) {
247246
}
248247

249248
TEST(TestRegisterWithKey) {
250-
FLAG_harmony_weak_refs = true;
251249
CcTest::InitializeVM();
252250
LocalContext context;
253251
Isolate* isolate = CcTest::i_isolate();
@@ -300,7 +298,6 @@ TEST(TestRegisterWithKey) {
300298
}
301299

302300
TEST(TestWeakCellNullify1) {
303-
FLAG_harmony_weak_refs = true;
304301
CcTest::InitializeVM();
305302
LocalContext context;
306303
Isolate* isolate = CcTest::i_isolate();
@@ -335,7 +332,6 @@ TEST(TestWeakCellNullify1) {
335332
}
336333

337334
TEST(TestWeakCellNullify2) {
338-
FLAG_harmony_weak_refs = true;
339335
CcTest::InitializeVM();
340336
LocalContext context;
341337
Isolate* isolate = CcTest::i_isolate();
@@ -369,7 +365,6 @@ TEST(TestWeakCellNullify2) {
369365
}
370366

371367
TEST(TestJSFinalizationRegistryPopClearedCellHoldings1) {
372-
FLAG_harmony_weak_refs = true;
373368
CcTest::InitializeVM();
374369
LocalContext context;
375370
Isolate* isolate = CcTest::i_isolate();
@@ -425,7 +420,6 @@ TEST(TestJSFinalizationRegistryPopClearedCellHoldings1) {
425420
TEST(TestJSFinalizationRegistryPopClearedCellHoldings2) {
426421
// Test that when all WeakCells for a key are popped, the key is removed from
427422
// the key map.
428-
FLAG_harmony_weak_refs = true;
429423
CcTest::InitializeVM();
430424
LocalContext context;
431425
Isolate* isolate = CcTest::i_isolate();
@@ -476,7 +470,6 @@ TEST(TestJSFinalizationRegistryPopClearedCellHoldings2) {
476470
}
477471

478472
TEST(TestUnregisterActiveCells) {
479-
FLAG_harmony_weak_refs = true;
480473
CcTest::InitializeVM();
481474
LocalContext context;
482475
Isolate* isolate = CcTest::i_isolate();
@@ -529,7 +522,6 @@ TEST(TestUnregisterActiveCells) {
529522
}
530523

531524
TEST(TestUnregisterActiveAndClearedCells) {
532-
FLAG_harmony_weak_refs = true;
533525
CcTest::InitializeVM();
534526
LocalContext context;
535527
Isolate* isolate = CcTest::i_isolate();
@@ -585,7 +577,6 @@ TEST(TestUnregisterActiveAndClearedCells) {
585577
}
586578

587579
TEST(TestWeakCellUnregisterTwice) {
588-
FLAG_harmony_weak_refs = true;
589580
CcTest::InitializeVM();
590581
LocalContext context;
591582
Isolate* isolate = CcTest::i_isolate();
@@ -633,7 +624,6 @@ TEST(TestWeakCellUnregisterTwice) {
633624
}
634625

635626
TEST(TestWeakCellUnregisterPopped) {
636-
FLAG_harmony_weak_refs = true;
637627
CcTest::InitializeVM();
638628
LocalContext context;
639629
Isolate* isolate = CcTest::i_isolate();
@@ -674,7 +664,6 @@ TEST(TestWeakCellUnregisterPopped) {
674664
}
675665

676666
TEST(TestWeakCellUnregisterNonexistentKey) {
677-
FLAG_harmony_weak_refs = true;
678667
CcTest::InitializeVM();
679668
LocalContext context;
680669
Isolate* isolate = CcTest::i_isolate();
@@ -687,7 +676,6 @@ TEST(TestWeakCellUnregisterNonexistentKey) {
687676
}
688677

689678
TEST(TestJSWeakRef) {
690-
FLAG_harmony_weak_refs = true;
691679
CcTest::InitializeVM();
692680
LocalContext context;
693681

@@ -716,7 +704,6 @@ TEST(TestJSWeakRef) {
716704
}
717705

718706
TEST(TestJSWeakRefIncrementalMarking) {
719-
FLAG_harmony_weak_refs = true;
720707
if (!FLAG_incremental_marking) {
721708
return;
722709
}
@@ -752,7 +739,6 @@ TEST(TestJSWeakRefIncrementalMarking) {
752739
}
753740

754741
TEST(TestJSWeakRefKeepDuringJob) {
755-
FLAG_harmony_weak_refs = true;
756742
CcTest::InitializeVM();
757743
LocalContext context;
758744

@@ -790,7 +776,6 @@ TEST(TestJSWeakRefKeepDuringJob) {
790776
}
791777

792778
TEST(TestJSWeakRefKeepDuringJobIncrementalMarking) {
793-
FLAG_harmony_weak_refs = true;
794779
if (!FLAG_incremental_marking) {
795780
return;
796781
}
@@ -819,7 +804,6 @@ TEST(TestJSWeakRefKeepDuringJobIncrementalMarking) {
819804
}
820805

821806
TEST(TestRemoveUnregisterToken) {
822-
FLAG_harmony_weak_refs = true;
823807
CcTest::InitializeVM();
824808
LocalContext context;
825809
Isolate* isolate = CcTest::i_isolate();
@@ -883,7 +867,6 @@ TEST(TestRemoveUnregisterToken) {
883867
}
884868

885869
TEST(JSWeakRefScavengedInWorklist) {
886-
FLAG_harmony_weak_refs = true;
887870
if (!FLAG_incremental_marking || FLAG_single_generation) {
888871
return;
889872
}
@@ -928,7 +911,6 @@ TEST(JSWeakRefScavengedInWorklist) {
928911
}
929912

930913
TEST(JSWeakRefTenuredInWorklist) {
931-
FLAG_harmony_weak_refs = true;
932914
if (!FLAG_incremental_marking || FLAG_single_generation) {
933915
return;
934916
}
@@ -976,7 +958,6 @@ TEST(JSWeakRefTenuredInWorklist) {
976958
}
977959

978960
TEST(UnregisterTokenHeapVerifier) {
979-
FLAG_harmony_weak_refs = true;
980961
if (!FLAG_incremental_marking) return;
981962
ManualGCScope manual_gc_scope;
982963
#ifdef VERIFY_HEAP

test/message/fail/weak-refs-finalizationregistry1.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// Flags: --harmony-weak-refs
6-
75
let fg = new FinalizationRegistry();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
*%(basename)s:7: TypeError: FinalizationRegistry: cleanup must be callable
1+
*%(basename)s:*: TypeError: FinalizationRegistry: cleanup must be callable
22
let fg = new FinalizationRegistry();
33
^
44
TypeError: FinalizationRegistry: cleanup must be callable
55
at new FinalizationRegistry (<anonymous>)
6-
at *%(basename)s:7:10
6+
at *%(basename)s:*:10

test/message/fail/weak-refs-finalizationregistry2.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// Flags: --harmony-weak-refs
6-
75
let fg = new FinalizationRegistry({});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
*%(basename)s:7: TypeError: FinalizationRegistry: cleanup must be callable
1+
*%(basename)s:*: TypeError: FinalizationRegistry: cleanup must be callable
22
let fg = new FinalizationRegistry({});
33
^
44
TypeError: FinalizationRegistry: cleanup must be callable
55
at new FinalizationRegistry (<anonymous>)
6-
at *%(basename)s:7:10
6+
at *%(basename)s:*:10

0 commit comments

Comments
 (0)