Simplify IA32 code generator API.

Cut down on the number of arguments passed to the various binary operation
code generator functions by passing along the expression itself, rather than
a subset of its fields.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4319 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6d3cdbbf
...@@ -852,13 +852,11 @@ UnaryOperation::UnaryOperation(UnaryOperation* other, Expression* expression) ...@@ -852,13 +852,11 @@ UnaryOperation::UnaryOperation(UnaryOperation* other, Expression* expression)
: Expression(other), op_(other->op_), expression_(expression) {} : Expression(other), op_(other->op_), expression_(expression) {}
BinaryOperation::BinaryOperation(BinaryOperation* other, BinaryOperation::BinaryOperation(Expression* other,
Token::Value op,
Expression* left, Expression* left,
Expression* right) Expression* right)
: Expression(other), : Expression(other), op_(op), left_(left), right_(right) {}
op_(other->op_),
left_(left),
right_(right) {}
CountOperation::CountOperation(CountOperation* other, Expression* expression) CountOperation::CountOperation(CountOperation* other, Expression* expression)
...@@ -1110,6 +1108,7 @@ void CopyAstVisitor::VisitCountOperation(CountOperation* expr) { ...@@ -1110,6 +1108,7 @@ void CopyAstVisitor::VisitCountOperation(CountOperation* expr) {
void CopyAstVisitor::VisitBinaryOperation(BinaryOperation* expr) { void CopyAstVisitor::VisitBinaryOperation(BinaryOperation* expr) {
expr_ = new BinaryOperation(expr, expr_ = new BinaryOperation(expr,
expr->op(),
DeepCopyExpr(expr->left()), DeepCopyExpr(expr->left()),
DeepCopyExpr(expr->right())); DeepCopyExpr(expr->right()));
} }
......
...@@ -1369,7 +1369,13 @@ class BinaryOperation: public Expression { ...@@ -1369,7 +1369,13 @@ class BinaryOperation: public Expression {
ASSERT(Token::IsBinaryOp(op)); ASSERT(Token::IsBinaryOp(op));
} }
BinaryOperation(BinaryOperation* other, Expression* left, Expression* right); // Construct a binary operation with a given operator and left and right
// subexpressions. The rest of the expression state is copied from
// another expression.
BinaryOperation(Expression* other,
Token::Value op,
Expression* left,
Expression* right);
virtual void Accept(AstVisitor* v); virtual void Accept(AstVisitor* v);
......
This diff is collapsed.
...@@ -492,11 +492,8 @@ class CodeGenerator: public AstVisitor { ...@@ -492,11 +492,8 @@ class CodeGenerator: public AstVisitor {
// Generate code that computes a shortcutting logical operation. // Generate code that computes a shortcutting logical operation.
void GenerateLogicalBooleanOperation(BinaryOperation* node); void GenerateLogicalBooleanOperation(BinaryOperation* node);
void GenericBinaryOperation( void GenericBinaryOperation(BinaryOperation* expr,
Token::Value op, OverwriteMode overwrite_mode);
StaticType* type,
OverwriteMode overwrite_mode,
bool no_negative_zero);
// If possible, combine two constant smi values using op to produce // If possible, combine two constant smi values using op to produce
// a smi result, and push it on the virtual frame, all at compile time. // a smi result, and push it on the virtual frame, all at compile time.
...@@ -505,22 +502,19 @@ class CodeGenerator: public AstVisitor { ...@@ -505,22 +502,19 @@ class CodeGenerator: public AstVisitor {
// Emit code to perform a binary operation on a constant // Emit code to perform a binary operation on a constant
// smi and a likely smi. Consumes the Result operand. // smi and a likely smi. Consumes the Result operand.
Result ConstantSmiBinaryOperation(Token::Value op, Result ConstantSmiBinaryOperation(BinaryOperation* expr,
Result* operand, Result* operand,
Handle<Object> constant_operand, Handle<Object> constant_operand,
StaticType* type,
bool reversed, bool reversed,
OverwriteMode overwrite_mode, OverwriteMode overwrite_mode);
bool no_negative_zero);
// Emit code to perform a binary operation on two likely smis. // Emit code to perform a binary operation on two likely smis.
// The code to handle smi arguments is produced inline. // The code to handle smi arguments is produced inline.
// Consumes the Results left and right. // Consumes the Results left and right.
Result LikelySmiBinaryOperation(Token::Value op, Result LikelySmiBinaryOperation(BinaryOperation* expr,
Result* left, Result* left,
Result* right, Result* right,
OverwriteMode overwrite_mode, OverwriteMode overwrite_mode);
bool no_negative_zero);
// Emit code to perform a binary operation on two untagged int32 values. // Emit code to perform a binary operation on two untagged int32 values.
......
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