diff --git a/include/v8.h b/include/v8.h index 287098489391..007a6ce25382 100644 --- a/include/v8.h +++ b/include/v8.h @@ -8350,16 +8350,14 @@ class V8_EXPORT Context { Isolate* GetIsolate(); /** - * The field at kDebugIdIndex is reserved for V8 debugger implementation. - * The value is propagated to the scripts compiled in given Context and - * can be used for filtering scripts. + * The field at kDebugIdIndex used to be reserved for the inspector. + * It now serves no purpose. */ enum EmbedderDataFields { kDebugIdIndex = 0 }; /** * Gets the embedder data with the given index, which must have been set by a - * previous call to SetEmbedderData with the same index. Note that index 0 - * currently has a special meaning for Chrome's debugger. + * previous call to SetEmbedderData with the same index. */ V8_INLINE Local GetEmbedderData(int index); diff --git a/src/api.cc b/src/api.cc index 818d1f3e8757..350ce1be164e 100644 --- a/src/api.cc +++ b/src/api.cc @@ -9139,6 +9139,15 @@ MaybeLocal Debug::GetInternalProperties(Isolate* v8_isolate, return debug::GetInternalProperties(v8_isolate, value); } +void debug::SetContextId(Local context, int id) { + Utils::OpenHandle(*context)->set_debug_context_id(i::Smi::FromInt(id)); +} + +int debug::GetContextId(Local context) { + i::Object* value = Utils::OpenHandle(*context)->debug_context_id(); + return (value->IsSmi()) ? i::Smi::cast(value)->value() : 0; +} + Local debug::GetDebugContext(Isolate* isolate) { i::Isolate* i_isolate = reinterpret_cast(isolate); ENTER_V8(i_isolate); diff --git a/src/contexts.h b/src/contexts.h index ee13995aaaab..d59837873b92 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -240,6 +240,7 @@ enum ContextLookupFlags { V(DATA_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, data_property_descriptor_map) \ V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \ V(DATE_FUNCTION_INDEX, JSFunction, date_function) \ + V(DEBUG_CONTEXT_ID_INDEX, Object, debug_context_id) \ V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \ error_message_for_code_gen_from_strings) \ V(ERRORS_THROWN_INDEX, Smi, errors_thrown) \ diff --git a/src/d8.cc b/src/d8.cc index cb29f4fd3037..208d4ba53799 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -642,8 +642,6 @@ class ModuleEmbedderData { }; enum { - // The debugger reserves the first slot in the Context embedder data. - kDebugIdIndex = Context::kDebugIdIndex, kModuleEmbedderDataIndex, kInspectorClientIndex }; diff --git a/src/debug/debug-interface.h b/src/debug/debug-interface.h index 443e07497db2..fd8bc978ef56 100644 --- a/src/debug/debug-interface.h +++ b/src/debug/debug-interface.h @@ -25,6 +25,9 @@ class Script; namespace debug { +void SetContextId(Local context, int id); +int GetContextId(Local context); + /** * Debugger is running in its own context which is entered while debugger * messages are being dispatched. This is an explicit getter for this diff --git a/src/debug/debug.cc b/src/debug/debug.cc index 73af4cf7f71b..e54b7e9778d7 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -2066,8 +2066,7 @@ void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle