Revision: 17184
Author: rossb...@chromium.org
Date: Mon Oct 14 09:41:41 2013 UTC
Log: Unify handling of position info in AST, part 2
* Eliminate Conditional::then/else_position and
WhileStatement::condition_position.
R=yang...@chromium.org
BUG=
Review URL: https://codereview.chromium.org/23597037
http://code.google.com/p/v8/source/detail?r=17184
Modified:
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/full-codegen.h
/branches/bleeding_edge/src/parser.cc
=======================================
--- /branches/bleeding_edge/src/ast.h Mon Oct 14 09:24:58 2013 UTC
+++ /branches/bleeding_edge/src/ast.h Mon Oct 14 09:41:41 2013 UTC
@@ -255,7 +255,6 @@
class Statement : public AstNode {
public:
- // TODO(rossberg)
explicit Statement(int position) : AstNode(position) {}
bool IsEmpty() { return AsEmptyStatement() != NULL; }
@@ -764,12 +763,6 @@
}
Expression* cond() const { return cond_; }
-
- // TODO(rossberg): get rid of this.
- // Position where condition expression starts. We need it to make
- // the loop's condition a breakable location.
- int condition_position() { return condition_position_; }
- void set_condition_position(int pos) { condition_position_ = pos; }
virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
virtual BailoutId StackCheckId() const V8_OVERRIDE { return
back_edge_id_; }
@@ -779,7 +772,6 @@
DoWhileStatement(Isolate* isolate, ZoneStringList* labels, int pos)
: IterationStatement(isolate, labels, pos),
cond_(NULL),
- condition_position_(-1),
continue_id_(GetNextId(isolate)),
back_edge_id_(GetNextId(isolate)) {
}
@@ -787,8 +779,6 @@
private:
Expression* cond_;
- int condition_position_;
-
const BailoutId continue_id_;
const BailoutId back_edge_id_;
};
@@ -2057,10 +2047,6 @@
Expression* condition() const { return condition_; }
Expression* then_expression() const { return then_expression_; }
Expression* else_expression() const { return else_expression_; }
-
- // TODO(rossberg): get rid of this.
- int then_expression_position() const { return then_expression_position_;
}
- int else_expression_position() const { return else_expression_position_;
}
BailoutId ThenId() const { return then_id_; }
BailoutId ElseId() const { return else_id_; }
@@ -2070,15 +2056,11 @@
Expression* condition,
Expression* then_expression,
Expression* else_expression,
- int then_expression_position,
- int else_expression_position,
int position)
: Expression(isolate, position),
condition_(condition),
then_expression_(then_expression),
else_expression_(else_expression),
- then_expression_position_(then_expression_position),
- else_expression_position_(else_expression_position),
then_id_(GetNextId(isolate)),
else_id_(GetNextId(isolate)) { }
@@ -2086,8 +2068,6 @@
Expression* condition_;
Expression* then_expression_;
Expression* else_expression_;
- int then_expression_position_;
- int else_expression_position_;
const BailoutId then_id_;
const BailoutId else_id_;
};
@@ -3192,12 +3172,9 @@
Conditional* NewConditional(Expression* condition,
Expression* then_expression,
Expression* else_expression,
- int then_expression_position,
- int else_expression_position,
int position) {
Conditional* cond = new(zone_) Conditional(
- isolate_, condition, then_expression, else_expression,
- then_expression_position, else_expression_position, position);
+ isolate_, condition, then_expression, else_expression, position);
VISIT_AND_RETURN(Conditional, cond)
}
@@ -3251,9 +3228,8 @@
return lit;
}
- NativeFunctionLiteral* NewNativeFunctionLiteral(Handle<String> name,
- v8::Extension* extension,
- int pos) {
+ NativeFunctionLiteral* NewNativeFunctionLiteral(
+ Handle<String> name, v8::Extension* extension, int pos) {
NativeFunctionLiteral* lit =
new(zone_) NativeFunctionLiteral(isolate_, name, extension, pos);
VISIT_AND_RETURN(NativeFunctionLiteral, lit)
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Mon Oct 14 09:24:58 2013 UTC
+++ /branches/bleeding_edge/src/full-codegen.cc Mon Oct 14 09:41:41 2013 UTC
@@ -849,10 +849,10 @@
}
-void FullCodeGenerator::SetExpressionPosition(Expression* expr, int pos) {
+void FullCodeGenerator::SetExpressionPosition(Expression* expr) {
#ifdef ENABLE_DEBUGGER_SUPPORT
if (!isolate()->debugger()->IsDebuggerActive()) {
- CodeGenerator::RecordPositions(masm_, pos);
+ CodeGenerator::RecordPositions(masm_, expr->position());
} else {
// Check if the expression will be breakable without adding a debug
break
// slot.
@@ -866,7 +866,7 @@
// statement positions this is used for e.g. the condition expression
of
// a do while loop.
bool position_recorded = CodeGenerator::RecordPositions(
- masm_, pos, !checker.is_breakable());
+ masm_, expr->position(), !checker.is_breakable());
// If the position recording did record a new position generate a debug
// break slot to make the statement breakable.
if (position_recorded) {
@@ -1293,7 +1293,7 @@
// possible to break on the condition.
__ bind(loop_statement.continue_label());
PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS);
- SetExpressionPosition(stmt->cond(), stmt->condition_position());
+ SetExpressionPosition(stmt->cond());
VisitForControl(stmt->cond(),
&book_keeping,
loop_statement.break_label(),
@@ -1522,8 +1522,7 @@
PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS);
__ bind(&true_case);
- SetExpressionPosition(expr->then_expression(),
- expr->then_expression_position());
+ SetExpressionPosition(expr->then_expression());
if (context()->IsTest()) {
const TestContext* for_test = TestContext::cast(context());
VisitForControl(expr->then_expression(),
@@ -1537,8 +1536,7 @@
PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS);
__ bind(&false_case);
- SetExpressionPosition(expr->else_expression(),
- expr->else_expression_position());
+ SetExpressionPosition(expr->else_expression());
VisitInDuplicateContext(expr->else_expression());
// If control flow falls through Visit, merge it with true case here.
if (!context()->IsTest()) {
=======================================
--- /branches/bleeding_edge/src/full-codegen.h Wed Sep 25 08:26:11 2013 UTC
+++ /branches/bleeding_edge/src/full-codegen.h Mon Oct 14 09:41:41 2013 UTC
@@ -576,7 +576,7 @@
void SetFunctionPosition(FunctionLiteral* fun);
void SetReturnPosition(FunctionLiteral* fun);
void SetStatementPosition(Statement* stmt);
- void SetExpressionPosition(Expression* expr, int pos);
+ void SetExpressionPosition(Expression* expr);
void SetStatementPosition(int pos);
void SetSourcePosition(int pos);
=======================================
--- /branches/bleeding_edge/src/parser.cc Mon Oct 14 09:24:58 2013 UTC
+++ /branches/bleeding_edge/src/parser.cc Mon Oct 14 09:41:41 2013 UTC
@@ -2571,8 +2571,6 @@
Expect(Token::WHILE, CHECK_OK);
Expect(Token::LPAREN, CHECK_OK);
- if (loop != NULL) loop->set_condition_position(position());
-
Expression* cond = ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
@@ -3024,13 +3022,10 @@
// In parsing the first assignment expression in conditional
// expressions we always accept the 'in' keyword; see ECMA-262,
// section 11.12, page 58.
- int left_position = peek_position();
Expression* left = ParseAssignmentExpression(true, CHECK_OK);
Expect(Token::COLON, CHECK_OK);
- int right_position = peek_position();
Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
- return factory()->NewConditional(
- expression, left, right, left_position, right_position, pos);
+ return factory()->NewConditional(expression, left, right, pos);
}
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.