| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7d46437 commit e1d4f43
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | 31 | # Reset this number to 0 on major V8 upgrades. | |
| 32 | 32 | # Increment by one for each non-official patch applied to deps/v8. | |
| 33 | - 'v8_embedder_string': '-node.15', | ||
| 33 | + 'v8_embedder_string': '-node.16', | ||
| 34 | 34 | ||
| 35 | 35 | # Enable disassembler for `--print-code` v8 options | |
| 36 | 36 | 'v8_enable_disassembler': 1, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9950,6 +9950,47 @@ debug::TypeProfile::ScriptData debug::TypeProfile::GetScriptData( | |||
| 9950 | 9950 | return ScriptData(i, type_profile_); | |
| 9951 | 9951 | } | |
| 9952 | 9952 | ||
| 9953 | + v8::MaybeLocal<v8::Value> debug::WeakMap::Get(v8::Local<v8::Context> context, | ||
| 9954 | + v8::Local<v8::Value> key) { | ||
| 9955 | + PREPARE_FOR_EXECUTION(context, WeakMap, Get, Value); | ||
| 9956 | + auto self = Utils::OpenHandle(this); | ||
| 9957 | + Local<Value> result; | ||
| 9958 | + i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | ||
| 9959 | + has_pending_exception = | ||
| 9960 | + !ToLocal<Value>(i::Execution::Call(isolate, isolate->weakmap_get(), self, | ||
| 9961 | + arraysize(argv), argv), | ||
| 9962 | + &result); | ||
| 9963 | + RETURN_ON_FAILED_EXECUTION(Value); | ||
| 9964 | + RETURN_ESCAPED(result); | ||
| 9965 | + } | ||
| 9966 | + | ||
| 9967 | + v8::MaybeLocal<debug::WeakMap> debug::WeakMap::Set( | ||
| 9968 | + v8::Local<v8::Context> context, v8::Local<v8::Value> key, | ||
| 9969 | + v8::Local<v8::Value> value) { | ||
| 9970 | + PREPARE_FOR_EXECUTION(context, WeakMap, Set, WeakMap); | ||
| 9971 | + auto self = Utils::OpenHandle(this); | ||
| 9972 | + i::Handle<i::Object> result; | ||
| 9973 | + i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), | ||
| 9974 | + Utils::OpenHandle(*value)}; | ||
| 9975 | + has_pending_exception = !i::Execution::Call(isolate, isolate->weakmap_set(), | ||
| 9976 | + self, arraysize(argv), argv) | ||
| 9977 | + .ToHandle(&result); | ||
| 9978 | + RETURN_ON_FAILED_EXECUTION(WeakMap); | ||
| 9979 | + RETURN_ESCAPED(Local<WeakMap>::Cast(Utils::ToLocal(result))); | ||
| 9980 | + } | ||
| 9981 | + | ||
| 9982 | + Local<debug::WeakMap> debug::WeakMap::New(v8::Isolate* isolate) { | ||
| 9983 | + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | ||
| 9984 | + LOG_API(i_isolate, WeakMap, New); | ||
| 9985 | + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | ||
| 9986 | + i::Handle<i::JSWeakMap> obj = i_isolate->factory()->NewJSWeakMap(); | ||
| 9987 | + return ToApiHandle<debug::WeakMap>(obj); | ||
| 9988 | + } | ||
| 9989 | + | ||
| 9990 | + debug::WeakMap* debug::WeakMap::Cast(v8::Value* value) { | ||
| 9991 | + return static_cast<debug::WeakMap*>(value); | ||
| 9992 | + } | ||
| 9993 | + | ||
| 9953 | 9994 | const char* CpuProfileNode::GetFunctionNameStr() const { | |
| 9954 | 9995 | const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | |
| 9955 | 9996 | return node->entry()->name(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,6 +116,7 @@ class RegisteredExtension { | |||
| 116 | 116 | V(Proxy, JSProxy) \ | |
| 117 | 117 | V(debug::GeneratorObject, JSGeneratorObject) \ | |
| 118 | 118 | V(debug::Script, Script) \ | |
| 119 | + V(debug::WeakMap, JSWeakMap) \ | ||
| 119 | 120 | V(Promise, JSPromise) \ | |
| 120 | 121 | V(Primitive, Object) \ | |
| 121 | 122 | V(PrimitiveArray, FixedArray) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3435,8 +3435,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, | |||
| 3435 | 3435 | ||
| 3436 | 3436 | SimpleInstallFunction(isolate_, prototype, "delete", | |
| 3437 | 3437 | Builtins::kWeakMapPrototypeDelete, 1, true); | |
| 3438 | - SimpleInstallFunction(isolate_, prototype, "get", Builtins::kWeakMapGet, 1, | ||
| 3439 | - true); | ||
| 3438 | + Handle<JSFunction> weakmap_get = SimpleInstallFunction( | ||
| 3439 | + isolate_, prototype, "get", Builtins::kWeakMapGet, 1, true); | ||
| 3440 | + native_context()->set_weakmap_get(*weakmap_get); | ||
| 3440 | 3441 | SimpleInstallFunction(isolate_, prototype, "has", Builtins::kWeakMapHas, 1, | |
| 3441 | 3442 | true); | |
| 3442 | 3443 | Handle<JSFunction> weakmap_set = SimpleInstallFunction( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -112,6 +112,7 @@ enum ContextLookupFlags { | |||
| 112 | 112 | V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, \ | |
| 113 | 113 | wasm_runtime_error_function) \ | |
| 114 | 114 | V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set) \ | |
| 115 | + V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get) \ | ||
| 115 | 116 | V(WEAKSET_ADD_INDEX, JSFunction, weakset_add) | |
| 116 | 117 | ||
| 117 | 118 | #define NATIVE_CONTEXT_FIELDS(V) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -750,6 +750,9 @@ class RuntimeCallTimer final { | |||
| 750 | 750 | V(Map_Has) \ | |
| 751 | 751 | V(Map_New) \ | |
| 752 | 752 | V(Map_Set) \ | |
| 753 | + V(WeakMap_Get) \ | ||
| 754 | + V(WeakMap_Set) \ | ||
| 755 | + V(WeakMap_New) \ | ||
| 753 | 756 | V(Message_GetEndColumn) \ | |
| 754 | 757 | V(Message_GetLineNumber) \ | |
| 755 | 758 | V(Message_GetSourceLine) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -502,6 +502,20 @@ class PostponeInterruptsScope { | |||
| 502 | 502 | std::unique_ptr<i::PostponeInterruptsScope> scope_; | |
| 503 | 503 | }; | |
| 504 | 504 | ||
| 505 | + class WeakMap : public v8::Object { | ||
| 506 | + public: | ||
| 507 | + V8_WARN_UNUSED_RESULT v8::MaybeLocal<v8::Value> Get( | ||
| 508 | + v8::Local<v8::Context> context, v8::Local<v8::Value> key); | ||
| 509 | + V8_WARN_UNUSED_RESULT v8::MaybeLocal<WeakMap> Set( | ||
| 510 | + v8::Local<v8::Context> context, v8::Local<v8::Value> key, | ||
| 511 | + v8::Local<v8::Value> value); | ||
| 512 | + | ||
| 513 | + static Local<WeakMap> New(v8::Isolate* isolate); | ||
| 514 | + V8_INLINE static WeakMap* Cast(Value* obj); | ||
| 515 | + | ||
| 516 | + private: | ||
| 517 | + WeakMap(); | ||
| 518 | + }; | ||
| 505 | 519 | } // namespace debug | |
| 506 | 520 | } // namespace v8 | |
| 507 | 521 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -751,11 +751,37 @@ v8::MaybeLocal<v8::Value> V8Debugger::generatorScopes( | |||
| 751 | 751 | return getTargetScopes(context, generator, GENERATOR); | |
| 752 | 752 | } | |
| 753 | 753 | ||
| 754 | + v8::MaybeLocal<v8::Uint32> V8Debugger::stableObjectId( | ||
| 755 | + v8::Local<v8::Context> context, v8::Local<v8::Value> value) { | ||
| 756 | + DCHECK(value->IsObject()); | ||
| 757 | + if (m_stableObjectId.IsEmpty()) { | ||
| 758 | + m_stableObjectId.Reset(m_isolate, v8::debug::WeakMap::New(m_isolate)); | ||
| 759 | + } | ||
| 760 | + v8::Local<v8::debug::WeakMap> stableObjectId = | ||
| 761 | + m_stableObjectId.Get(m_isolate); | ||
| 762 | + v8::Local<v8::Value> idValue; | ||
| 763 | + if (!stableObjectId->Get(context, value).ToLocal(&idValue) || | ||
| 764 | + !idValue->IsUint32()) { | ||
| 765 | + idValue = v8::Integer::NewFromUnsigned(m_isolate, ++m_lastStableObjectId); | ||
| 766 | + stableObjectId->Set(context, value, idValue).ToLocalChecked(); | ||
| 767 | + } | ||
| 768 | + return idValue.As<v8::Uint32>(); | ||
| 769 | + } | ||
| 770 | + | ||
| 754 | 771 | v8::MaybeLocal<v8::Array> V8Debugger::internalProperties( | |
| 755 | 772 | v8::Local<v8::Context> context, v8::Local<v8::Value> value) { | |
| 756 | 773 | v8::Local<v8::Array> properties; | |
| 757 | 774 | if (!v8::debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)) | |
| 758 | 775 | return v8::MaybeLocal<v8::Array>(); | |
| 776 | + if (value->IsObject()) { | ||
| 777 | + v8::Local<v8::Uint32> id; | ||
| 778 | + if (stableObjectId(context, value).ToLocal(&id)) { | ||
| 779 | + createDataProperty( | ||
| 780 | + context, properties, properties->Length(), | ||
| 781 | + toV8StringInternalized(m_isolate, "[[StableObjectId]]")); | ||
| 782 | + createDataProperty(context, properties, properties->Length(), id); | ||
| 783 | + } | ||
| 784 | + } | ||
| 759 | 785 | if (value->IsFunction()) { | |
| 760 | 786 | v8::Local<v8::Function> function = value.As<v8::Function>(); | |
| 761 | 787 | v8::Local<v8::Object> location; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,6 +189,9 @@ class V8Debugger : public v8::debug::DebugDelegate, | |||
| 189 | 189 | int currentContextGroupId(); | |
| 190 | 190 | bool asyncStepOutOfFunction(int targetContextGroupId, bool onlyAtReturn); | |
| 191 | 191 | ||
| 192 | + v8::MaybeLocal<v8::Uint32> stableObjectId(v8::Local<v8::Context>, | ||
| 193 | + v8::Local<v8::Value>); | ||
| 194 | + | ||
| 192 | 195 | v8::Isolate* m_isolate; | |
| 193 | 196 | V8InspectorImpl* m_inspector; | |
| 194 | 197 | int m_enableCount; | |
@@ -245,6 +248,9 @@ class V8Debugger : public v8::debug::DebugDelegate, | |||
| 245 | 248 | ||
| 246 | 249 | std::unique_ptr<TerminateExecutionCallback> m_terminateExecutionCallback; | |
| 247 | 250 | ||
| 251 | + uint32_t m_lastStableObjectId = 0; | ||
| 252 | + v8::Global<v8::debug::WeakMap> m_stableObjectId; | ||
| 253 | + | ||
| 248 | 254 | WasmTranslation m_wasmTranslation; | |
| 249 | 255 | ||
| 250 | 256 | DISALLOW_COPY_AND_ASSIGN(V8Debugger); | |
| 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 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments