Revision: 7524
Author: [email protected]
Date: Thu Apr 7 00:56:43 2011
Log: Remove unnecessary AST node for ++ and -- operations.
Instead of adding an extra AST node we can just use an auxiliary
bailout id for named and keyed property count operations.
Review URL: http://codereview.chromium.org/6810015
http://code.google.com/p/v8/source/detail?r=7524
Modified:
/branches/bleeding_edge/src/arm/full-codegen-arm.cc
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/codegen.cc
/branches/bleeding_edge/src/data-flow.cc
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/prettyprinter.cc
/branches/bleeding_edge/src/rewriter.cc
/branches/bleeding_edge/src/x64/full-codegen-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Fri Apr 1 12:46:21
2011
+++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu Apr 7 00:56:43
2011
@@ -3885,7 +3885,7 @@
if (assign_type == VARIABLE) {
PrepareForBailout(expr->expression(), TOS_REG);
} else {
- PrepareForBailout(expr->increment(), TOS_REG);
+ PrepareForBailoutForId(expr->CountId(), TOS_REG);
}
// Call ToNumber only if operand is not a smi.
=======================================
--- /branches/bleeding_edge/src/ast.h Fri Apr 1 12:46:21 2011
+++ /branches/bleeding_edge/src/ast.h Thu Apr 7 00:56:43 2011
@@ -88,7 +88,6 @@
V(CallNew) \
V(CallRuntime) \
V(UnaryOperation) \
- V(IncrementOperation) \
V(CountOperation) \
V(BinaryOperation) \
V(CompareOperation) \
@@ -1487,45 +1486,27 @@
};
-class IncrementOperation: public Expression {
- public:
- IncrementOperation(Token::Value op, Expression* expr)
- : op_(op), expression_(expr) {
- ASSERT(Token::IsCountOp(op));
- }
-
- DECLARE_NODE_TYPE(IncrementOperation)
-
- Token::Value op() const { return op_; }
- bool is_increment() { return op_ == Token::INC; }
- Expression* expression() const { return expression_; }
-
- private:
- Token::Value op_;
- Expression* expression_;
- int pos_;
-};
-
-
class CountOperation: public Expression {
public:
- CountOperation(bool is_prefix, IncrementOperation* increment, int pos)
- : is_prefix_(is_prefix), increment_(increment), pos_(pos),
- assignment_id_(GetNextId()) {
- }
+ CountOperation(Token::Value op, bool is_prefix, Expression* expr, int
pos)
+ : op_(op),
+ is_prefix_(is_prefix),
+ expression_(expr),
+ pos_(pos),
+ assignment_id_(GetNextId()),
+ count_id_(GetNextId()) { }
DECLARE_NODE_TYPE(CountOperation)
bool is_prefix() const { return is_prefix_; }
bool is_postfix() const { return !is_prefix_; }
- Token::Value op() const { return increment_->op(); }
+ Token::Value op() const { return op_; }
Token::Value binary_op() {
return (op() == Token::INC) ? Token::ADD : Token::SUB;
}
- Expression* expression() const { return increment_->expression(); }
- IncrementOperation* increment() const { return increment_; }
+ Expression* expression() const { return expression_; }
int position() const { return pos_; }
virtual void MarkAsStatement() { is_prefix_ = true; }
@@ -1534,12 +1515,15 @@
// Bailout support.
int AssignmentId() const { return assignment_id_; }
+ int CountId() const { return count_id_; }
private:
+ Token::Value op_;
bool is_prefix_;
- IncrementOperation* increment_;
+ Expression* expression_;
int pos_;
int assignment_id_;
+ int count_id_;
};
=======================================
--- /branches/bleeding_edge/src/codegen.cc Fri Apr 1 07:46:30 2011
+++ /branches/bleeding_edge/src/codegen.cc Thu Apr 7 00:56:43 2011
@@ -356,11 +356,6 @@
// declaration the global variables and functions.
DeclareGlobals(array);
}
-
-
-void CodeGenerator::VisitIncrementOperation(IncrementOperation* expr) {
- UNREACHABLE();
-}
// Lookup table for code generators for special runtime calls which are
=======================================
--- /branches/bleeding_edge/src/data-flow.cc Tue Dec 7 03:31:57 2010
+++ /branches/bleeding_edge/src/data-flow.cc Thu Apr 7 00:56:43 2011
@@ -488,12 +488,6 @@
MarkIfTrivial(expr->expression());
Visit(expr->expression());
}
-
-
-void AssignedVariablesAnalyzer::VisitIncrementOperation(
- IncrementOperation* expr) {
- UNREACHABLE();
-}
void AssignedVariablesAnalyzer::VisitCountOperation(CountOperation* expr) {
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Fri Apr 1 07:46:30 2011
+++ /branches/bleeding_edge/src/full-codegen.cc Thu Apr 7 00:56:43 2011
@@ -211,12 +211,6 @@
// Throw is breakable if the expression is.
Visit(expr->exception());
}
-
-
-void BreakableStatementChecker::VisitIncrementOperation(
- IncrementOperation* expr) {
- UNREACHABLE();
-}
void BreakableStatementChecker::VisitProperty(Property* expr) {
@@ -1355,11 +1349,6 @@
__ CallRuntime(Runtime::kThrow, 1);
// Never returns here.
}
-
-
-void FullCodeGenerator::VisitIncrementOperation(IncrementOperation* expr) {
- UNREACHABLE();
-}
int FullCodeGenerator::TryFinally::Exit(int stack_depth) {
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Tue Apr 5 11:47:46 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Apr 7 00:56:43 2011
@@ -4610,13 +4610,6 @@
ast_context()->ReturnInstruction(instr, expr->id());
}
}
-
-
-void HGraphBuilder::VisitIncrementOperation(IncrementOperation* expr) {
- // IncrementOperation is never visited by the visitor. It only
- // occurs as a subexpression of CountOperation.
- UNREACHABLE();
-}
HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment)
{
@@ -4630,8 +4623,7 @@
void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
- IncrementOperation* increment = expr->increment();
- Expression* target = increment->expression();
+ Expression* target = expr->expression();
VariableProxy* proxy = target->AsVariableProxy();
Variable* var = proxy->AsVariable();
Property* prop = target->AsProperty();
@@ -4692,7 +4684,7 @@
load = BuildLoadNamedGeneric(obj, prop);
}
PushAndAdd(load);
- if (load->HasSideEffects()) AddSimulate(increment->id());
+ if (load->HasSideEffects()) AddSimulate(expr->CountId());
HValue* before = Pop();
// There is no deoptimization to after the increment, so we don't
need
@@ -4733,7 +4725,7 @@
? BuildLoadKeyedFastElement(obj, key, prop)
: BuildLoadKeyedGeneric(obj, key);
PushAndAdd(load);
- if (load->HasSideEffects()) AddSimulate(increment->id());
+ if (load->HasSideEffects()) AddSimulate(expr->CountId());
HValue* before = Pop();
// There is no deoptimization to after the increment, so we don't
need
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Fri Apr 1
12:46:21 2011
+++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu Apr 7
00:56:43 2011
@@ -3835,7 +3835,7 @@
if (assign_type == VARIABLE) {
PrepareForBailout(expr->expression(), TOS_REG);
} else {
- PrepareForBailout(expr->increment(), TOS_REG);
+ PrepareForBailoutForId(expr->CountId(), TOS_REG);
}
// Call ToNumber only if operand is not a smi.
=======================================
--- /branches/bleeding_edge/src/parser.cc Sun Apr 3 23:29:02 2011
+++ /branches/bleeding_edge/src/parser.cc Thu Apr 7 00:56:43 2011
@@ -2593,9 +2593,10 @@
}
int position = scanner().location().beg_pos;
- IncrementOperation* increment =
- new(zone()) IncrementOperation(op, expression);
- return new(zone()) CountOperation(true /* prefix */, increment,
position);
+ return new(zone()) CountOperation(op,
+ true /* prefix */,
+ expression,
+ position);
} else {
return ParsePostfixExpression(ok);
@@ -2627,10 +2628,11 @@
Token::Value next = Next();
int position = scanner().location().beg_pos;
- IncrementOperation* increment =
- new(zone()) IncrementOperation(next, expression);
expression =
- new(zone()) CountOperation(false /* postfix */, increment,
position);
+ new(zone()) CountOperation(next,
+ false /* postfix */,
+ expression,
+ position);
}
return expression;
}
=======================================
--- /branches/bleeding_edge/src/prettyprinter.cc Fri Mar 25 04:53:29 2011
+++ /branches/bleeding_edge/src/prettyprinter.cc Thu Apr 7 00:56:43 2011
@@ -374,11 +374,6 @@
Visit(node->expression());
Print(")");
}
-
-
-void PrettyPrinter::VisitIncrementOperation(IncrementOperation* node) {
- UNREACHABLE();
-}
void PrettyPrinter::VisitCountOperation(CountOperation* node) {
@@ -1054,11 +1049,6 @@
void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
PrintIndentedVisit(Token::Name(node->op()), node->expression());
}
-
-
-void AstPrinter::VisitIncrementOperation(IncrementOperation* node) {
- UNREACHABLE();
-}
void AstPrinter::VisitCountOperation(CountOperation* node) {
@@ -1459,11 +1449,6 @@
}
Visit(expr->expression());
}
-
-
-void JsonAstBuilder::VisitIncrementOperation(IncrementOperation* expr) {
- UNREACHABLE();
-}
void JsonAstBuilder::VisitCountOperation(CountOperation* expr) {
=======================================
--- /branches/bleeding_edge/src/rewriter.cc Fri Mar 18 13:35:07 2011
+++ /branches/bleeding_edge/src/rewriter.cc Thu Apr 7 00:56:43 2011
@@ -430,11 +430,6 @@
node->expression()->set_to_int32(true);
}
}
-
-
-void AstOptimizer::VisitIncrementOperation(IncrementOperation* node) {
- UNREACHABLE();
-}
void AstOptimizer::VisitCountOperation(CountOperation* node) {
@@ -941,11 +936,6 @@
USE(node);
UNREACHABLE();
}
-
-
-void Processor::VisitIncrementOperation(IncrementOperation* node) {
- UNREACHABLE();
-}
void Processor::VisitCountOperation(CountOperation* node) {
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Fri Apr 1 12:46:21
2011
+++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu Apr 7 00:56:43
2011
@@ -3811,7 +3811,7 @@
if (assign_type == VARIABLE) {
PrepareForBailout(expr->expression(), TOS_REG);
} else {
- PrepareForBailout(expr->increment(), TOS_REG);
+ PrepareForBailoutForId(expr->CountId(), TOS_REG);
}
// Call ToNumber only if operand is not a smi.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev