Commit 07ee0b17 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] correctly annotate scripts with debug id.

Previously, we would incorrectly not assign any debug id to scripts
deserialized from the code cache.

R=jgruber@chromium.org
BUG=v8:6072

Review-Url: https://codereview.chromium.org/2742713003
Cr-Commit-Position: refs/heads/master@{#43740}
parent 78199ce5
......@@ -1149,10 +1149,6 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
Handle<Script> script = parse_info->script();
// TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
FixedArray* array = isolate->native_context()->embedder_data();
script->set_context_data(array->get(v8::Context::kDebugIdIndex));
Handle<SharedFunctionInfo> result;
{ VMState<COMPILER> state(info->isolate());
......@@ -1509,17 +1505,17 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
CompilationCache* compilation_cache = isolate->compilation_cache();
InfoVectorPair eval_result = compilation_cache->LookupEval(
source, outer_info, context, language_mode, position);
Handle<SharedFunctionInfo> shared_info;
if (eval_result.has_shared()) {
shared_info = Handle<SharedFunctionInfo>(eval_result.shared(), isolate);
}
Handle<Cell> vector;
if (eval_result.has_vector()) {
vector = Handle<Cell>(eval_result.vector(), isolate);
}
Handle<SharedFunctionInfo> shared_info;
Handle<Script> script;
if (!eval_result.has_shared()) {
if (eval_result.has_shared()) {
shared_info = Handle<SharedFunctionInfo>(eval_result.shared(), isolate);
script = Handle<Script>(Script::cast(shared_info->script()), isolate);
} else {
script = isolate->factory()->NewScript(source);
if (isolate->NeedsSourcePositionsForProfiling()) {
Script::InitLineEnds(script);
......@@ -1690,13 +1686,14 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
if (CodeSerializer::Deserialize(isolate, *cached_data, source)
.ToHandle(&inner_result)) {
// Promote to per-isolate compilation cache.
// TODO(mvstanton): create a feedback vector array here.
DCHECK(inner_result->is_compiled());
Handle<FeedbackVector> feedback_vector =
FeedbackVector::New(isolate, inner_result);
vector = isolate->factory()->NewCell(feedback_vector);
compilation_cache->PutScript(source, context, language_mode,
inner_result, vector);
Handle<Script> script(Script::cast(inner_result->script()), isolate);
isolate->debug()->OnAfterCompile(script);
return inner_result;
}
// Deserializer failed. Fall through to compile.
......
......@@ -2025,6 +2025,10 @@ void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id,
}
void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
// Attach the correct debug id to the script. The debug id is used by the
// inspector to filter scripts by native context.
FixedArray* array = isolate_->native_context()->embedder_data();
script->set_context_data(array->get(v8::Context::kDebugIdIndex));
if (ignore_events()) return;
if (script->type() != i::Script::TYPE_NORMAL &&
script->type() != i::Script::TYPE_WASM) {
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --cache=code
Debug = debug.Debug
// Simple debug event handler which first time hit will perform 1000 steps and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment