GeezerVison is showing github.com — deps: V8: cherry-pick 94e8282325a1 · nodejs/node@6d50966
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: common.gypi +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 36 | 36 |
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | 39 | | - 'v8_embedder_string': '-node.31', | | 39 | + 'v8_embedder_string': '-node.32', | 40 | 40 |
| 41 | 41 | ##### V8 defaults for Node.js ##### | 42 | 42 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/builtins/builtins-collections-gen.cc +19-19Lines changed: 19 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -399,23 +399,23 @@ TNode<IntPtrT> BaseCollectionsAssembler::EstimatedInitialSize( | 399 | 399 | [=] { return IntPtrConstant(0); }); | 400 | 400 | } | 401 | 401 |
| 402 | | -void BaseCollectionsAssembler::GotoIfCannotBeWeakKey( | 403 | | - const TNode<Object> obj, Label* if_cannot_be_weak_key) { | | 402 | +void BaseCollectionsAssembler::GotoIfCannotBeHeldWeakly( | | 403 | + const TNode<Object> obj, Label* if_cannot_be_held_weakly) { | 404 | 404 | Label check_symbol_key(this); | 405 | 405 | Label end(this); | 406 | | - GotoIf(TaggedIsSmi(obj), if_cannot_be_weak_key); | | 406 | + GotoIf(TaggedIsSmi(obj), if_cannot_be_held_weakly); | 407 | 407 | TNode<Uint16T> instance_type = LoadMapInstanceType(LoadMap(CAST(obj))); | 408 | 408 | GotoIfNot(IsJSReceiverInstanceType(instance_type), &check_symbol_key); | 409 | 409 | // TODO(v8:12547) Shared structs should only be able to point to shared values | 410 | 410 | // in weak collections. For now, disallow them as weak collection keys. | 411 | | - GotoIf(IsJSSharedStructInstanceType(instance_type), if_cannot_be_weak_key); | | 411 | + GotoIf(IsJSSharedStructInstanceType(instance_type), if_cannot_be_held_weakly); | 412 | 412 | Goto(&end); | 413 | 413 | Bind(&check_symbol_key); | 414 | | - GotoIfNot(HasHarmonySymbolAsWeakmapKeyFlag(), if_cannot_be_weak_key); | 415 | | - GotoIfNot(IsSymbolInstanceType(instance_type), if_cannot_be_weak_key); | | 414 | + GotoIfNot(HasHarmonySymbolAsWeakmapKeyFlag(), if_cannot_be_held_weakly); | | 415 | + GotoIfNot(IsSymbolInstanceType(instance_type), if_cannot_be_held_weakly); | 416 | 416 | TNode<Uint32T> flags = LoadSymbolFlags(CAST(obj)); | 417 | 417 | GotoIf(Word32And(flags, Symbol::IsInPublicSymbolTableBit::kMask), | 418 | | - if_cannot_be_weak_key); | | 418 | + if_cannot_be_held_weakly); | 419 | 419 | Goto(&end); | 420 | 420 | Bind(&end); | 421 | 421 | } | @@ -2573,17 +2573,17 @@ TF_BUILTIN(WeakMapLookupHashIndex, WeakCollectionsBuiltinsAssembler) { | 2573 | 2573 | auto table = Parameter<EphemeronHashTable>(Descriptor::kTable); | 2574 | 2574 | auto key = Parameter<Object>(Descriptor::kKey); | 2575 | 2575 |
| 2576 | | - Label if_cannot_be_weak_key(this); | | 2576 | + Label if_cannot_be_held_weakly(this); | 2577 | 2577 |
| 2578 | | - GotoIfCannotBeWeakKey(key, &if_cannot_be_weak_key); | | 2578 | + GotoIfCannotBeHeldWeakly(key, &if_cannot_be_held_weakly); | 2579 | 2579 |
| 2580 | | - TNode<IntPtrT> hash = GetHash(CAST(key), &if_cannot_be_weak_key); | | 2580 | + TNode<IntPtrT> hash = GetHash(CAST(key), &if_cannot_be_held_weakly); | 2581 | 2581 | TNode<IntPtrT> capacity = LoadTableCapacity(table); | 2582 | 2582 | TNode<IntPtrT> key_index = FindKeyIndexForKey( | 2583 | | - table, key, hash, EntryMask(capacity), &if_cannot_be_weak_key); | | 2583 | + table, key, hash, EntryMask(capacity), &if_cannot_be_held_weakly); | 2584 | 2584 | Return(SmiTag(ValueIndexFromKeyIndex(key_index))); | 2585 | 2585 |
| 2586 | | - BIND(&if_cannot_be_weak_key); | | 2586 | + BIND(&if_cannot_be_held_weakly); | 2587 | 2587 | Return(SmiConstant(-1)); | 2588 | 2588 | } | 2589 | 2589 |
| @@ -2638,22 +2638,22 @@ TF_BUILTIN(WeakCollectionDelete, WeakCollectionsBuiltinsAssembler) { | 2638 | 2638 | auto collection = Parameter<JSWeakCollection>(Descriptor::kCollection); | 2639 | 2639 | auto key = Parameter<Object>(Descriptor::kKey); | 2640 | 2640 |
| 2641 | | - Label call_runtime(this), if_cannot_be_weak_key(this); | | 2641 | + Label call_runtime(this), if_cannot_be_held_weakly(this); | 2642 | 2642 |
| 2643 | | - GotoIfCannotBeWeakKey(key, &if_cannot_be_weak_key); | | 2643 | + GotoIfCannotBeHeldWeakly(key, &if_cannot_be_held_weakly); | 2644 | 2644 |
| 2645 | | - TNode<IntPtrT> hash = GetHash(CAST(key), &if_cannot_be_weak_key); | | 2645 | + TNode<IntPtrT> hash = GetHash(CAST(key), &if_cannot_be_held_weakly); | 2646 | 2646 | TNode<EphemeronHashTable> table = LoadTable(collection); | 2647 | 2647 | TNode<IntPtrT> capacity = LoadTableCapacity(table); | 2648 | 2648 | TNode<IntPtrT> key_index = FindKeyIndexForKey( | 2649 | | - table, key, hash, EntryMask(capacity), &if_cannot_be_weak_key); | | 2649 | + table, key, hash, EntryMask(capacity), &if_cannot_be_held_weakly); | 2650 | 2650 | TNode<IntPtrT> number_of_elements = LoadNumberOfElements(table, -1); | 2651 | 2651 | GotoIf(ShouldShrink(capacity, number_of_elements), &call_runtime); | 2652 | 2652 |
| 2653 | 2653 | RemoveEntry(table, key_index, number_of_elements); | 2654 | 2654 | Return(TrueConstant()); | 2655 | 2655 |
| 2656 | | - BIND(&if_cannot_be_weak_key); | | 2656 | + BIND(&if_cannot_be_held_weakly); | 2657 | 2657 | Return(FalseConstant()); | 2658 | 2658 |
| 2659 | 2659 | BIND(&call_runtime); | @@ -2735,7 +2735,7 @@ TF_BUILTIN(WeakMapPrototypeSet, WeakCollectionsBuiltinsAssembler) { | 2735 | 2735 | "WeakMap.prototype.set"); | 2736 | 2736 |
| 2737 | 2737 | Label throw_invalid_key(this); | 2738 | | - GotoIfCannotBeWeakKey(key, &throw_invalid_key); | | 2738 | + GotoIfCannotBeHeldWeakly(key, &throw_invalid_key); | 2739 | 2739 |
| 2740 | 2740 | Return( | 2741 | 2741 | CallBuiltin(Builtin::kWeakCollectionSet, context, receiver, key, value)); | @@ -2753,7 +2753,7 @@ TF_BUILTIN(WeakSetPrototypeAdd, WeakCollectionsBuiltinsAssembler) { | 2753 | 2753 | "WeakSet.prototype.add"); | 2754 | 2754 |
| 2755 | 2755 | Label throw_invalid_value(this); | 2756 | | - GotoIfCannotBeWeakKey(value, &throw_invalid_value); | | 2756 | + GotoIfCannotBeHeldWeakly(value, &throw_invalid_value); | 2757 | 2757 |
| 2758 | 2758 | Return(CallBuiltin(Builtin::kWeakCollectionSet, context, receiver, value, | 2759 | 2759 | TrueConstant())); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/builtins/builtins-collections-gen.h +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,8 +27,8 @@ class BaseCollectionsAssembler : public CodeStubAssembler { | 27 | 27 |
| 28 | 28 | virtual ~BaseCollectionsAssembler() = default; | 29 | 29 |
| 30 | | - void GotoIfCannotBeWeakKey(const TNode<Object> obj, | 31 | | - Label* if_cannot_be_weak_key); | | 30 | + void GotoIfCannotBeHeldWeakly(const TNode<Object> obj, | | 31 | + Label* if_cannot_be_held_weakly); | 32 | 32 |
| 33 | 33 | protected: | 34 | 34 | enum Variant { kMap, kSet, kWeakMap, kWeakSet }; | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/builtins/builtins-weak-refs.cc +4-17Lines changed: 4 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,23 +27,10 @@ BUILTIN(FinalizationRegistryUnregister) { | 27 | 27 |
| 28 | 28 | // 4. If CanBeHeldWeakly(unregisterToken) is false, throw a TypeError | 29 | 29 | // exception. | 30 | | - if (FLAG_harmony_symbol_as_weakmap_key) { | 31 | | - if (!unregister_token->IsJSReceiver() && | 32 | | - (!unregister_token->IsSymbol() || | 33 | | - Handle<Symbol>::cast(unregister_token)->is_in_public_symbol_table())) { | 34 | | - THROW_NEW_ERROR_RETURN_FAILURE( | 35 | | - isolate, | 36 | | - NewTypeError(MessageTemplate::kInvalidWeakRefsUnregisterToken, | 37 | | - unregister_token)); | 38 | | - } | 39 | | - } else { | 40 | | - // 4. If Type(unregisterToken) is not Object, throw a TypeError exception. | 41 | | - if (!unregister_token->IsJSReceiver()) { | 42 | | - THROW_NEW_ERROR_RETURN_FAILURE( | 43 | | - isolate, | 44 | | - NewTypeError(MessageTemplate::kInvalidWeakRefsUnregisterToken, | 45 | | - unregister_token)); | 46 | | - } | | 30 | + if (!unregister_token->CanBeHeldWeakly()) { | | 31 | + THROW_NEW_ERROR_RETURN_FAILURE( | | 32 | + isolate, NewTypeError(MessageTemplate::kInvalidWeakRefsUnregisterToken, | | 33 | + unregister_token)); | 47 | 34 | } | 48 | 35 |
| 49 | 36 | bool success = JSFinalizationRegistry::Unregister( | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/builtins/finalization-registry.tq +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,7 +16,7 @@ extern transitioning macro | 16 | 16 | RemoveFinalizationRegistryCellFromUnregisterTokenMap( | 17 | 17 | JSFinalizationRegistry, WeakCell): void; | 18 | 18 |
| 19 | | -extern macro WeakCollectionsBuiltinsAssembler::GotoIfCannotBeWeakKey(JSAny): | | 19 | +extern macro WeakCollectionsBuiltinsAssembler::GotoIfCannotBeHeldWeakly(JSAny): | 20 | 20 | void labels NotWeakKey; | 21 | 21 |
| 22 | 22 | macro SplitOffTail(weakCell: WeakCell): WeakCell|Undefined { | @@ -140,7 +140,7 @@ FinalizationRegistryRegister( | 140 | 140 | MessageTemplate::kIncompatibleMethodReceiver, | 141 | 141 | 'FinalizationRegistry.prototype.register', receiver); | 142 | 142 | // 3. If CanBeHeldWeakly(target) is false, throw a TypeError exception. | 143 | | - GotoIfCannotBeWeakKey(arguments[0]) | | 143 | + GotoIfCannotBeHeldWeakly(arguments[0]) | 144 | 144 | otherwise ThrowTypeError(MessageTemplate::kInvalidWeakRefsRegisterTarget); | 145 | 145 |
| 146 | 146 | const target = UnsafeCast<(JSReceiver | Symbol)>(arguments[0]); | @@ -159,7 +159,7 @@ FinalizationRegistryRegister( | 159 | 159 | if (IsUndefined(unregisterTokenRaw)) { | 160 | 160 | unregisterToken = Undefined; | 161 | 161 | } else { | 162 | | - GotoIfCannotBeWeakKey(unregisterTokenRaw) | | 162 | + GotoIfCannotBeHeldWeakly(unregisterTokenRaw) | 163 | 163 | otherwise ThrowTypeError( | 164 | 164 | MessageTemplate::kInvalidWeakRefsUnregisterToken, unregisterTokenRaw); | 165 | 165 | unregisterToken = UnsafeCast<(JSReceiver | Symbol)>(unregisterTokenRaw); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/builtins/weak-ref.tq +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,7 +24,7 @@ WeakRefConstructor( | 24 | 24 | } | 25 | 25 |
| 26 | 26 | // 2. If CanBeHeldWeakly(weakTarget) is false, throw a TypeError exception. | 27 | | - GotoIfCannotBeWeakKey(weakTarget) otherwise ThrowTypeError( | | 27 | + GotoIfCannotBeHeldWeakly(weakTarget) otherwise ThrowTypeError( | 28 | 28 | MessageTemplate::kInvalidWeakRefsWeakRefConstructorTarget); | 29 | 29 |
| 30 | 30 | // 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/diagnostics/objects-debug.cc +2-6Lines changed: 2 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1240,9 +1240,7 @@ void JSSharedStruct::JSSharedStructVerify(Isolate* isolate) { | 1240 | 1240 | void WeakCell::WeakCellVerify(Isolate* isolate) { | 1241 | 1241 | CHECK(IsWeakCell()); | 1242 | 1242 |
| 1243 | | - CHECK(target().IsJSReceiver() || target().IsUndefined(isolate) || | 1244 | | - (target().IsSymbol() && | 1245 | | - !Symbol::cast(target()).is_in_public_symbol_table())); | | 1243 | + CHECK(target().IsUndefined(isolate) || target().CanBeHeldWeakly()); | 1246 | 1244 |
| 1247 | 1245 | CHECK(prev().IsWeakCell() || prev().IsUndefined(isolate)); | 1248 | 1246 | if (prev().IsWeakCell()) { | @@ -1270,9 +1268,7 @@ void WeakCell::WeakCellVerify(Isolate* isolate) { | 1270 | 1268 | void JSWeakRef::JSWeakRefVerify(Isolate* isolate) { | 1271 | 1269 | CHECK(IsJSWeakRef()); | 1272 | 1270 | JSObjectVerify(isolate); | 1273 | | - CHECK(target().IsUndefined(isolate) || target().IsJSReceiver() || | 1274 | | - (target().IsSymbol() && | 1275 | | - !Symbol::cast(target()).is_in_public_symbol_table())); | | 1271 | + CHECK(target().IsUndefined(isolate) || target().CanBeHeldWeakly()); | 1276 | 1272 | } | 1277 | 1273 |
| 1278 | 1274 | void JSFinalizationRegistry::JSFinalizationRegistryVerify(Isolate* isolate) { | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/objects/js-weak-refs-inl.h +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -170,9 +170,7 @@ void WeakCell::Nullify(Isolate* isolate, | 170 | 170 | // only called for WeakCells which haven't been unregistered yet, so they will | 171 | 171 | // be in the active_cells list. (The caller must guard against calling this | 172 | 172 | // for unregistered WeakCells by checking that the target is not undefined.) | 173 | | - DCHECK(target().IsJSReceiver() || | 174 | | - (target().IsSymbol() && | 175 | | - !Symbol::cast(target()).is_in_public_symbol_table())); | | 173 | + DCHECK(target().CanBeHeldWeakly()); | 176 | 174 | set_target(ReadOnlyRoots(isolate).undefined_value()); | 177 | 175 |
| 178 | 176 | JSFinalizationRegistry fr = | @@ -218,7 +216,7 @@ void WeakCell::RemoveFromFinalizationRegistryCells(Isolate* isolate) { | 218 | 216 |
| 219 | 217 | // It's important to set_target to undefined here. This guards that we won't | 220 | 218 | // call Nullify (which assumes that the WeakCell is in active_cells). | 221 | | - DCHECK(target().IsUndefined() || target().IsJSReceiver()); | | 219 | + DCHECK(target().IsUndefined() || target().CanBeHeldWeakly()); | 222 | 220 | set_target(ReadOnlyRoots(isolate).undefined_value()); | 223 | 221 |
| 224 | 222 | JSFinalizationRegistry fr = | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/objects/objects-inl.h +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1206,6 +1206,23 @@ MaybeHandle<Object> Object::Share(Isolate* isolate, Handle<Object> value, | 1206 | 1206 | throw_if_cannot_be_shared); | 1207 | 1207 | } | 1208 | 1208 |
| | 1209 | +// https://tc39.es/proposal-symbols-as-weakmap-keys/#sec-canbeheldweakly-abstract-operation | | 1210 | +bool Object::CanBeHeldWeakly() const { | | 1211 | + if (IsJSReceiver()) { | | 1212 | + // TODO(v8:12547) Shared structs and arrays should only be able to point | | 1213 | + // to shared values in weak collections. For now, disallow them as weak | | 1214 | + // collection keys. | | 1215 | + if (FLAG_harmony_struct) { | | 1216 | + return !IsJSSharedStruct(); | | 1217 | + } | | 1218 | + return true; | | 1219 | + } | | 1220 | + if (FLAG_harmony_symbol_as_weakmap_key) { | | 1221 | + return IsSymbol() && !Symbol::cast(*this).is_in_public_symbol_table(); | | 1222 | + } | | 1223 | + return false; | | 1224 | +} | | 1225 | + | 1209 | 1226 | Handle<Object> ObjectHashTableShape::AsHandle(Handle<Object> key) { | 1210 | 1227 | return key; | 1211 | 1228 | } | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/objects/objects.h +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -770,6 +770,11 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> { | 770 | 770 | Handle<HeapObject> value, | 771 | 771 | ShouldThrow throw_if_cannot_be_shared); | 772 | 772 |
| | 773 | + // Whether this Object can be held weakly, i.e. whether it can be used as a | | 774 | + // key in WeakMap, as a key in WeakSet, as the target of a WeakRef, or as a | | 775 | + // target or unregister token of a FinalizationRegistry. | | 776 | + inline bool CanBeHeldWeakly() const; | | 777 | + | 773 | 778 | protected: | 774 | 779 | inline Address field_address(size_t offset) const { | 775 | 780 | return ptr() + offset - kHeapObjectTag; | |
|