Fix the debugger in multipass mode by introducing phantom instructions

marking statement boundaries.

Review URL: http://codereview.chromium.org/162007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2633 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6f21761e
......@@ -100,6 +100,14 @@ void ExitNode::Compile(MacroAssembler* masm) {
}
void PositionInstr::Compile(MacroAssembler* masm) {
if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
__ RecordStatementPosition(pos_);
__ RecordPosition(pos_);
}
}
void BinaryOpInstr::Compile(MacroAssembler* masm) {
// The right-hand value should not be on the stack---if it is a
// compiler-generated temporary it is in the accumulator.
......
......@@ -436,6 +436,7 @@ void StatementBuilder::VisitExpressionStatement(ExpressionStatement* stmt) {
Instruction* instr = block->instructions()->last();
instr->set_location(CfgGlobals::current()->effect_location());
}
cfg_->Append(new PositionInstr(stmt->statement_pos()));
cfg_->Concatenate(builder.cfg());
}
......@@ -467,6 +468,7 @@ void StatementBuilder::VisitReturnStatement(ReturnStatement* stmt) {
BAILOUT("unsupported expression in return statement");
}
cfg_->Append(new PositionInstr(stmt->statement_pos()));
cfg_->Concatenate(builder.cfg());
cfg_->AppendReturnInstruction(builder.value());
}
......
......@@ -306,7 +306,9 @@ class TempLocation : public Location {
class Instruction : public ZoneObject {
public:
// Every instruction has a location where its result is stored (which may
// be Effect).
// be Effect, the default).
Instruction() : loc_(CfgGlobals::current()->effect_location()) {}
explicit Instruction(Location* loc) : loc_(loc) {}
virtual ~Instruction() {}
......@@ -334,6 +336,30 @@ class Instruction : public ZoneObject {
};
// A phantom instruction that indicates the start of a statement. It
// causes the statement position to be recorded in the relocation
// information but generates no code.
class PositionInstr : public Instruction {
public:
explicit PositionInstr(int pos) : pos_(pos) {}
// Support for fast-compilation mode.
void Compile(MacroAssembler* masm);
// This should not be called. The last instruction of the previous
// statement should not have a temporary as its location.
void FastAllocate(TempLocation* temp) { UNREACHABLE(); }
#ifdef DEBUG
// Printing support. Print nothing.
void Print() {}
#endif
private:
int pos_;
};
// Perform a (non-short-circuited) binary operation on a pair of values,
// leaving the result in a location.
class BinaryOpInstr : public Instruction {
......@@ -365,10 +391,7 @@ class BinaryOpInstr : public Instruction {
class ReturnInstr : public Instruction {
public:
// Location is always Effect.
explicit ReturnInstr(Value* value)
: Instruction(CfgGlobals::current()->effect_location()),
value_(value) {
}
explicit ReturnInstr(Value* value) : value_(value) {}
virtual ~ReturnInstr() {}
......
......@@ -113,6 +113,14 @@ void ExitNode::Compile(MacroAssembler* masm) {
}
void PositionInstr::Compile(MacroAssembler* masm) {
if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
__ RecordStatementPosition(pos_);
__ RecordPosition(pos_);
}
}
void BinaryOpInstr::Compile(MacroAssembler* masm) {
// The right-hand value should not be on the stack---if it is a
// compiler-generated temporary it is in the accumulator.
......
......@@ -123,6 +123,14 @@ void ExitNode::Compile(MacroAssembler* masm) {
}
void PositionInstr::Compile(MacroAssembler* masm) {
if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
__ RecordStatementPosition(pos_);
__ RecordPosition(pos_);
}
}
void BinaryOpInstr::Compile(MacroAssembler* masm) {
// The right-hand value should not be on the stack---if it is a
// compiler-generated temporary it is in the accumulator.
......
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