From d87a810b81f74431426699c463205c09daebc250 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 1 Dec 2023 20:00:18 +0100 Subject: [PATCH] deps: V8: cherry-pick 3dd9576ce336 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Simon Zünd Commit-Queue: Shu-yu Guo Cr-Commit-Position: refs/heads/main@{#83518} Refs: https://github.com/v8/v8/commit/3dd9576ce33683b261da944ddba460b507ca5aa1 PR-URL: https://github.com/nodejs/node/pull/51004 Reviewed-By: Chengzhong Wu --- common.gypi | 2 +- deps/v8/src/inspector/value-mirror.cc | 12 +++ ...t-preview-internal-properties-expected.txt | 82 +++++++++++++++++++ .../object-preview-internal-properties.js | 11 ++- 4 files changed, 105 insertions(+), 2 deletions(-) diff --git a/common.gypi b/common.gypi index 8f598c63aee632..960c169a789c5d 100644 --- a/common.gypi +++ b/common.gypi @@ -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 ##### diff --git a/deps/v8/src/inspector/value-mirror.cc b/deps/v8/src/inspector/value-mirror.cc index c2fa9b46cc0067..a345a8db38675e 100644 --- a/deps/v8/src/inspector/value-mirror.cc +++ b/deps/v8/src/inspector/value-mirror.cc @@ -656,6 +656,18 @@ class SymbolMirror final : public ValueMirror { .build(); } + void buildEntryPreview( + v8::Local context, int* nameLimit, int* indexLimit, + std::unique_ptr* preview) const override { + *preview = + ObjectPreview::create() + .setType(RemoteObject::TypeEnum::Symbol) + .setDescription(descriptionForSymbol(context, m_symbol)) + .setOverflow(false) + .setProperties(std::make_unique>()) + .build(); + } + v8::Local v8Value() const override { return m_symbol; } protocol::Response buildWebDriverValue( diff --git a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt index 56f992237a2ebd..1bdef8231b2523 100644 --- a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt @@ -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]]: diff --git a/deps/v8/test/inspector/debugger/object-preview-internal-properties.js b/deps/v8/test/inspector/debugger/object-preview-internal-properties.js index f542683aa49159..d2b3a7816339e9 100644 --- a/deps/v8/test/inspector/debugger/object-preview-internal-properties.js +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties.js @@ -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."); @@ -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()")