Skip to content

Commit

Permalink
deps: V8: cherry-pick 3dd9576ce336
Browse files Browse the repository at this point in the history
Original commit message:

    [inspector] Support Symbols in EntryPreview

    The Symbols-as-WeakMap-keys proposal allows non-Symbol.for Symbol values
    in weak collections, which means it can show in EntryPreviews.

    Also apparently Symbols in regular Maps and Sets were also unsupported.

    Bug: v8:13350, v8:12947
    Change-Id: Ib10476fa2f3c7f59af67933f0bf61640be1bbd97
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3930037
    Reviewed-by: Benedikt Meurer <[email protected]>
    Reviewed-by: Simon Zünd <[email protected]>
    Commit-Queue: Shu-yu Guo <[email protected]>
    Cr-Commit-Position: refs/heads/main@{#83518}

Refs: v8/v8@3dd9576
PR-URL: #51004
Reviewed-By: Chengzhong Wu <[email protected]>
  • Loading branch information
joyeecheung authored and richardlau committed Mar 15, 2024
1 parent 6d50966 commit d87a810
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.32',
'v8_embedder_string': '-node.33',

##### V8 defaults for Node.js #####

Expand Down
12 changes: 12 additions & 0 deletions deps/v8/src/inspector/value-mirror.cc
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,18 @@ class SymbolMirror final : public ValueMirror {
.build();
}

void buildEntryPreview(
v8::Local<v8::Context> context, int* nameLimit, int* indexLimit,
std::unique_ptr<ObjectPreview>* preview) const override {
*preview =
ObjectPreview::create()
.setType(RemoteObject::TypeEnum::Symbol)
.setDescription(descriptionForSymbol(context, m_symbol))
.setOverflow(false)
.setProperties(std::make_unique<protocol::Array<PropertyPreview>>())
.build();
}

v8::Local<v8::Value> v8Value() const override { return m_symbol; }

protocol::Response buildWebDriverValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,88 @@ expression: new WeakSet([{}])
]


Running test: symbolsAsKeysInEntries
expression: new Map([[Symbol('key1'), 1]])
{
name : size
type : number
value : 1
}
[[Entries]]:
[
[0] : {
key : {
description : Symbol(key1)
overflow : false
properties : [
]
type : symbol
}
value : {
description : 1
overflow : false
properties : [
]
type : number
}
}
]

expression: new Set([Symbol('key2')])
{
name : size
type : number
value : 1
}
[[Entries]]:
[
[0] : {
value : {
description : Symbol(key2)
overflow : false
properties : [
]
type : symbol
}
}
]

expression: new WeakMap([[Symbol('key3'), 2]])
[[Entries]]:
[
[0] : {
key : {
description : Symbol(key3)
overflow : false
properties : [
]
type : symbol
}
value : {
description : 2
overflow : false
properties : [
]
type : number
}
}
]

expression: new WeakSet([Symbol('key4')])
[[Entries]]:
[
[0] : {
value : {
description : Symbol(key4)
overflow : false
properties : [
]
type : symbol
}
}
]


Running test: iteratorObject
expression: (new Map([[1,2]])).entries()
[[Entries]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --harmony-class-fields
// Flags: --harmony-symbol-as-weakmap-key

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

Expand Down Expand Up @@ -45,6 +45,15 @@ InspectorTest.runTestSuite([
.then(next);
},

function symbolsAsKeysInEntries(next)
{
checkExpression("new Map([[Symbol('key1'), 1]])")
.then(() => checkExpression("new Set([Symbol('key2')])"))
.then(() => checkExpression("new WeakMap([[Symbol('key3'), 2]])"))
.then(() => checkExpression("new WeakSet([Symbol('key4')])"))
.then(next);
},

function iteratorObject(next)
{
checkExpression("(new Map([[1,2]])).entries()")
Expand Down

0 comments on commit d87a810

Please sign in to comment.