Commit 9611a4d2 authored by yangguo's avatar yangguo Committed by Commit bot

[debug] always add debug slot for statements.

Previously we would elide debug slots if the statement position it
belongs to has just already been written. The motivation is that since
we should only break once per statement, we can elide debug slots that
has the same statement position as the previous debug slot.

This is an unnecessary optimization, since the debugger has yet another
check against breaking twice at the same statement at runtime, in
Debug::Break.

This optimization can also be wrong, if there is control flow involved,
for example if we can jump to the elided debug slot without executing
the previous debug slot.

CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel
R=jgruber@chromium.org

Review-Url: https://codereview.chromium.org/2080173002
Cr-Commit-Position: refs/heads/master@{#37107}
parent 2d778239
......@@ -1790,7 +1790,7 @@ std::ostream& operator<<(std::ostream& os, ExternalReference reference) {
return os;
}
bool AssemblerPositionsRecorder::RecordPosition(int pos) {
void AssemblerPositionsRecorder::RecordPosition(int pos) {
DCHECK(pos != RelocInfo::kNoPosition);
DCHECK(pos >= 0);
current_position_ = pos;
......@@ -1798,10 +1798,10 @@ bool AssemblerPositionsRecorder::RecordPosition(int pos) {
CodeLinePosInfoAddPositionEvent(jit_handler_data_,
assembler_->pc_offset(),
pos));
return WriteRecordedPositions();
WriteRecordedPositions();
}
bool AssemblerPositionsRecorder::RecordStatementPosition(int pos) {
void AssemblerPositionsRecorder::RecordStatementPosition(int pos) {
DCHECK(pos != RelocInfo::kNoPosition);
DCHECK(pos >= 0);
current_statement_position_ = pos;
......@@ -1810,12 +1810,10 @@ bool AssemblerPositionsRecorder::RecordStatementPosition(int pos) {
jit_handler_data_,
assembler_->pc_offset(),
pos));
return RecordPosition(pos);
RecordPosition(pos);
}
bool AssemblerPositionsRecorder::WriteRecordedPositions() {
bool written = false;
void AssemblerPositionsRecorder::WriteRecordedPositions() {
// Write the statement position if it is different from what was written last
// time.
if (current_statement_position_ != written_statement_position_) {
......@@ -1824,7 +1822,6 @@ bool AssemblerPositionsRecorder::WriteRecordedPositions() {
current_statement_position_);
written_position_ = current_statement_position_;
written_statement_position_ = current_statement_position_;
written = true;
}
// Write the position if it is different from what was written last time and
......@@ -1833,11 +1830,7 @@ bool AssemblerPositionsRecorder::WriteRecordedPositions() {
EnsureSpace ensure_space(assembler_);
assembler_->RecordRelocInfo(RelocInfo::POSITION, current_position_);
written_position_ = current_position_;
written = true;
}
// Return whether something was written.
return written;
}
......
......@@ -1148,14 +1148,14 @@ class AssemblerPositionsRecorder : public PositionsRecorder {
written_statement_position_(RelocInfo::kNoPosition) {}
// Set current position to pos.
bool RecordPosition(int pos);
void RecordPosition(int pos);
// Set current statement position to pos.
bool RecordStatementPosition(int pos);
void RecordStatementPosition(int pos);
private:
// Write recorded positions to relocation information.
bool WriteRecordedPositions();
void WriteRecordedPositions();
Assembler* assembler_;
......
......@@ -615,15 +615,14 @@ void FullCodeGenerator::EmitHasProperty() {
RestoreContext();
}
bool RecordStatementPosition(MacroAssembler* masm, int pos) {
if (pos == RelocInfo::kNoPosition) return false;
return masm->positions_recorder()->RecordStatementPosition(pos);
void RecordStatementPosition(MacroAssembler* masm, int pos) {
if (pos == RelocInfo::kNoPosition) return;
masm->positions_recorder()->RecordStatementPosition(pos);
}
bool RecordPosition(MacroAssembler* masm, int pos) {
if (pos == RelocInfo::kNoPosition) return false;
return masm->positions_recorder()->RecordPosition(pos);
void RecordPosition(MacroAssembler* masm, int pos) {
if (pos == RelocInfo::kNoPosition) return;
masm->positions_recorder()->RecordPosition(pos);
}
......@@ -647,8 +646,8 @@ void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) {
void FullCodeGenerator::SetStatementPosition(
Statement* stmt, FullCodeGenerator::InsertBreak insert_break) {
if (stmt->position() == RelocInfo::kNoPosition) return;
bool recorded = RecordStatementPosition(masm_, stmt->position());
if (recorded && insert_break == INSERT_BREAK && info_->is_debug() &&
RecordStatementPosition(masm_, stmt->position());
if (insert_break == INSERT_BREAK && info_->is_debug() &&
!stmt->IsDebuggerStatement()) {
DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION);
}
......@@ -662,8 +661,8 @@ void FullCodeGenerator::SetExpressionPosition(Expression* expr) {
void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) {
if (expr->position() == RelocInfo::kNoPosition) return;
bool recorded = RecordStatementPosition(masm_, expr->position());
if (recorded && info_->is_debug()) {
RecordStatementPosition(masm_, expr->position());
if (info_->is_debug()) {
DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION);
}
}
......
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