Commit 5ea84123 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger,interpreter] add source position to stack checks.

DevTools uses the debug interrupt to trap on function entry. Without
source position at the stack check, we would get bogus source positions.

R=mstarzinger@chromium.org
BUG=chromium:595646
LOG=N

Review-Url: https://codereview.chromium.org/1925063002
Cr-Commit-Position: refs/heads/master@{#35864}
parent 9212be86
......@@ -860,7 +860,13 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined(
return OutputJump(Bytecode::kJumpIfUndefined, label);
}
BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck() {
BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) {
if (position != RelocInfo::kNoPosition) {
// We need to attach a non-breakable source position to a stack check,
// so we simply add it as expression position.
source_position_table_builder_.AddExpressionPosition(bytecodes_.size(),
position);
}
Output(Bytecode::kStackCheck);
return *this;
}
......
......@@ -223,7 +223,7 @@ class BytecodeArrayBuilder final : public ZoneObject {
BytecodeArrayBuilder& JumpIfNull(BytecodeLabel* label);
BytecodeArrayBuilder& JumpIfUndefined(BytecodeLabel* label);
BytecodeArrayBuilder& StackCheck();
BytecodeArrayBuilder& StackCheck(int position);
BytecodeArrayBuilder& Throw();
BytecodeArrayBuilder& ReThrow();
......
......@@ -638,7 +638,7 @@ void BytecodeGenerator::MakeBytecodeBody() {
VisitDeclarations(scope()->declarations());
// Perform a stack-check before the body.
builder()->StackCheck();
builder()->StackCheck(info()->literal()->start_position());
// Visit statements in the function body.
VisitStatements(info()->literal()->body());
......@@ -1036,7 +1036,7 @@ void BytecodeGenerator::VisitCaseClause(CaseClause* clause) {
void BytecodeGenerator::VisitIterationBody(IterationStatement* stmt,
LoopBuilder* loop_builder) {
ControlScopeForIteration execution_control(this, stmt, loop_builder);
builder()->StackCheck();
builder()->StackCheck(stmt->position());
Visit(stmt->body());
}
......
// Copyright 2016 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: --expose-debug-as debug --allow-natives-syntax
var Debug = debug.Debug;
var exception = null;
var loop = true;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertTrue(exec_state.frame(0).sourceLineText().indexOf("BREAK") > 0);
} catch (e) {
exception = e;
}
}
function f() { // BREAK
return 1;
}
Debug.setListener(listener);
%ScheduleBreak(); // Break on function entry.
f();
Debug.setListener(null);
assertNull(exception);
......@@ -208,7 +208,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.JumpIfFalse(&start);
// Emit stack check bytecode.
builder.StackCheck();
builder.StackCheck(0);
// Emit throw and re-throw in it's own basic block so that the rest of the
// code isn't omitted due to being dead.
......
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