| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index 45fbbc09821824998595b84291389a3bf214bfd0..4bfb91c1108245716adbbb6f19c1f32b49ead887 100644
|
| --- a/src/hydrogen.cc
|
| +++ b/src/hydrogen.cc
|
| @@ -1283,8 +1283,7 @@ void HGraphBuilder::BuildTransitionElementsKind(HValue* object,
|
|
|
|
|
| HValue* HGraphBuilder::BuildLookupNumberStringCache(
|
| - HValue* object,
|
| - HIfContinuation* continuation) {
|
| + HValue* object, ToStringMode mode, HIfContinuation* continuation) {
|
| // Create a joinable continuation.
|
| HIfContinuation found(graph()->CreateBasicBlock(),
|
| graph()->CreateBasicBlock());
|
| @@ -1366,6 +1365,10 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache(
|
| }
|
| if_keyeqobject.JoinContinuation(&found);
|
| }
|
| + if (mode == CHECK_NUMBER) {
|
| + if_objectisnumber.Else();
|
| + if_objectisnumber.Deopt("Expected Argument to be Numeric");
|
| + }
|
| if_keyisnumber.JoinContinuation(&found);
|
| }
|
| if_objectisnumber.JoinContinuation(&found);
|
| @@ -1391,12 +1394,12 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache(
|
| }
|
|
|
|
|
| -HValue* HGraphBuilder::BuildNumberToString(HValue* number) {
|
| +HValue* HGraphBuilder::BuildNumberToString(HValue* number, ToStringMode mode) {
|
| NoObservableSideEffectsScope scope(this);
|
|
|
| // Lookup the number in the number string cache.
|
| HIfContinuation continuation;
|
| - HValue* value = BuildLookupNumberStringCache(number, &continuation);
|
| + HValue* value = BuildLookupNumberStringCache(number, mode, &continuation);
|
| IfBuilder if_found(this, &continuation);
|
| if_found.Then();
|
|
|
| @@ -7909,17 +7912,25 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(
|
| switch (op) {
|
| case Token::ADD:
|
| if (is_string_add) {
|
| - StringAddFlags flags = STRING_ADD_CHECK_BOTH;
|
| + StringAddFlags flags = STRING_ADD_CHECK_NONE;
|
| if (left_type->Is(Type::String())) {
|
| BuildCheckHeapObject(left);
|
| AddInstruction(HCheckInstanceType::NewIsString(left, zone()));
|
| - flags = STRING_ADD_CHECK_RIGHT;
|
| + if (right_type->Is(Type::Number())) {
|
| + right = BuildNumberToString(right, CHECK_NUMBER);
|
| + } else {
|
| + flags = STRING_ADD_CHECK_RIGHT;
|
| + }
|
| }
|
| if (right_type->Is(Type::String())) {
|
| + if (left_type->Is(Type::Number())) {
|
| + left = BuildNumberToString(left, CHECK_NUMBER);
|
| + } else {
|
| + flags = (flags == STRING_ADD_CHECK_RIGHT)
|
| + ? STRING_ADD_CHECK_NONE : STRING_ADD_CHECK_LEFT;
|
| + }
|
| BuildCheckHeapObject(right);
|
| AddInstruction(HCheckInstanceType::NewIsString(right, zone()));
|
| - flags = (flags == STRING_ADD_CHECK_BOTH)
|
| - ? STRING_ADD_CHECK_LEFT : STRING_ADD_CHECK_NONE;
|
| }
|
| instr = NewUncasted<HStringAdd>(left, right, flags);
|
| } else {
|
| @@ -9124,7 +9135,7 @@ void HOptimizedGraphBuilder::GenerateNumberToString(CallRuntime* call) {
|
| ASSERT_EQ(1, call->arguments()->length());
|
| CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
|
| HValue* number = Pop();
|
| - HValue* result = BuildNumberToString(number);
|
| + HValue* result = BuildNumberToString(number, ALLOW_SIDE_EFFECTS);
|
| return ast_context()->ReturnValue(result);
|
| }
|
|
|
|
|