Skip to content

Commit 2468e4e

Browse files
aduh95jasnell
authored andcommitted
deps: V8: backport d59db06bf542
Original commit message: [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} Refs: v8/v8@d59db06 PR-URL: #38162 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 3da003c commit 2468e4e

Some content is hidden

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

47 files changed

+104
-161
lines changed

Diff for: common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.9',
39+
'v8_embedder_string': '-node.10',
4040

4141
##### V8 defaults for Node.js #####
4242

Diff for: deps/v8/src/flags/flag-definitions.h

-3
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ DEFINE_BOOL(use_strict, false, "enforce strict mode")
246246

247247
DEFINE_BOOL(harmony, false, "enable all completed harmony features")
248248
DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features")
249-
// Enabling FinalizationRegistry#cleanupSome also enables weak refs
250-
DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs)
251249

252250
// Update bootstrapper.cc whenever adding a new feature flag.
253251

@@ -286,7 +284,6 @@ DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs)
286284
#define HARMONY_SHIPPING_BASE(V) \
287285
V(harmony_sharedarraybuffer, "harmony sharedarraybuffer") \
288286
V(harmony_atomics, "harmony atomics") \
289-
V(harmony_weak_refs, "harmony weak references") \
290287
V(harmony_string_replaceall, "harmony String.prototype.replaceAll") \
291288
V(harmony_logical_assignment, "harmony logical assignment") \
292289
V(harmony_atomics_waitasync, "harmony Atomics.waitAsync") \

Diff for: deps/v8/src/heap/heap.cc

-3
Original file line numberDiff line numberDiff line change
@@ -6228,8 +6228,6 @@ MaybeHandle<JSFinalizationRegistry> Heap::DequeueDirtyJSFinalizationRegistry() {
62286228
}
62296229

62306230
void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
6231-
if (!FLAG_harmony_weak_refs) return;
6232-
62336231
DisallowGarbageCollection no_gc;
62346232

62356233
Isolate* isolate = this->isolate();
@@ -6259,7 +6257,6 @@ void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
62596257
}
62606258

62616259
void Heap::KeepDuringJob(Handle<JSReceiver> target) {
6262-
DCHECK(FLAG_harmony_weak_refs);
62636260
DCHECK(weak_refs_keep_during_job().IsUndefined() ||
62646261
weak_refs_keep_during_job().IsOrderedHashSet());
62656262
Handle<OrderedHashSet> table;

Diff for: deps/v8/src/heap/mark-compact.cc

-3
Original file line numberDiff line numberDiff line change
@@ -2480,9 +2480,6 @@ void MarkCompactCollector::ClearWeakReferences() {
24802480
}
24812481

24822482
void MarkCompactCollector::ClearJSWeakRefs() {
2483-
if (!FLAG_harmony_weak_refs) {
2484-
return;
2485-
}
24862483
JSWeakRef weak_ref;
24872484
while (weak_objects_.js_weak_refs.Pop(kMainThreadTask, &weak_ref)) {
24882485
HeapObject target = HeapObject::cast(weak_ref.target());

Diff for: deps/v8/src/heap/weak-object-worklists.cc

+11-13
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) {

Diff for: deps/v8/src/init/bootstrapper.cc

+55-67
Original file line numberDiff line numberDiff line change
@@ -3854,6 +3854,61 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
38543854
native_context()->set_bound_function_with_constructor_map(*map);
38553855
}
38563856

3857+
{ // -- F i n a l i z a t i o n R e g i s t r y
3858+
Handle<JSFunction> finalization_registry_fun = InstallFunction(
3859+
isolate_, global, factory->FinalizationRegistry_string(),
3860+
JS_FINALIZATION_REGISTRY_TYPE, JSFinalizationRegistry::kHeaderSize, 0,
3861+
factory->the_hole_value(), Builtins::kFinalizationRegistryConstructor);
3862+
InstallWithIntrinsicDefaultProto(
3863+
isolate_, finalization_registry_fun,
3864+
Context::JS_FINALIZATION_REGISTRY_FUNCTION_INDEX);
3865+
3866+
finalization_registry_fun->shared().DontAdaptArguments();
3867+
finalization_registry_fun->shared().set_length(1);
3868+
3869+
Handle<JSObject> finalization_registry_prototype(
3870+
JSObject::cast(finalization_registry_fun->instance_prototype()),
3871+
isolate());
3872+
3873+
InstallToStringTag(isolate_, finalization_registry_prototype,
3874+
factory->FinalizationRegistry_string());
3875+
3876+
SimpleInstallFunction(isolate_, finalization_registry_prototype, "register",
3877+
Builtins::kFinalizationRegistryRegister, 2, false);
3878+
3879+
SimpleInstallFunction(isolate_, finalization_registry_prototype,
3880+
"unregister",
3881+
Builtins::kFinalizationRegistryUnregister, 1, false);
3882+
3883+
// The cleanupSome function is created but not exposed, as it is used
3884+
// internally by InvokeFinalizationRegistryCleanupFromTask.
3885+
//
3886+
// It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
3887+
Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction(
3888+
isolate_, factory->InternalizeUtf8String("cleanupSome"),
3889+
Builtins::kFinalizationRegistryPrototypeCleanupSome, 0, false);
3890+
native_context()->set_finalization_registry_cleanup_some(*cleanup_some_fun);
3891+
}
3892+
3893+
{ // -- W e a k R e f
3894+
Handle<JSFunction> weak_ref_fun = InstallFunction(
3895+
isolate_, global, "WeakRef", JS_WEAK_REF_TYPE, JSWeakRef::kHeaderSize,
3896+
0, factory->the_hole_value(), Builtins::kWeakRefConstructor);
3897+
InstallWithIntrinsicDefaultProto(isolate_, weak_ref_fun,
3898+
Context::JS_WEAK_REF_FUNCTION_INDEX);
3899+
3900+
weak_ref_fun->shared().DontAdaptArguments();
3901+
weak_ref_fun->shared().set_length(1);
3902+
3903+
Handle<JSObject> weak_ref_prototype(
3904+
JSObject::cast(weak_ref_fun->instance_prototype()), isolate());
3905+
3906+
InstallToStringTag(isolate_, weak_ref_prototype, factory->WeakRef_string());
3907+
3908+
SimpleInstallFunction(isolate_, weak_ref_prototype, "deref",
3909+
Builtins::kWeakRefDeref, 0, true);
3910+
}
3911+
38573912
{ // --- sloppy arguments map
38583913
Handle<String> arguments_string = factory->Arguments_string();
38593914
Handle<JSFunction> function = CreateFunctionForBuiltinWithPrototype(
@@ -4351,75 +4406,8 @@ void Genesis::InitializeGlobal_harmony_atomics() {
43514406
InstallToStringTag(isolate_, isolate()->atomics_object(), "Atomics");
43524407
}
43534408

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

44244412
Handle<JSFunction> finalization_registry_fun =
44254413
isolate()->js_finalization_registry_fun();

Diff for: deps/v8/test/cctest/test-js-weak-refs.cc

-19
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

Diff for: deps/v8/test/message/fail/weak-refs-finalizationregistry1.js

-2
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();
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

Diff for: deps/v8/test/message/fail/weak-refs-finalizationregistry2.js

-2
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({});

0 commit comments

Comments
 (0)