Skip to content

Commit 58c7034

Browse files
joyeecheungrichardlau
authored andcommitted
deps: V8: cherry-pick 705e374124ae
Original commit message: [symbol-as-weakmap-key] Ship the proposal I2S with 3 LGTMs: https://groups.google.com/a/chromium.org/g/blink-dev/c/E6pDZP_TiBA/m/ZcXLwiz8AAAJ Bug: v8:12947 Change-Id: Ibce4abc8b0610afb2041d44cc9ed136db8b62c0d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4004610 Commit-Queue: Shu-yu Guo <[email protected]> Reviewed-by: Camillo Bruni <[email protected]> Cr-Commit-Position: refs/heads/main@{#84128} Refs: v8/v8@705e374 PR-URL: #51004 Reviewed-By: Chengzhong Wu <[email protected]>
1 parent b0e8889 commit 58c7034

18 files changed

+13
-43
lines changed

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.34',
39+
'v8_embedder_string': '-node.35',
4040

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

deps/v8/src/builtins/builtins-collections-gen.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ TNode<IntPtrT> BaseCollectionsAssembler::EstimatedInitialSize(
399399
[=] { return IntPtrConstant(0); });
400400
}
401401

402+
// https://tc39.es/ecma262/#sec-canbeheldweakly
402403
void BaseCollectionsAssembler::GotoIfCannotBeHeldWeakly(
403404
const TNode<Object> obj, Label* if_cannot_be_held_weakly) {
404405
Label check_symbol_key(this);
@@ -411,7 +412,6 @@ void BaseCollectionsAssembler::GotoIfCannotBeHeldWeakly(
411412
GotoIf(IsJSSharedStructInstanceType(instance_type), if_cannot_be_held_weakly);
412413
Goto(&end);
413414
Bind(&check_symbol_key);
414-
GotoIfNot(HasHarmonySymbolAsWeakmapKeyFlag(), if_cannot_be_held_weakly);
415415
GotoIfNot(IsSymbolInstanceType(instance_type), if_cannot_be_held_weakly);
416416
TNode<Uint32T> flags = LoadSymbolFlags(CAST(obj));
417417
GotoIf(Word32And(flags, Symbol::IsInPublicSymbolTableBit::kMask),

deps/v8/src/builtins/builtins-weak-refs.cc

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,19 @@
99
namespace v8 {
1010
namespace internal {
1111

12-
// https://tc39.es/proposal-symbols-as-weakmap-keys/#sec-finalization-registry.prototype.unregister
12+
// https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
1313
BUILTIN(FinalizationRegistryUnregister) {
1414
HandleScope scope(isolate);
1515
const char* method_name = "FinalizationRegistry.prototype.unregister";
1616

1717
// 1. Let finalizationGroup be the this value.
1818
//
19-
// 2. If Type(finalizationGroup) is not Object, throw a TypeError
20-
// exception.
21-
//
22-
// 3. If finalizationGroup does not have a [[Cells]] internal slot,
23-
// throw a TypeError exception.
19+
// 2. Perform ? RequireInternalSlot(finalizationRegistry, [[Cells]]).
2420
CHECK_RECEIVER(JSFinalizationRegistry, finalization_registry, method_name);
2521

2622
Handle<Object> unregister_token = args.atOrUndefined(isolate, 1);
2723

28-
// 4. If CanBeHeldWeakly(unregisterToken) is false, throw a TypeError
24+
// 3. If CanBeHeldWeakly(unregisterToken) is false, throw a TypeError
2925
// exception.
3026
if (!unregister_token->CanBeHeldWeakly()) {
3127
THROW_NEW_ERROR_RETURN_FAILURE(

deps/v8/src/builtins/finalization-registry.tq

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ FinalizationRegistryConstructor(
129129
return finalizationRegistry;
130130
}
131131

132-
// https://tc39.es/proposal-symbols-as-weakmap-keys/#sec-finalization-registry.prototype.register
132+
// https://tc39.es/ecma262/#sec-finalization-registry.prototype.register
133133
transitioning javascript builtin
134134
FinalizationRegistryRegister(
135135
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {

deps/v8/src/builtins/weak-ref.tq

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern runtime JSWeakRefAddToKeptObjects(implicit context: Context)(
1313

1414
namespace weakref {
1515

16-
// https://tc39.es/proposal-symbols-as-weakmap-keys/#sec-weak-ref-target
16+
// https://tc39.es/ecma262/#sec-weak-ref-target
1717
transitioning javascript builtin
1818
WeakRefConstructor(
1919
js-implicit context: NativeContext, receiver: JSAny, newTarget: JSAny,

deps/v8/src/codegen/code-stub-assembler.h

-6
Original file line numberDiff line numberDiff line change
@@ -2679,12 +2679,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
26792679
ExternalReference::address_of_shared_string_table_flag());
26802680
}
26812681

2682-
TNode<BoolT> HasHarmonySymbolAsWeakmapKeyFlag() {
2683-
return LoadRuntimeFlag(
2684-
ExternalReference::
2685-
address_of_FLAG_harmony_symbol_as_weakmap_key());
2686-
}
2687-
26882682
// True iff |object| is a Smi or a HeapNumber or a BigInt.
26892683
TNode<BoolT> IsNumeric(TNode<Object> object);
26902684

deps/v8/src/codegen/external-reference.cc

-5
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,6 @@ ExternalReference::address_of_mock_arraybuffer_allocator_flag() {
550550
return ExternalReference(&FLAG_mock_arraybuffer_allocator);
551551
}
552552

553-
ExternalReference
554-
ExternalReference::address_of_FLAG_harmony_symbol_as_weakmap_key() {
555-
return ExternalReference(&FLAG_harmony_symbol_as_weakmap_key);
556-
}
557-
558553
ExternalReference ExternalReference::address_of_builtin_subclassing_flag() {
559554
return ExternalReference(&FLAG_builtin_subclassing);
560555
}

deps/v8/src/codegen/external-reference.h

-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ class StatsCounter;
9292

9393
#define EXTERNAL_REFERENCE_LIST(V) \
9494
V(abort_with_reason, "abort_with_reason") \
95-
V(address_of_FLAG_harmony_symbol_as_weakmap_key, \
96-
"FLAG_harmony_symbol_as_weakmap_key") \
9795
V(address_of_builtin_subclassing_flag, "FLAG_builtin_subclassing") \
9896
V(address_of_double_abs_constant, "double_absolute_constant") \
9997
V(address_of_double_neg_constant, "double_negate_constant") \

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features")
319319

320320
// Features that are complete (but still behind the --harmony flag).
321321
#define HARMONY_STAGED_BASE(V) \
322-
V(harmony_array_grouping, "harmony array grouping") \
323-
V(harmony_symbol_as_weakmap_key, "harmony symbols as weakmap keys")
322+
V(harmony_array_grouping, "harmony array grouping")
324323

325324
#ifdef V8_INTL_SUPPORT
326325
#define HARMONY_STAGED(V) \

deps/v8/src/init/bootstrapper.cc

-1
Original file line numberDiff line numberDiff line change
@@ -4484,7 +4484,6 @@ void Genesis::InitializeConsole(Handle<JSObject> extras_binding) {
44844484
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_import_assertions)
44854485
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_private_brand_checks)
44864486
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_class_static_blocks)
4487-
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_symbol_as_weakmap_key)
44884487
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_error_cause)
44894488

44904489
#ifdef V8_INTL_SUPPORT

deps/v8/src/objects/objects-inl.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ MaybeHandle<Object> Object::Share(Isolate* isolate, Handle<Object> value,
12061206
throw_if_cannot_be_shared);
12071207
}
12081208

1209-
// https://tc39.es/proposal-symbols-as-weakmap-keys/#sec-canbeheldweakly-abstract-operation
1209+
// https://tc39.es/ecma262/#sec-canbeheldweakly
12101210
bool Object::CanBeHeldWeakly() const {
12111211
if (IsJSReceiver()) {
12121212
// TODO(v8:12547) Shared structs and arrays should only be able to point
@@ -1217,10 +1217,7 @@ bool Object::CanBeHeldWeakly() const {
12171217
}
12181218
return true;
12191219
}
1220-
if (FLAG_harmony_symbol_as_weakmap_key) {
1221-
return IsSymbol() && !Symbol::cast(*this).is_in_public_symbol_table();
1222-
}
1223-
return false;
1220+
return IsSymbol() && !Symbol::cast(*this).is_in_public_symbol_table();
12241221
}
12251222

12261223
Handle<Object> ObjectHashTableShape::AsHandle(Handle<Object> key) {

deps/v8/test/inspector/debugger/object-preview-internal-properties.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2016 the V8 project authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
//
5-
// Flags: --harmony-symbol-as-weakmap-key
64

75
let {session, contextGroup, Protocol} = InspectorTest.start("Check internal properties reported in object preview.");
86

deps/v8/test/mjsunit/es6/collections.js

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ function TestInvalidCalls(m) {
7777
assertThrows(function () { m.set(null, 0) }, TypeError);
7878
assertThrows(function () { m.set(0, 0) }, TypeError);
7979
assertThrows(function () { m.set('a-key', 0) }, TypeError);
80-
assertThrows(function () { m.set(Symbol(), 0) }, TypeError);
8180
}
8281
TestInvalidCalls(new WeakMap);
8382

deps/v8/test/mjsunit/harmony/regress/regress-crbug-1372500.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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-symbol-as-weakmap-key --expose-gc
5+
// Flags: --expose-gc
66

77
// Register an object in a FinalizationRegistry with a Symbol as the unregister
88
// token.

deps/v8/test/mjsunit/harmony/symbol-as-weakmap-key.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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-symbol-as-weakmap-key --expose-gc --allow-natives-syntax --noincremental-marking
5+
// Flags: --expose-gc --allow-natives-syntax --noincremental-marking
66

77
(function TestWeakMapWithNonRegisteredSymbolKey() {
88
const key = Symbol('123');

deps/v8/test/mjsunit/harmony/weakrefs/basics.js

-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
assertThrows(() => fg.register(1, "holdings"), TypeError, message);
5252
assertThrows(() => fg.register(false, "holdings"), TypeError, message);
5353
assertThrows(() => fg.register("foo", "holdings"), TypeError, message);
54-
assertThrows(() => fg.register(Symbol(), "holdings"), TypeError, message);
5554
assertThrows(() => fg.register(null, "holdings"), TypeError, message);
5655
assertThrows(() => fg.register(undefined, "holdings"), TypeError, message);
5756
})();
@@ -97,7 +96,6 @@
9796
assertThrows(() => fg.unregister(1), TypeError);
9897
assertThrows(() => fg.unregister(1n), TypeError);
9998
assertThrows(() => fg.unregister('one'), TypeError);
100-
assertThrows(() => fg.unregister(Symbol()), TypeError);
10199
assertThrows(() => fg.unregister(true), TypeError);
102100
assertThrows(() => fg.unregister(false), TypeError);
103101
assertThrows(() => fg.unregister(undefined), TypeError);
@@ -121,7 +119,6 @@
121119
assertThrows(() => new WeakRef(1), TypeError, message);
122120
assertThrows(() => new WeakRef(false), TypeError, message);
123121
assertThrows(() => new WeakRef("foo"), TypeError, message);
124-
assertThrows(() => new WeakRef(Symbol()), TypeError, message);
125122
assertThrows(() => new WeakRef(null), TypeError, message);
126123
assertThrows(() => new WeakRef(undefined), TypeError, message);
127124
})();

deps/v8/test/mjsunit/harmony/weakrefs/symbol-as-weakref-target-gc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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-symbol-as-weakmap-key --expose-gc --noincremental-marking
5+
// Flags: --expose-gc --noincremental-marking
66

77
(function TestWeakRefWithSymbolGC() {
88
let weakRef;

deps/v8/test/mjsunit/harmony/weakrefs/symbol-as-weakref-target.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
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-symbol-as-weakmap-key
6-
75
(function TestRegisterWithSymbolTarget() {
86
const fg = new FinalizationRegistry(() => { });
97
fg.register(Symbol('123'), 'holdings');

0 commit comments

Comments
 (0)