From c622cb637a2831f9c2bf0ec7b80bb65440e9afc4 Mon Sep 17 00:00:00 2001 From: yurys Date: Thu, 19 Mar 2015 01:18:35 -0700 Subject: [PATCH] Introduce explicit constant for per Context debug data set by embedder It's value is hardwired in gin[1] and is referenced in Blink[2]. Since it is treated specially by v8 debugger it should be defined in v8 API and referenced in gin and blink.. [1] https://src.chromium.org/viewvc/chrome/trunk/src/gin/public/context_holder.h?r1=239099&r2=239098&pathrev=239099 [2] https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/bindings/core/v8/V8PerContextData.cpp&q=kDebugIdIndex%20f:V8PerContextData&sq=package:chromium&type=cs BUG=chromium:466631 LOG=Y Review URL: https://codereview.chromium.org/1020453002 Cr-Commit-Position: refs/heads/master@{#27290} --- include/v8.h | 7 +++++++ src/compiler.cc | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/v8.h b/include/v8.h index 27f4629..8ed5b8d 100644 --- a/include/v8.h +++ b/include/v8.h @@ -6288,6 +6288,13 @@ class V8_EXPORT Context { v8::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. + */ + 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. diff --git a/src/compiler.cc b/src/compiler.cc index d31cbea..f3584d5 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1059,7 +1059,7 @@ static Handle CompileToplevel(CompilationInfo* info) { // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? FixedArray* array = isolate->native_context()->embedder_data(); - script->set_context_data(array->get(0)); + script->set_context_data(array->get(v8::Context::kDebugIdIndex)); isolate->debug()->OnBeforeCompile(script); -- 2.7.4