Revision: 3075 Author: [email protected] Date: Thu Oct 15 08:27:37 2009 Log: Record statement positions for the debugger in the fast code generator.
Review URL: http://codereview.chromium.org/271102 http://code.google.com/p/v8/source/detail?r=3075 Modified: /branches/bleeding_edge/src/arm/codegen-arm.h /branches/bleeding_edge/src/arm/fast-codegen-arm.cc /branches/bleeding_edge/src/codegen.cc /branches/bleeding_edge/src/codegen.h /branches/bleeding_edge/src/fast-codegen.cc /branches/bleeding_edge/src/fast-codegen.h /branches/bleeding_edge/src/ia32/codegen-ia32.h /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc /branches/bleeding_edge/src/x64/codegen-x64.h /branches/bleeding_edge/src/x64/fast-codegen-x64.cc ======================================= --- /branches/bleeding_edge/src/arm/codegen-arm.h Wed Oct 14 12:30:50 2009 +++ /branches/bleeding_edge/src/arm/codegen-arm.h Thu Oct 15 08:27:37 2009 @@ -165,6 +165,8 @@ bool is_toplevel, Handle<Script> script); + static void RecordPositions(MacroAssembler* masm, int pos); + // Accessors MacroAssembler* masm() { return masm_; } ======================================= --- /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Thu Oct 15 05:42:16 2009 +++ /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Thu Oct 15 08:27:37 2009 @@ -51,6 +51,7 @@ // 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 @@ // 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::VisitExpressionStatement(ExpressionStatement* stmt) { Comment cmnt(masm_, "[ ExpressionStatement"); + SetStatementPosition(stmt); Visit(stmt->expression()); __ pop(); } @@ -111,6 +114,7 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { Comment cmnt(masm_, "[ ReturnStatement"); + SetStatementPosition(stmt); Visit(stmt->expression()); __ pop(r0); __ RecordJSReturn(); ======================================= --- /branches/bleeding_edge/src/codegen.cc Wed Oct 14 12:30:50 2009 +++ /branches/bleeding_edge/src/codegen.cc Thu Oct 15 08:27:37 2009 @@ -499,26 +499,26 @@ } -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()); } ======================================= --- /branches/bleeding_edge/src/codegen.h Wed Oct 14 12:30:50 2009 +++ /branches/bleeding_edge/src/codegen.h Thu Oct 15 08:27:37 2009 @@ -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: ======================================= --- /branches/bleeding_edge/src/fast-codegen.cc Thu Oct 15 04:21:26 2009 +++ /branches/bleeding_edge/src/fast-codegen.cc Thu Oct 15 08:27:37 2009 @@ -65,6 +65,33 @@ } 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) { ======================================= --- /branches/bleeding_edge/src/fast-codegen.h Thu Oct 15 05:42:16 2009 +++ /branches/bleeding_edge/src/fast-codegen.h Thu Oct 15 08:27:37 2009 @@ -49,6 +49,11 @@ 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) ======================================= --- /branches/bleeding_edge/src/ia32/codegen-ia32.h Wed Oct 14 12:30:50 2009 +++ /branches/bleeding_edge/src/ia32/codegen-ia32.h Thu Oct 15 08:27:37 2009 @@ -312,6 +312,8 @@ bool is_toplevel, Handle<Script> script); + static void RecordPositions(MacroAssembler* masm, int pos); + // Accessors MacroAssembler* masm() { return masm_; } ======================================= --- /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc Thu Oct 15 05:42:16 2009 +++ /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc Thu Oct 15 08:27:37 2009 @@ -50,6 +50,7 @@ // 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 @@ // 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::VisitExpressionStatement(ExpressionStatement* stmt) { Comment cmnt(masm_, "[ ExpressionStatement"); + SetStatementPosition(stmt); Visit(stmt->expression()); __ pop(eax); } @@ -101,6 +104,7 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { Comment cmnt(masm_, "[ ReturnStatement"); + SetStatementPosition(stmt); Visit(stmt->expression()); __ pop(eax); __ RecordJSReturn(); @@ -127,7 +131,6 @@ 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(); ======================================= --- /branches/bleeding_edge/src/x64/codegen-x64.h Wed Oct 14 12:30:50 2009 +++ /branches/bleeding_edge/src/x64/codegen-x64.h Thu Oct 15 08:27:37 2009 @@ -312,6 +312,8 @@ bool is_toplevel, Handle<Script> script); + static void RecordPositions(MacroAssembler* masm, int pos); + // Accessors MacroAssembler* masm() { return masm_; } ======================================= --- /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Thu Oct 15 04:21:26 2009 +++ /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Thu Oct 15 08:27:37 2009 @@ -51,6 +51,7 @@ // 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 @@ // 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::VisitExpressionStatement(ExpressionStatement* stmt) { Comment cmnt(masm_, "[ ExpressionStatement"); + SetStatementPosition(stmt); Visit(stmt->expression()); __ pop(rax); } @@ -109,6 +112,7 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { Comment cmnt(masm_, "[ ReturnStatement"); + SetStatementPosition(stmt); Visit(stmt->expression()); __ pop(rax); __ RecordJSReturn(); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
