Move the per-ast-node statement position to only statement node types.

It was not currently being used for expressions or declarations and
always had the default initial value.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2976 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 94d57588
...@@ -1188,7 +1188,6 @@ void CodeGenerator::VisitDeclaration(Declaration* node) { ...@@ -1188,7 +1188,6 @@ void CodeGenerator::VisitDeclaration(Declaration* node) {
#endif #endif
VirtualFrame::SpilledScope spilled_scope; VirtualFrame::SpilledScope spilled_scope;
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
CodeForStatementPosition(node);
Variable* var = node->proxy()->var(); Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved ASSERT(var != NULL); // must have been resolved
Slot* slot = var->slot(); Slot* slot = var->slot();
...@@ -2811,7 +2810,6 @@ void CodeGenerator::VisitAssignment(Assignment* node) { ...@@ -2811,7 +2810,6 @@ void CodeGenerator::VisitAssignment(Assignment* node) {
#endif #endif
VirtualFrame::SpilledScope spilled_scope; VirtualFrame::SpilledScope spilled_scope;
Comment cmnt(masm_, "[ Assignment"); Comment cmnt(masm_, "[ Assignment");
CodeForStatementPosition(node);
{ Reference target(this, node->target()); { Reference target(this, node->target());
if (target.is_illegal()) { if (target.is_illegal()) {
...@@ -2911,9 +2909,7 @@ void CodeGenerator::VisitCall(Call* node) { ...@@ -2911,9 +2909,7 @@ void CodeGenerator::VisitCall(Call* node) {
ZoneList<Expression*>* args = node->arguments(); ZoneList<Expression*>* args = node->arguments();
CodeForStatementPosition(node);
// Standard function call. // Standard function call.
// Check if the function is a variable or a property. // Check if the function is a variable or a property.
Expression* function = node->expression(); Expression* function = node->expression();
Variable* var = function->AsVariableProxy()->AsVariable(); Variable* var = function->AsVariableProxy()->AsVariable();
...@@ -3067,8 +3063,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) { ...@@ -3067,8 +3063,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) {
ZoneList<Expression*>* args = node->arguments(); ZoneList<Expression*>* args = node->arguments();
Expression* function = node->expression(); Expression* function = node->expression();
CodeForStatementPosition(node);
// Prepare stack for call to resolved function. // Prepare stack for call to resolved function.
LoadAndSpill(function); LoadAndSpill(function);
__ LoadRoot(r2, Heap::kUndefinedValueRootIndex); __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
...@@ -3118,7 +3112,6 @@ void CodeGenerator::VisitCallNew(CallNew* node) { ...@@ -3118,7 +3112,6 @@ void CodeGenerator::VisitCallNew(CallNew* node) {
#endif #endif
VirtualFrame::SpilledScope spilled_scope; VirtualFrame::SpilledScope spilled_scope;
Comment cmnt(masm_, "[ CallNew"); Comment cmnt(masm_, "[ CallNew");
CodeForStatementPosition(node);
// According to ECMA-262, section 11.2.2, page 44, the function // According to ECMA-262, section 11.2.2, page 44, the function
// expression in new calls must be evaluated before the // expression in new calls must be evaluated before the
......
...@@ -370,7 +370,7 @@ class CodeGenerator: public AstVisitor { ...@@ -370,7 +370,7 @@ class CodeGenerator: public AstVisitor {
// information. // information.
void CodeForFunctionPosition(FunctionLiteral* fun); void CodeForFunctionPosition(FunctionLiteral* fun);
void CodeForReturnPosition(FunctionLiteral* fun); void CodeForReturnPosition(FunctionLiteral* fun);
void CodeForStatementPosition(AstNode* node); void CodeForStatementPosition(Statement* node);
void CodeForSourcePosition(int pos); void CodeForSourcePosition(int pos);
#ifdef DEBUG #ifdef DEBUG
......
...@@ -116,7 +116,6 @@ typedef ZoneList<Handle<Object> > ZoneObjectList; ...@@ -116,7 +116,6 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
class AstNode: public ZoneObject { class AstNode: public ZoneObject {
public: public:
AstNode(): statement_pos_(RelocInfo::kNoPosition) { }
virtual ~AstNode() { } virtual ~AstNode() { }
virtual void Accept(AstVisitor* v) = 0; virtual void Accept(AstVisitor* v) = 0;
...@@ -140,21 +139,23 @@ class AstNode: public ZoneObject { ...@@ -140,21 +139,23 @@ class AstNode: public ZoneObject {
virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
virtual ObjectLiteral* AsObjectLiteral() { return NULL; } virtual ObjectLiteral* AsObjectLiteral() { return NULL; }
virtual ArrayLiteral* AsArrayLiteral() { return NULL; } virtual ArrayLiteral* AsArrayLiteral() { return NULL; }
void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; }
int statement_pos() const { return statement_pos_; }
private:
int statement_pos_;
}; };
class Statement: public AstNode { class Statement: public AstNode {
public: public:
Statement() : statement_pos_(RelocInfo::kNoPosition) {}
virtual Statement* AsStatement() { return this; } virtual Statement* AsStatement() { return this; }
virtual ReturnStatement* AsReturnStatement() { return NULL; } virtual ReturnStatement* AsReturnStatement() { return NULL; }
bool IsEmpty() { return AsEmptyStatement() != NULL; } bool IsEmpty() { return AsEmptyStatement() != NULL; }
void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; }
int statement_pos() const { return statement_pos_; }
private:
int statement_pos_;
}; };
......
...@@ -469,44 +469,32 @@ bool CodeGenerator::PatchInlineRuntimeEntry(Handle<String> name, ...@@ -469,44 +469,32 @@ bool CodeGenerator::PatchInlineRuntimeEntry(Handle<String> name,
} }
void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) { static inline void RecordPositions(CodeGenerator* cgen, int pos) {
if (FLAG_debug_info) { if (pos != RelocInfo::kNoPosition) {
int pos = fun->start_position(); cgen->masm()->RecordStatementPosition(pos);
if (pos != RelocInfo::kNoPosition) { cgen->masm()->RecordPosition(pos);
masm()->RecordStatementPosition(pos);
masm()->RecordPosition(pos);
}
} }
} }
void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) {
if (FLAG_debug_info) RecordPositions(this, fun->start_position());
}
void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) { void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) {
if (FLAG_debug_info) { if (FLAG_debug_info) RecordPositions(this, fun->end_position());
int pos = fun->end_position();
if (pos != RelocInfo::kNoPosition) {
masm()->RecordStatementPosition(pos);
masm()->RecordPosition(pos);
}
}
} }
void CodeGenerator::CodeForStatementPosition(AstNode* node) { void CodeGenerator::CodeForStatementPosition(Statement* stmt) {
if (FLAG_debug_info) { if (FLAG_debug_info) RecordPositions(this, stmt->statement_pos());
int pos = node->statement_pos();
if (pos != RelocInfo::kNoPosition) {
masm()->RecordStatementPosition(pos);
masm()->RecordPosition(pos);
}
}
} }
void CodeGenerator::CodeForSourcePosition(int pos) { void CodeGenerator::CodeForSourcePosition(int pos) {
if (FLAG_debug_info) { if (FLAG_debug_info && pos != RelocInfo::kNoPosition) {
if (pos != RelocInfo::kNoPosition) { masm()->RecordPosition(pos);
masm()->RecordPosition(pos);
}
} }
} }
......
...@@ -2305,7 +2305,6 @@ void CodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { ...@@ -2305,7 +2305,6 @@ void CodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
void CodeGenerator::VisitDeclaration(Declaration* node) { void CodeGenerator::VisitDeclaration(Declaration* node) {
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
CodeForStatementPosition(node);
Variable* var = node->proxy()->var(); Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved ASSERT(var != NULL); // must have been resolved
Slot* slot = var->slot(); Slot* slot = var->slot();
...@@ -4333,7 +4332,6 @@ void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) { ...@@ -4333,7 +4332,6 @@ void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) {
void CodeGenerator::VisitAssignment(Assignment* node) { void CodeGenerator::VisitAssignment(Assignment* node) {
Comment cmnt(masm_, "[ Assignment"); Comment cmnt(masm_, "[ Assignment");
CodeForStatementPosition(node);
{ Reference target(this, node->target()); { Reference target(this, node->target());
if (target.is_illegal()) { if (target.is_illegal()) {
...@@ -4415,8 +4413,6 @@ void CodeGenerator::VisitAssignment(Assignment* node) { ...@@ -4415,8 +4413,6 @@ void CodeGenerator::VisitAssignment(Assignment* node) {
void CodeGenerator::VisitThrow(Throw* node) { void CodeGenerator::VisitThrow(Throw* node) {
Comment cmnt(masm_, "[ Throw"); Comment cmnt(masm_, "[ Throw");
CodeForStatementPosition(node);
Load(node->exception()); Load(node->exception());
Result result = frame_->CallRuntime(Runtime::kThrow, 1); Result result = frame_->CallRuntime(Runtime::kThrow, 1);
frame_->Push(&result); frame_->Push(&result);
...@@ -4435,8 +4431,6 @@ void CodeGenerator::VisitCall(Call* node) { ...@@ -4435,8 +4431,6 @@ void CodeGenerator::VisitCall(Call* node) {
ZoneList<Expression*>* args = node->arguments(); ZoneList<Expression*>* args = node->arguments();
CodeForStatementPosition(node);
// Check if the function is a variable or a property. // Check if the function is a variable or a property.
Expression* function = node->expression(); Expression* function = node->expression();
Variable* var = function->AsVariableProxy()->AsVariable(); Variable* var = function->AsVariableProxy()->AsVariable();
...@@ -4591,7 +4585,6 @@ void CodeGenerator::VisitCall(Call* node) { ...@@ -4591,7 +4585,6 @@ void CodeGenerator::VisitCall(Call* node) {
void CodeGenerator::VisitCallNew(CallNew* node) { void CodeGenerator::VisitCallNew(CallNew* node) {
Comment cmnt(masm_, "[ CallNew"); Comment cmnt(masm_, "[ CallNew");
CodeForStatementPosition(node);
// According to ECMA-262, section 11.2.2, page 44, the function // According to ECMA-262, section 11.2.2, page 44, the function
// expression in new calls must be evaluated before the // expression in new calls must be evaluated before the
...@@ -4631,8 +4624,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) { ...@@ -4631,8 +4624,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) {
ZoneList<Expression*>* args = node->arguments(); ZoneList<Expression*>* args = node->arguments();
Expression* function = node->expression(); Expression* function = node->expression();
CodeForStatementPosition(node);
// Prepare the stack for the call to the resolved function. // Prepare the stack for the call to the resolved function.
Load(function); Load(function);
......
...@@ -553,7 +553,7 @@ class CodeGenerator: public AstVisitor { ...@@ -553,7 +553,7 @@ class CodeGenerator: public AstVisitor {
// information. // information.
void CodeForFunctionPosition(FunctionLiteral* fun); void CodeForFunctionPosition(FunctionLiteral* fun);
void CodeForReturnPosition(FunctionLiteral* fun); void CodeForReturnPosition(FunctionLiteral* fun);
void CodeForStatementPosition(AstNode* node); void CodeForStatementPosition(Statement* stmt);
void CodeForSourcePosition(int pos); void CodeForSourcePosition(int pos);
#ifdef DEBUG #ifdef DEBUG
......
...@@ -913,7 +913,6 @@ void CodeGenerator::VisitBlock(Block* node) { ...@@ -913,7 +913,6 @@ void CodeGenerator::VisitBlock(Block* node) {
void CodeGenerator::VisitDeclaration(Declaration* node) { void CodeGenerator::VisitDeclaration(Declaration* node) {
Comment cmnt(masm_, "[ Declaration"); Comment cmnt(masm_, "[ Declaration");
CodeForStatementPosition(node);
Variable* var = node->proxy()->var(); Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved ASSERT(var != NULL); // must have been resolved
Slot* slot = var->slot(); Slot* slot = var->slot();
...@@ -2592,7 +2591,6 @@ void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) { ...@@ -2592,7 +2591,6 @@ void CodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* node) {
void CodeGenerator::VisitAssignment(Assignment* node) { void CodeGenerator::VisitAssignment(Assignment* node) {
Comment cmnt(masm_, "[ Assignment"); Comment cmnt(masm_, "[ Assignment");
CodeForStatementPosition(node);
{ Reference target(this, node->target()); { Reference target(this, node->target());
if (target.is_illegal()) { if (target.is_illegal()) {
...@@ -2674,8 +2672,6 @@ void CodeGenerator::VisitAssignment(Assignment* node) { ...@@ -2674,8 +2672,6 @@ void CodeGenerator::VisitAssignment(Assignment* node) {
void CodeGenerator::VisitThrow(Throw* node) { void CodeGenerator::VisitThrow(Throw* node) {
Comment cmnt(masm_, "[ Throw"); Comment cmnt(masm_, "[ Throw");
CodeForStatementPosition(node);
Load(node->exception()); Load(node->exception());
Result result = frame_->CallRuntime(Runtime::kThrow, 1); Result result = frame_->CallRuntime(Runtime::kThrow, 1);
frame_->Push(&result); frame_->Push(&result);
...@@ -2694,8 +2690,6 @@ void CodeGenerator::VisitCall(Call* node) { ...@@ -2694,8 +2690,6 @@ void CodeGenerator::VisitCall(Call* node) {
ZoneList<Expression*>* args = node->arguments(); ZoneList<Expression*>* args = node->arguments();
CodeForStatementPosition(node);
// Check if the function is a variable or a property. // Check if the function is a variable or a property.
Expression* function = node->expression(); Expression* function = node->expression();
Variable* var = function->AsVariableProxy()->AsVariable(); Variable* var = function->AsVariableProxy()->AsVariable();
...@@ -2855,8 +2849,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) { ...@@ -2855,8 +2849,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) {
ZoneList<Expression*>* args = node->arguments(); ZoneList<Expression*>* args = node->arguments();
Expression* function = node->expression(); Expression* function = node->expression();
CodeForStatementPosition(node);
// Prepare the stack for the call to the resolved function. // Prepare the stack for the call to the resolved function.
Load(function); Load(function);
...@@ -2908,7 +2900,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) { ...@@ -2908,7 +2900,6 @@ void CodeGenerator::VisitCallEval(CallEval* node) {
void CodeGenerator::VisitCallNew(CallNew* node) { void CodeGenerator::VisitCallNew(CallNew* node) {
Comment cmnt(masm_, "[ CallNew"); Comment cmnt(masm_, "[ CallNew");
CodeForStatementPosition(node);
// According to ECMA-262, section 11.2.2, page 44, the function // According to ECMA-262, section 11.2.2, page 44, the function
// expression in new calls must be evaluated before the // expression in new calls must be evaluated before the
......
...@@ -553,7 +553,7 @@ class CodeGenerator: public AstVisitor { ...@@ -553,7 +553,7 @@ class CodeGenerator: public AstVisitor {
// information. // information.
void CodeForFunctionPosition(FunctionLiteral* fun); void CodeForFunctionPosition(FunctionLiteral* fun);
void CodeForReturnPosition(FunctionLiteral* fun); void CodeForReturnPosition(FunctionLiteral* fun);
void CodeForStatementPosition(AstNode* node); void CodeForStatementPosition(Statement* node);
void CodeForSourcePosition(int pos); void CodeForSourcePosition(int pos);
#ifdef DEBUG #ifdef DEBUG
......
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