Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7197fce

Browse filesBrowse files
committed
deps: V8: cherry-pick 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 <syg@chromium.org> Reviewed-by: Shu-yu Guo <syg@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#73871} Refs: v8/v8@d59db06 PR-URL: #38273 Backport-PR-URL: #38991 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Mary Marchini <oss@mmarchini.me>
1 parent bf7aa9f commit 7197fce
Copy full SHA for 7197fce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

47 files changed

+104
-161
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
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.7',
39+
'v8_embedder_string': '-node.8',
4040

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

Collapse file

‎deps/v8/src/flags/flag-definitions.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/flags/flag-definitions.h
-3Lines 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

@@ -298,7 +296,6 @@ DEFINE_IMPLICATION(harmony_weak_refs_with_cleanup_some, harmony_weak_refs)
298296
#define HARMONY_SHIPPING_BASE(V) \
299297
V(harmony_sharedarraybuffer, "harmony sharedarraybuffer") \
300298
V(harmony_atomics, "harmony atomics") \
301-
V(harmony_weak_refs, "harmony weak references") \
302299
V(harmony_regexp_match_indices, "harmony regexp match indices") \
303300
V(harmony_private_brand_checks, "harmony private brand checks") \
304301
V(harmony_top_level_await, "harmony top level await")
Collapse file

‎deps/v8/src/heap/heap.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/heap/heap.cc
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6284,8 +6284,6 @@ MaybeHandle<JSFinalizationRegistry> Heap::DequeueDirtyJSFinalizationRegistry() {
62846284
}
62856285

62866286
void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
6287-
if (!FLAG_harmony_weak_refs) return;
6288-
62896287
DisallowGarbageCollection no_gc;
62906288

62916289
Isolate* isolate = this->isolate();
@@ -6315,7 +6313,6 @@ void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
63156313
}
63166314

63176315
void Heap::KeepDuringJob(Handle<JSReceiver> target) {
6318-
DCHECK(FLAG_harmony_weak_refs);
63196316
DCHECK(weak_refs_keep_during_job().IsUndefined() ||
63206317
weak_refs_keep_during_job().IsOrderedHashSet());
63216318
Handle<OrderedHashSet> table;
Collapse file

‎deps/v8/src/heap/mark-compact.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/heap/mark-compact.cc
-3Lines 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());
Collapse file

‎deps/v8/src/heap/weak-object-worklists.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/heap/weak-object-worklists.cc
+11-13Lines 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) {
Collapse file

‎deps/v8/src/init/bootstrapper.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/init/bootstrapper.cc
+55-67Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,6 +3862,61 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
38623862
native_context()->set_bound_function_with_constructor_map(*map);
38633863
}
38643864

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

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

44264414
Handle<JSFunction> finalization_registry_fun =
44274415
isolate()->js_finalization_registry_fun();
Collapse file

‎deps/v8/test/cctest/test-js-weak-refs.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-js-weak-refs.cc
-19Lines 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
Collapse file

‎deps/v8/test/message/fail/weak-refs-finalizationregistry1.js‎

Copy file name to clipboardExpand all lines: deps/v8/test/message/fail/weak-refs-finalizationregistry1.js
-2Lines 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();
Collapse file
+2-2Lines 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
Collapse file

‎deps/v8/test/message/fail/weak-refs-finalizationregistry2.js‎

Copy file name to clipboardExpand all lines: deps/v8/test/message/fail/weak-refs-finalizationregistry2.js
-2Lines 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({});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.