Record statement positions for the debugger in the fast code generator.
authorfschneider@chromium.org <fschneider@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 15 Oct 2009 15:27:37 +0000 (15:27 +0000)
committerfschneider@chromium.org <fschneider@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 15 Oct 2009 15:27:37 +0000 (15:27 +0000)
Review URL: http://codereview.chromium.org/271102

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3075 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/codegen-arm.h
src/arm/fast-codegen-arm.cc
src/codegen.cc
src/codegen.h
src/fast-codegen.cc
src/fast-codegen.h
src/ia32/codegen-ia32.h
src/ia32/fast-codegen-ia32.cc
src/x64/codegen-x64.h
src/x64/fast-codegen-x64.cc

index 63be25f5840f05651b6bad2f307de935cb8b7762..7b50b01049fc5c135d0d394bedb43ae473a088d9 100644 (file)
@@ -165,6 +165,8 @@ class CodeGenerator: public AstVisitor {
                               bool is_toplevel,
                               Handle<Script> script);
 
+  static void RecordPositions(MacroAssembler* masm, int pos);
+
   // Accessors
   MacroAssembler* masm() { return masm_; }
 
index 8299ec2ab34de7271797384a6ecefc1bf8b71425..e3587115a9f9f02778b25ea351b3713f7a5d39cf 100644 (file)
@@ -51,6 +51,7 @@ namespace internal {
 // frames-arm.h for its layout.
 void FastCodeGenerator::Generate(FunctionLiteral* fun) {
   function_ = fun;
+  // ARM does NOT call SetFunctionPosition.
 
   __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
   // Adjust fp to point to caller's fp.
@@ -92,6 +93,7 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
     // Emit a 'return undefined' in case control fell off the end of the
     // body.
     __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
+    SetReturnPosition(fun);
     __ RecordJSReturn();
     __ mov(sp, fp);
     __ ldm(ia_w, sp, fp.bit() | lr.bit());
@@ -104,6 +106,7 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
 
 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
   Comment cmnt(masm_, "[ ExpressionStatement");
+  SetStatementPosition(stmt);
   Visit(stmt->expression());
   __ pop();
 }
@@ -111,6 +114,7 @@ void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
 
 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
   Comment cmnt(masm_, "[ ReturnStatement");
+  SetStatementPosition(stmt);
   Visit(stmt->expression());
   __ pop(r0);
   __ RecordJSReturn();
index c47e3685c2e22d3d60f81a41795f0acd5a97cab9..096a1a19104bd001596caba7270167fa94371fcf 100644 (file)
@@ -499,26 +499,26 @@ CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition(
 }
 
 
-static inline void RecordPositions(CodeGenerator* cgen, int pos) {
+void CodeGenerator::RecordPositions(MacroAssembler* masm, int pos) {
   if (pos != RelocInfo::kNoPosition) {
-    cgen->masm()->RecordStatementPosition(pos);
-    cgen->masm()->RecordPosition(pos);
+    masm->RecordStatementPosition(pos);
+    masm->RecordPosition(pos);
   }
 }
 
 
 void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) {
-  if (FLAG_debug_info) RecordPositions(this, fun->start_position());
+  if (FLAG_debug_info) RecordPositions(masm(), fun->start_position());
 }
 
 
 void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) {
-  if (FLAG_debug_info) RecordPositions(this, fun->end_position());
+  if (FLAG_debug_info) RecordPositions(masm(), fun->end_position());
 }
 
 
 void CodeGenerator::CodeForStatementPosition(Statement* stmt) {
-  if (FLAG_debug_info) RecordPositions(this, stmt->statement_pos());
+  if (FLAG_debug_info) RecordPositions(masm(), stmt->statement_pos());
 }
 
 
index ac6e9074881e0d91b719eafbd011b0beedd54fb8..1209f36ec64dea90591186c844b4a62d4502b348 100644 (file)
@@ -48,6 +48,7 @@
 //   AddDeferred
 //   in_spilled_code
 //   set_in_spilled_code
+//   RecordPositions
 //
 // These methods are either used privately by the shared code or implemented as
 // shared code:
index f91eb553d64c1b3f40ad32968abc04c8048ec5e7..e4a407d322ecd69ad693d4840d7a593f300e1a00 100644 (file)
@@ -66,6 +66,33 @@ int FastCodeGenerator::SlotOffset(Slot* slot) {
   return offset;
 }
 
