Commit 96ef78aa authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Fix FrameInspector when deoptimizer is disabled.

This is a workaround to make the debugger happy about TurboFan frames
when the debugger causes frame inspection. Note that this can happen
because the debugger can be activated while there still are optimized
TurboFan activations on the stack.

R=ishell@chromium.org
BUG=chromium:465298
TEST=mjsunit/regress/regress-crbug-465298
LOG=N

Review URL: https://codereview.chromium.org/1074793003

Cr-Commit-Position: refs/heads/master@{#27717}
parent 635b5fea
......@@ -294,14 +294,20 @@ class FrameInspector {
FrameInspector(JavaScriptFrame* frame, int inlined_jsframe_index,
Isolate* isolate)
: frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) {
has_adapted_arguments_ = frame_->has_adapted_arguments();
is_bottommost_ = inlined_jsframe_index == 0;
is_optimized_ = frame_->is_optimized();
// Calculate the deoptimized frame.
if (frame->is_optimized()) {
// TODO(turbofan): Revisit once we support deoptimization.
if (frame->LookupCode()->is_turbofanned() && !FLAG_turbo_deoptimization) {
is_optimized_ = false;
return;
}
deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
frame, inlined_jsframe_index, isolate);
}
has_adapted_arguments_ = frame_->has_adapted_arguments();
is_bottommost_ = inlined_jsframe_index == 0;
is_optimized_ = frame_->is_optimized();
}
~FrameInspector() {
......@@ -325,6 +331,10 @@ class FrameInspector {
: frame_->GetParameter(index);
}
Object* GetExpression(int index) {
// TODO(turbofan): Revisit once we support deoptimization.
if (frame_->LookupCode()->is_turbofanned() && !FLAG_turbo_deoptimization) {
return isolate_->heap()->undefined_value();
}
return is_optimized_ ? deoptimized_frame_->GetExpression(index)
: frame_->GetExpression(index);
}
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --noturbo-osr --expose-debug-as debug
var stdlib = this;
var buffer = new ArrayBuffer(64 * 1024);
var foreign = { thrower: thrower, debugme: debugme }
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug;
var listenerCalled = false;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
var frame = exec_state.frame(1);
assertEquals(m.foo, frame.func().value());
listenerCalled = true;
}
} catch (e) {
print("Caught: " + e + " " + e.stack);
};
}
function thrower() { throw "boom"; }
function debugme() { Debug.setListener(listener); debugger; }
function Module(stdlib, foreign, heap) {
"use asm";
var thrower = foreign.thrower;
var debugme = foreign.debugme;
function foo(i) {
i = i|0;
var a = 101; // Local variables exist ...
var b = 102; // ... to make the debugger ...
var c = 103; // ... inspect them during break.
if (i > 0) {
debugme();
i = 23;
} else {
thrower();
i = 42;
}
return i|0;
}
return { foo: foo };
}
var m = Module(stdlib, foreign, buffer);
assertThrows("m.foo(0)");
assertEquals(23, m.foo(1));
assertTrue(listenerCalled);
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