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 fb26861

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
deps: cherry-pick ff0a9793334 from upstream V8
Original commit message: [api] Expose PreviewEntries as public API Turn `debug::EntriesPreview` into a public API. This is a straightforward approach to addressing #20409 (not relying on functionality behind `--allow-natives-syntax`) in Node.js. Refs: v8/v8@ff0a979 PR-URL: #20719 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 40c8bbe commit fb26861
Copy full SHA for fb26861

File tree

Expand file treeCollapse file tree

5 files changed

+24
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+24
-16
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
@@ -27,7 +27,7 @@
2727

2828
# Reset this number to 0 on major V8 upgrades.
2929
# Increment by one for each non-official patch applied to deps/v8.
30-
'v8_embedder_string': '-node.4',
30+
'v8_embedder_string': '-node.5',
3131

3232
# Enable disassembler for `--print-code` v8 options
3333
'v8_enable_disassembler': 1,
Collapse file

‎deps/v8/include/v8.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8.h
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,6 +3549,17 @@ class V8_EXPORT Object : public Value {
35493549
*/
35503550
Isolate* GetIsolate();
35513551

3552+
/**
3553+
* If this object is a Set, Map, WeakSet or WeakMap, this returns a
3554+
* representation of the elements of this object as an array.
3555+
* If this object is a SetIterator or MapIterator, this returns all
3556+
* elements of the underlying collection, starting at the iterator's current
3557+
* position.
3558+
* For other types, this will return an empty MaybeLocal<Array> (without
3559+
* scheduling an exception).
3560+
*/
3561+
MaybeLocal<Array> PreviewEntries(bool* is_key_value);
3562+
35523563
static Local<Object> New(Isolate* isolate);
35533564

35543565
V8_INLINE static Object* Cast(Value* obj);
Collapse file

‎deps/v8/src/api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/api.cc
+9-10Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9635,21 +9635,20 @@ int debug::EstimatedValueSize(Isolate* v8_isolate, v8::Local<v8::Value> value) {
96359635
return i::Handle<i::HeapObject>::cast(object)->Size();
96369636
}
96379637

9638-
v8::MaybeLocal<v8::Array> debug::EntriesPreview(Isolate* v8_isolate,
9639-
v8::Local<v8::Value> value,
9640-
bool* is_key_value) {
9641-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9642-
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
9643-
if (value->IsMap()) {
9638+
v8::MaybeLocal<v8::Array> v8::Object::PreviewEntries(bool* is_key_value) {
9639+
if (IsMap()) {
96449640
*is_key_value = true;
9645-
return value.As<Map>()->AsArray();
9641+
return Map::Cast(this)->AsArray();
96469642
}
9647-
if (value->IsSet()) {
9643+
if (IsSet()) {
96489644
*is_key_value = false;
9649-
return value.As<Set>()->AsArray();
9645+
return Set::Cast(this)->AsArray();
96509646
}
96519647

9652-
i::Handle<i::Object> object = Utils::OpenHandle(*value);
9648+
i::Handle<i::JSReceiver> object = Utils::OpenHandle(this);
9649+
i::Isolate* isolate = object->GetIsolate();
9650+
Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
9651+
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
96539652
if (object->IsJSWeakCollection()) {
96549653
*is_key_value = object->IsJSWeakMap();
96559654
return Utils::ToLocal(i::JSWeakCollection::GetEntries(
Collapse file

‎deps/v8/src/debug/debug-interface.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/debug/debug-interface.h
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ void ResetBlackboxedStateCache(Isolate* isolate,
212212

213213
int EstimatedValueSize(Isolate* isolate, v8::Local<v8::Value> value);
214214

215-
v8::MaybeLocal<v8::Array> EntriesPreview(Isolate* isolate,
216-
v8::Local<v8::Value> value,
217-
bool* is_key_value);
218-
219215
enum Builtin {
220216
kObjectKeys,
221217
kObjectGetPrototypeOf,
Collapse file

‎deps/v8/src/inspector/v8-debugger.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ v8::MaybeLocal<v8::Array> collectionsEntries(v8::Local<v8::Context> context,
2929
v8::Isolate* isolate = context->GetIsolate();
3030
v8::Local<v8::Array> entries;
3131
bool isKeyValue = false;
32-
if (!v8::debug::EntriesPreview(isolate, value, &isKeyValue).ToLocal(&entries))
32+
if (!value->IsObject() ||
33+
!value.As<v8::Object>()->PreviewEntries(&isKeyValue).ToLocal(&entries)) {
3334
return v8::MaybeLocal<v8::Array>();
35+
}
3436

3537
v8::Local<v8::Array> wrappedEntries = v8::Array::New(isolate);
3638
CHECK(!isKeyValue || wrappedEntries->Length() % 2 == 0);

0 commit comments

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