+void FastCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) {
+  if (FLAG_debug_info) {
+    CodeGenerator::RecordPositions(masm_, fun->start_position());
+  }
+}
+
+
+void FastCodeGenerator::SetReturnPosition(FunctionLiteral* fun) {
+  if (FLAG_debug_info) {
+    CodeGenerator::RecordPositions(masm_, fun->end_position());
+  }
+}
+
+
+void FastCodeGenerator::SetStatementPosition(Statement* stmt) {
+  if (FLAG_debug_info) {
+    CodeGenerator::RecordPositions(masm_, stmt->statement_pos());
+  }
+}
+
+
+void FastCodeGenerator::SetSourcePosition(int pos) {
+  if (FLAG_debug_info && pos != RelocInfo::kNoPosition) {
+    masm_->RecordPosition(pos);
+  }
+}
+
 
 void FastCodeGenerator::VisitDeclaration(Declaration* decl) {
   UNREACHABLE();
index 64cb72c66ccc67a98b0d5ef769bf2af22b7c6384..e6bb6436a44548701842cb9f8251c9d39e80941e 100644 (file)
@@ -49,6 +49,11 @@ class FastCodeGenerator: public AstVisitor {
  private:
   int SlotOffset(Slot* slot);
 
+  void SetFunctionPosition(FunctionLiteral* fun);
+  void SetReturnPosition(FunctionLiteral* fun);
+  void SetStatementPosition(Statement* stmt);
+  void SetSourcePosition(int pos);
+
   // AST node visit functions.
 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
   AST_NODE_LIST(DECLARE_VISIT)
index 78d9978a3cd0ca44114763b917665eed1d1d2517..ec4a8be16d29d3a530f612af72552f246fc497c7 100644 (file)
@@ -312,6 +312,8 @@ class CodeGenerator: public AstVisitor {
                               bool is_toplevel,
                               Handle<Script> script);
 
+  static void RecordPositions(MacroAssembler* masm, int pos);
+
   // Accessors
   MacroAssembler* masm() { return masm_; }
 
index 587ad7475ce207c91acb47a898d61063affa7dbc..2b612a5e31af79627632885bf2a4a57dec1a36db 100644 (file)
@@ -50,6 +50,7 @@ namespace internal {
 // frames-ia32.h for its layout.
 void FastCodeGenerator::Generate(FunctionLiteral* fun) {
   function_ = fun;
+  SetFunctionPosition(fun);
 
   __ push(ebp);  // Caller's frame pointer.
   __ mov(ebp, esp);
@@ -82,6 +83,7 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
     // Emit a 'return undefined' in case control fell off the end of the
     // body.
     __ mov(eax, Factory::undefined_value());
+    SetReturnPosition(fun);
     __ RecordJSReturn();
     // Do not use the leave instruction here because it is too short to
     // patch with the code required by the debugger.
@@ -94,6 +96,7 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
 
 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
   Comment cmnt(masm_, "[ ExpressionStatement");
+  SetStatementPosition(stmt);
   Visit(stmt->expression());
   __ pop(eax);
 }
@@ -101,6 +104,7 @@ void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
 
 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
   Comment cmnt(masm_, "[ ReturnStatement");
+  SetStatementPosition(stmt);
   Visit(stmt->expression());
   __ pop(eax);
   __ RecordJSReturn();
@@ -127,7 +131,6 @@ void FastCodeGenerator::VisitLiteral(Literal* expr) {
 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
   Comment cmnt(masm_, "[ Assignment");
   ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
-
   Visit(expr->value());
 
   Variable* var = expr->target()->AsVariableProxy()->AsVariable();
index da78ecf721835b6b088689bcbdff0ef3a52c87c9..5fa6583a317490a9830de81d1923b077b9678457 100644 (file)
@@ -312,6 +312,8 @@ class CodeGenerator: public AstVisitor {
                               bool is_toplevel,
                               Handle<Script> script);
 
+  static void RecordPositions(MacroAssembler* masm, int pos);
+
   // Accessors
   MacroAssembler* masm() { return masm_; }
 
index 39b2c9754b2d1268043ce18609574f30175c8a99..dcf826e9914a6146839bbfc6b9181ee3e859cbe6 100644 (file)
@@ -51,6 +51,7 @@ namespace internal {
 // frames-x64.h for its layout.
 void FastCodeGenerator::Generate(FunctionLiteral* fun) {
   function_ = fun;
+  SetFunctionPosition(fun);
 
   __ push(rbp);  // Caller's frame pointer.
   __ movq(rbp, rsp);
@@ -81,6 +82,7 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
     // Emit a 'return undefined' in case control fell off the end of the
     // body.
     __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
+    SetReturnPosition(fun);
     __ RecordJSReturn();
     // Do not use the leave instruction here because it is too short to
     // patch with the code required by the debugger.
@@ -102,6 +104,7 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
 
 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
   Comment cmnt(masm_, "[ ExpressionStatement");
+  SetStatementPosition(stmt);
   Visit(stmt->expression());
   __ pop(rax);
 }
@@ -109,6 +112,7 @@ void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
 
 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
   Comment cmnt(masm_, "[ ReturnStatement");
+  SetStatementPosition(stmt);
   Visit(stmt->expression());
   __ pop(rax);
   __ RecordJSReturn();