Record statement positions for the debugger in the fast code generator.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3075 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
fschneider@chromium.org 2009-10-15 15:27:37 +00:00
parent 6f5ed57683
commit 1cc731ab0d
10 changed files with 57 additions and 7 deletions

View 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_; }

View 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();

View 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());
}

View 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:

View 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();

View 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)

View 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_; }

View 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();

View 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_; }

View 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();