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 e56716e

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 4b64c84 commit e56716e
Copy full SHA for e56716e

File tree

Expand file treeCollapse file tree

4 files changed

+23
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+23
-15
lines changed
Open diff view settings
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
@@ -3503,6 +3503,17 @@ class V8_EXPORT Object : public Value {
35033503
*/
35043504
Isolate* GetIsolate();
35053505

3506+
/**
3507+
* If this object is a Set, Map, WeakSet or WeakMap, this returns a
3508+
* representation of the elements of this object as an array.
3509+
* If this object is a SetIterator or MapIterator, this returns all
3510+
* elements of the underlying collection, starting at the iterator's current
3511+
* position.
3512+
* For other types, this will return an empty MaybeLocal<Array> (without
3513+
* scheduling an exception).
3514+
*/
3515+
MaybeLocal<Array> PreviewEntries(bool* is_key_value);
3516+
35063517
static Local<Object> New(Isolate* isolate);
35073518

35083519
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
@@ -9526,21 +9526,20 @@ int debug::EstimatedValueSize(Isolate* v8_isolate, v8::Local<v8::Value> value) {
95269526
return i::Handle<i::HeapObject>::cast(object)->Size();
95279527
}
95289528

9529-
v8::MaybeLocal<v8::Array> debug::EntriesPreview(Isolate* v8_isolate,
9530-
v8::Local<v8::Value> value,
9531-
bool* is_key_value) {
9532-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9533-
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
9534-
if (value->IsMap()) {
9529+
v8::MaybeLocal<v8::Array> v8::Object::PreviewEntries(bool* is_key_value) {
9530+
if (IsMap()) {
95359531
*is_key_value = true;
9536-
return value.As<Map>()->AsArray();
9532+
return Map::Cast(this)->AsArray();
95379533
}
9538-
if (value->IsSet()) {
9534+
if (IsSet()) {
95399535
*is_key_value = false;
9540-
return value.As<Set>()->AsArray();
9536+
return Set::Cast(this)->AsArray();
95419537
}
95429538

9543-
i::Handle<i::Object> object = Utils::OpenHandle(*value);
9539+
i::Handle<i::JSReceiver> object = Utils::OpenHandle(this);
9540+
i::Isolate* isolate = object->GetIsolate();
9541+
Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
9542+
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
95449543
if (object->IsJSWeakCollection()) {
95459544
*is_key_value = object->IsJSWeakMap();
95469545
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
@@ -204,10 +204,6 @@ void ResetBlackboxedStateCache(Isolate* isolate,
204204

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

207-
v8::MaybeLocal<v8::Array> EntriesPreview(Isolate* isolate,
208-
v8::Local<v8::Value> value,
209-
bool* is_key_value);
210-
211207
enum Builtin {
212208
kObjectKeys,
213209
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.