Index: src/rewriter.cc |
=================================================================== |
--- src/rewriter.cc (revision 4129) |
+++ src/rewriter.cc (working copy) |
@@ -220,6 +220,7 @@ |
void AstOptimizer::VisitConditional(Conditional* node) { |
+ node->condition()->set_no_negative_zero(true); |
Visit(node->condition()); |
Visit(node->then_expression()); |
Visit(node->else_expression()); |
@@ -319,6 +320,7 @@ |
node->type()->SetAsLikelySmiIfUnknown(); |
node->target()->type()->SetAsLikelySmiIfUnknown(); |
node->value()->type()->SetAsLikelySmiIfUnknown(); |
+ node->value()->set_no_negative_zero(true); |
break; |
case Token::ASSIGN_ADD: |
case Token::ASSIGN_SUB: |
@@ -393,6 +395,7 @@ |
void AstOptimizer::VisitProperty(Property* node) { |
+ node->key()->set_no_negative_zero(true); |
Visit(node->obj()); |
Visit(node->key()); |
} |
@@ -422,6 +425,11 @@ |
void AstOptimizer::VisitUnaryOperation(UnaryOperation* node) { |
+ if (node->op() == Token::ADD || node->op() == Token::SUB) { |
+ node->expression()->set_no_negative_zero(node->no_negative_zero()); |
+ } else { |
+ node->expression()->set_no_negative_zero(true); |
+ } |
Visit(node->expression()); |
if (FLAG_safe_int32_compiler) { |
switch (node->op()) { |
@@ -449,6 +457,9 @@ |
void AstOptimizer::VisitCountOperation(CountOperation* node) { |
// Count operations assume that they work on Smis. |
+ node->expression()->set_no_negative_zero(node->is_prefix() ? |
+ true : |
+ node->no_negative_zero()); |
node->type()->SetAsLikelySmiIfUnknown(); |
node->expression()->type()->SetAsLikelySmiIfUnknown(); |
Visit(node->expression()); |
@@ -461,7 +472,12 @@ |
switch (node->op()) { |
case Token::COMMA: |
case Token::OR: |
+ node->left()->set_no_negative_zero(true); |
+ node->right()->set_no_negative_zero(node->no_negative_zero()); |
+ break; |
case Token::AND: |
+ node->left()->set_no_negative_zero(node->no_negative_zero()); |
+ node->right()->set_no_negative_zero(node->no_negative_zero()); |
break; |
case Token::BIT_OR: |
case Token::BIT_XOR: |
@@ -474,6 +490,8 @@ |
node->right()->type()->SetAsLikelySmiIfUnknown(); |
node->left()->set_to_int32(true); |
node->right()->set_to_int32(true); |
+ node->left()->set_no_negative_zero(true); |
+ node->right()->set_no_negative_zero(true); |
break; |
case Token::ADD: |
case Token::SUB: |
@@ -484,6 +502,13 @@ |
node->left()->type()->SetAsLikelySmiIfUnknown(); |
node->right()->type()->SetAsLikelySmiIfUnknown(); |
} |
+ node->left()->set_no_negative_zero(node->no_negative_zero()); |
+ node->right()->set_no_negative_zero(node->no_negative_zero()); |
+ if (node->op() == Token::DIV) { |
+ node->right()->set_no_negative_zero(false); |
+ } else if (node->op() == Token::MOD) { |
+ node->right()->set_no_negative_zero(true); |
+ } |
break; |
default: |
UNREACHABLE(); |
@@ -551,6 +576,10 @@ |
node->right()->type()->SetAsLikelySmiIfUnknown(); |
} |
+ node->left()->set_no_negative_zero(true); |
+ // Only [[HasInstance]] has the right argument passed unchanged to it. |
+ node->right()->set_no_negative_zero(true); |
+ |
Visit(node->left()); |
Visit(node->right()); |