Fix the debugger in multipass mode by introducing phantom instructions
authorkmillikin@chromium.org <kmillikin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 6 Aug 2009 11:14:48 +0000 (11:14 +0000)
committerkmillikin@chromium.org <kmillikin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 6 Aug 2009 11:14:48 +0000 (11:14 +0000)
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

src/arm/cfg-arm.cc
src/cfg.cc
src/cfg.h
src/ia32/cfg-ia32.cc
src/x64/cfg-x64.cc

index e060381..e7c3b7c 100644 (file)
@@ -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.
index bd4c8ae..51d3620 100644 (file)
@@ -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());
 }
index 02a99f4..ec08166 100644 (file)
--- a/src/cfg.h
+++ b/src/cfg.h
@@ -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() {}
 
index 64ee4cb..1ffddbc 100644 (file)
@@ -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.
index ea7b6db..21ac3e0 100644 (file)
@@ -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.