| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index 34ecfa34b58b342399052df6ef589f33fe17eb6c..61ce567f11a3e44834ab370db6542e1a71082122 100644
|
| --- a/src/hydrogen.cc
|
| +++ b/src/hydrogen.cc
|
| @@ -7631,10 +7631,10 @@ static bool ShiftAmountsAllowReplaceByRotate(HValue* sa,
|
| // directions that can be replaced by one rotate right instruction or not.
|
| // Returns the operand and the shift amount for the rotate instruction in the
|
| // former case.
|
| -bool HOptimizedGraphBuilder::MatchRotateRight(HValue* left,
|
| - HValue* right,
|
| - HValue** operand,
|
| - HValue** shift_amount) {
|
| +bool HGraphBuilder::MatchRotateRight(HValue* left,
|
| + HValue* right,
|
| + HValue** operand,
|
| + HValue** shift_amount) {
|
| HShl* shl;
|
| HShr* shr;
|
| if (left->IsShl() && right->IsShr()) {
|
| @@ -7697,6 +7697,7 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) {
|
| if_nan.Then();
|
| if_nan.ElseDeopt();
|
| if_nan.End();
|
| + *expected = handle(Type::Double(), isolate());
|
| return Add<HConstant>(OS::nan_value());
|
| }
|
|
|
| @@ -7713,14 +7714,28 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
|
| Handle<Type> right_type = expr->right()->bounds().lower;
|
| Handle<Type> result_type = expr->bounds().lower;
|
| Maybe<int> fixed_right_arg = expr->fixed_right_arg();
|
| +
|
| + return HGraphBuilder::BuildBinaryOperation(expr->op(), left, right,
|
| + left_type, right_type, result_type, fixed_right_arg, context);
|
| +}
|
| +
|
| +
|
| +HInstruction* HGraphBuilder::BuildBinaryOperation(
|
| + Token::Value op,
|
| + HValue* left,
|
| + HValue* right,
|
| + Handle<Type> left_type,
|
| + Handle<Type> right_type,
|
| + Handle<Type> result_type,
|
| + Maybe<int> fixed_right_arg,
|
| + HValue* context) {
|
| Representation left_rep = Representation::FromType(left_type);
|
| Representation right_rep = Representation::FromType(right_type);
|
| Representation result_rep = Representation::FromType(result_type);
|
|
|
| - if (expr->op() != Token::ADD ||
|
| - (left->type().IsNonString() && right->type().IsNonString())) {
|
| - // For addition we can only truncate the arguments to number if we can
|
| - // prove that we will not end up in string concatenation mode.
|
| + bool maybe_string = left_type->Maybe(Type::String()) ||
|
| + right_type->Maybe(Type::String());
|
| + if (op != Token::ADD || !maybe_string) {
|
| left = TruncateToNumber(left, &left_type);
|
| right = TruncateToNumber(right, &right_type);
|
| }
|
| @@ -7735,7 +7750,7 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
|
| right_type = handle(Type::Any(), isolate());
|
| }
|
| HInstruction* instr = NULL;
|
| - switch (expr->op()) {
|
| + switch (op) {
|
| case Token::ADD:
|
| if (left_type->Is(Type::String()) && right_type->Is(Type::String())) {
|
| BuildCheckHeapObject(left);
|
| @@ -7761,7 +7776,7 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
|
| break;
|
| case Token::BIT_XOR:
|
| case Token::BIT_AND:
|
| - instr = NewUncasted<HBitwise>(expr->op(), left, right);
|
| + instr = NewUncasted<HBitwise>(op, left, right);
|
| break;
|
| case Token::BIT_OR: {
|
| HValue* operand, *shift_amount;
|
| @@ -7770,7 +7785,7 @@ HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
|
| MatchRotateRight(left, right, &operand, &shift_amount)) {
|
| instr = new(zone()) HRor(context, operand, shift_amount);
|
| } else {
|
| - instr = NewUncasted<HBitwise>(expr->op(), left, right);
|
| + instr = NewUncasted<HBitwise>(op, left, right);
|
| }
|
| break;
|
| }
|
|
|