GeezerVison is showing github.com — deps: cherry-pick d9fbfeb from upstream V8 · nodejs/node@c9a3e40
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 |
|---|
| 33 | 33 |
| 34 | 34 | # Reset this number to 0 on major V8 upgrades. | 35 | 35 | # Increment by one for each non-official patch applied to deps/v8. | 36 | | - 'v8_embedder_string': '-node.48', | | 36 | + 'v8_embedder_string': '-node.49', | 37 | 37 |
| 38 | 38 | # Enable disassembler for `--print-code` v8 options | 39 | 39 | 'v8_enable_disassembler': 1, | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/api.cc +41Lines changed: 41 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10001,6 +10001,47 @@ debug::TypeProfile::ScriptData debug::TypeProfile::GetScriptData( | 10001 | 10001 | return ScriptData(i, type_profile_); | 10002 | 10002 | } | 10003 | 10003 |
| | 10004 | +v8::MaybeLocal<v8::Value> debug::WeakMap::Get(v8::Local<v8::Context> context, | | 10005 | + v8::Local<v8::Value> key) { | | 10006 | + PREPARE_FOR_EXECUTION(context, WeakMap, Get, Value); | | 10007 | + auto self = Utils::OpenHandle(this); | | 10008 | + Local<Value> result; | | 10009 | + i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | | 10010 | + has_pending_exception = | | 10011 | + !ToLocal<Value>(i::Execution::Call(isolate, isolate->weakmap_get(), self, | | 10012 | + arraysize(argv), argv), | | 10013 | + &result); | | 10014 | + RETURN_ON_FAILED_EXECUTION(Value); | | 10015 | + RETURN_ESCAPED(result); | | 10016 | +} | | 10017 | + | | 10018 | +v8::MaybeLocal<debug::WeakMap> debug::WeakMap::Set( | | 10019 | + v8::Local<v8::Context> context, v8::Local<v8::Value> key, | | 10020 | + v8::Local<v8::Value> value) { | | 10021 | + PREPARE_FOR_EXECUTION(context, WeakMap, Set, WeakMap); | | 10022 | + auto self = Utils::OpenHandle(this); | | 10023 | + i::Handle<i::Object> result; | | 10024 | + i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), | | 10025 | + Utils::OpenHandle(*value)}; | | 10026 | + has_pending_exception = !i::Execution::Call(isolate, isolate->weakmap_set(), | | 10027 | + self, arraysize(argv), argv) | | 10028 | + .ToHandle(&result); | | 10029 | + RETURN_ON_FAILED_EXECUTION(WeakMap); | | 10030 | + RETURN_ESCAPED(Local<WeakMap>::Cast(Utils::ToLocal(result))); | | 10031 | +} | | 10032 | + | | 10033 | +Local<debug::WeakMap> debug::WeakMap::New(v8::Isolate* isolate) { | | 10034 | + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | | 10035 | + LOG_API(i_isolate, WeakMap, New); | | 10036 | + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | | 10037 | + i::Handle<i::JSWeakMap> obj = i_isolate->factory()->NewJSWeakMap(); | | 10038 | + return ToApiHandle<debug::WeakMap>(obj); | | 10039 | +} | | 10040 | + | | 10041 | +debug::WeakMap* debug::WeakMap::Cast(v8::Value* value) { | | 10042 | + return static_cast<debug::WeakMap*>(value); | | 10043 | +} | | 10044 | + | 10004 | 10045 | const char* CpuProfileNode::GetFunctionNameStr() const { | 10005 | 10046 | const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 10006 | 10047 | return node->entry()->name(); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/api.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -124,6 +124,7 @@ class RegisteredExtension { | 124 | 124 | V(Proxy, JSProxy) \ | 125 | 125 | V(debug::GeneratorObject, JSGeneratorObject) \ | 126 | 126 | V(debug::Script, Script) \ | | 127 | + V(debug::WeakMap, JSWeakMap) \ | 127 | 128 | V(Promise, JSPromise) \ | 128 | 129 | V(Primitive, Object) \ | 129 | 130 | V(PrimitiveArray, FixedArray) \ | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/bootstrapper.cc +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3250,7 +3250,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, | 3250 | 3250 |
| 3251 | 3251 | SimpleInstallFunction(prototype, "delete", | 3252 | 3252 | Builtins::kWeakMapPrototypeDelete, 1, true); | 3253 | | - SimpleInstallFunction(prototype, "get", Builtins::kWeakMapGet, 1, true); | | 3253 | + Handle<JSFunction> weakmap_get = SimpleInstallFunction(prototype, "get", | | 3254 | + Builtins::kWeakMapGet, 1, true); | | 3255 | + native_context()->set_weakmap_get(*weakmap_get); | 3254 | 3256 | SimpleInstallFunction(prototype, "has", Builtins::kWeakMapHas, 1, true); | 3255 | 3257 | Handle<JSFunction> weakmap_set = SimpleInstallFunction( | 3256 | 3258 | prototype, "set", Builtins::kWeakMapPrototypeSet, 2, true); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/contexts.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -108,6 +108,7 @@ enum ContextLookupFlags { | 108 | 108 | V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, \ | 109 | 109 | wasm_runtime_error_function) \ | 110 | 110 | V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set) \ | | 111 | + V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get) \ | 111 | 112 | V(WEAKSET_ADD_INDEX, JSFunction, weakset_add) | 112 | 113 |
| 113 | 114 | #define NATIVE_CONTEXT_FIELDS(V) \ | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/counters.h +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -730,6 +730,9 @@ class RuntimeCallTimer final { | 730 | 730 | V(Map_Has) \ | 731 | 731 | V(Map_New) \ | 732 | 732 | V(Map_Set) \ | | 733 | + V(WeakMap_Get) \ | | 734 | + V(WeakMap_Set) \ | | 735 | + V(WeakMap_New) \ | 733 | 736 | V(Message_GetEndColumn) \ | 734 | 737 | V(Message_GetLineNumber) \ | 735 | 738 | V(Message_GetSourceLine) \ | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/debug/debug-interface.h +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -515,6 +515,20 @@ bool SetFunctionBreakpoint(v8::Local<v8::Function> function, | 515 | 515 |
| 516 | 516 | v8::Platform* GetCurrentPlatform(); | 517 | 517 |
| | 518 | +class WeakMap : public v8::Object { | | 519 | + public: | | 520 | + V8_WARN_UNUSED_RESULT v8::MaybeLocal<v8::Value> Get( | | 521 | + v8::Local<v8::Context> context, v8::Local<v8::Value> key); | | 522 | + V8_WARN_UNUSED_RESULT v8::MaybeLocal<WeakMap> Set( | | 523 | + v8::Local<v8::Context> context, v8::Local<v8::Value> key, | | 524 | + v8::Local<v8::Value> value); | | 525 | + | | 526 | + static Local<WeakMap> New(v8::Isolate* isolate); | | 527 | + V8_INLINE static WeakMap* Cast(Value* obj); | | 528 | + | | 529 | + private: | | 530 | + WeakMap(); | | 531 | +}; | 518 | 532 | } // namespace debug | 519 | 533 | } // namespace v8 | 520 | 534 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger.cc +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -703,11 +703,37 @@ v8::MaybeLocal<v8::Value> V8Debugger::generatorScopes( | 703 | 703 | return getTargetScopes(context, generator, GENERATOR); | 704 | 704 | } | 705 | 705 |
| | 706 | +v8::MaybeLocal<v8::Uint32> V8Debugger::stableObjectId( | | 707 | + v8::Local<v8::Context> context, v8::Local<v8::Value> value) { | | 708 | + DCHECK(value->IsObject()); | | 709 | + if (m_stableObjectId.IsEmpty()) { | | 710 | + m_stableObjectId.Reset(m_isolate, v8::debug::WeakMap::New(m_isolate)); | | 711 | + } | | 712 | + v8::Local<v8::debug::WeakMap> stableObjectId = | | 713 | + m_stableObjectId.Get(m_isolate); | | 714 | + v8::Local<v8::Value> idValue; | | 715 | + if (!stableObjectId->Get(context, value).ToLocal(&idValue) || | | 716 | + !idValue->IsUint32()) { | | 717 | + idValue = v8::Integer::NewFromUnsigned(m_isolate, ++m_lastStableObjectId); | | 718 | + stableObjectId->Set(context, value, idValue).ToLocalChecked(); | | 719 | + } | | 720 | + return idValue.As<v8::Uint32>(); | | 721 | +} | | 722 | + | 706 | 723 | v8::MaybeLocal<v8::Array> V8Debugger::internalProperties( | 707 | 724 | v8::Local<v8::Context> context, v8::Local<v8::Value> value) { | 708 | 725 | v8::Local<v8::Array> properties; | 709 | 726 | if (!v8::debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)) | 710 | 727 | return v8::MaybeLocal<v8::Array>(); | | 728 | + if (value->IsObject()) { | | 729 | + v8::Local<v8::Uint32> id; | | 730 | + if (stableObjectId(context, value).ToLocal(&id)) { | | 731 | + createDataProperty( | | 732 | + context, properties, properties->Length(), | | 733 | + toV8StringInternalized(m_isolate, "[[StableObjectId]]")); | | 734 | + createDataProperty(context, properties, properties->Length(), id); | | 735 | + } | | 736 | + } | 711 | 737 | if (value->IsFunction()) { | 712 | 738 | v8::Local<v8::Function> function = value.As<v8::Function>(); | 713 | 739 | v8::Local<v8::Object> location; | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/inspector/v8-debugger.h +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -185,6 +185,9 @@ class V8Debugger : public v8::debug::DebugDelegate { | 185 | 185 |
| 186 | 186 | int currentContextGroupId(); | 187 | 187 |
| | 188 | + v8::MaybeLocal<v8::Uint32> stableObjectId(v8::Local<v8::Context>, | | 189 | + v8::Local<v8::Value>); | | 190 | + | 188 | 191 | v8::Isolate* m_isolate; | 189 | 192 | V8InspectorImpl* m_inspector; | 190 | 193 | int m_enableCount; | @@ -241,6 +244,9 @@ class V8Debugger : public v8::debug::DebugDelegate { | 241 | 244 |
| 242 | 245 | std::unique_ptr<TerminateExecutionCallback> m_terminateExecutionCallback; | 243 | 246 |
| | 247 | + uint32_t m_lastStableObjectId = 0; | | 248 | + v8::Global<v8::debug::WeakMap> m_stableObjectId; | | 249 | + | 244 | 250 | WasmTranslation m_wasmTranslation; | 245 | 251 |
| 246 | 252 | DISALLOW_COPY_AND_ASSIGN(V8Debugger); | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/test/inspector/debugger/eval-scopes-expected.txt +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,12 @@ Tests that variables introduced in eval scopes are accessible | 2 | 2 | { | 3 | 3 | id : <messageId> | 4 | 4 | result : { | | 5 | + internalProperties : [ | | 6 | + [0] : { | | 7 | + name : [[StableObjectId]] | | 8 | + value : <StablectObjectId> | | 9 | + } | | 10 | + ] | 5 | 11 | result : [ | 6 | 12 | [0] : { | 7 | 13 | configurable : true | |
|