OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 7812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7823 Deoptimizer::SOFT); | 7823 Deoptimizer::SOFT); |
7824 right_type = handle(Type::Any(), isolate()); | 7824 right_type = handle(Type::Any(), isolate()); |
7825 } else { | 7825 } else { |
7826 if (!maybe_string_add) right = TruncateToNumber(right, &right_type); | 7826 if (!maybe_string_add) right = TruncateToNumber(right, &right_type); |
7827 right_rep = Representation::FromType(right_type); | 7827 right_rep = Representation::FromType(right_type); |
7828 } | 7828 } |
7829 | 7829 |
7830 // Special case for string addition here. | 7830 // Special case for string addition here. |
7831 if (op == Token::ADD && | 7831 if (op == Token::ADD && |
7832 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { | 7832 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { |
| 7833 // Validate type feedback for left argument. |
7833 if (left_type->Is(Type::String())) { | 7834 if (left_type->Is(Type::String())) { |
7834 IfBuilder if_isstring(this); | 7835 IfBuilder if_isstring(this); |
7835 if_isstring.If<HIsStringAndBranch>(left); | 7836 if_isstring.If<HIsStringAndBranch>(left); |
7836 if_isstring.Then(); | 7837 if_isstring.Then(); |
7837 if_isstring.ElseDeopt("Expected string for LHS of binary operation"); | 7838 if_isstring.ElseDeopt("Expected string for LHS of binary operation"); |
7838 } else if (left_type->Is(Type::Number())) { | 7839 } |
| 7840 |
| 7841 // Validate type feedback for right argument. |
| 7842 if (right_type->Is(Type::String())) { |
| 7843 IfBuilder if_isstring(this); |
| 7844 if_isstring.If<HIsStringAndBranch>(right); |
| 7845 if_isstring.Then(); |
| 7846 if_isstring.ElseDeopt("Expected string for RHS of binary operation"); |
| 7847 } |
| 7848 |
| 7849 // Convert left argument as necessary. |
| 7850 if (left_type->Is(Type::Number())) { |
| 7851 ASSERT(right_type->Is(Type::String())); |
7839 left = BuildNumberToString(left, left_type); | 7852 left = BuildNumberToString(left, left_type); |
7840 } else { | 7853 } else if (!left_type->Is(Type::String())) { |
7841 ASSERT(right_type->Is(Type::String())); | 7854 ASSERT(right_type->Is(Type::String())); |
7842 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); | 7855 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); |
7843 Add<HPushArgument>(left); | 7856 Add<HPushArgument>(left); |
7844 Add<HPushArgument>(right); | 7857 Add<HPushArgument>(right); |
7845 return NewUncasted<HInvokeFunction>(function, 2); | 7858 return NewUncasted<HInvokeFunction>(function, 2); |
7846 } | 7859 } |
7847 | 7860 |
7848 if (right_type->Is(Type::String())) { | 7861 // Convert right argument as necessary. |
7849 IfBuilder if_isstring(this); | 7862 if (right_type->Is(Type::Number())) { |
7850 if_isstring.If<HIsStringAndBranch>(right); | 7863 ASSERT(left_type->Is(Type::String())); |
7851 if_isstring.Then(); | |
7852 if_isstring.ElseDeopt("Expected string for RHS of binary operation"); | |
7853 } else if (right_type->Is(Type::Number())) { | |
7854 right = BuildNumberToString(right, right_type); | 7864 right = BuildNumberToString(right, right_type); |
7855 } else { | 7865 } else if (!right_type->Is(Type::String())) { |
7856 ASSERT(left_type->Is(Type::String())); | 7866 ASSERT(left_type->Is(Type::String())); |
7857 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); | 7867 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); |
7858 Add<HPushArgument>(left); | 7868 Add<HPushArgument>(left); |
7859 Add<HPushArgument>(right); | 7869 Add<HPushArgument>(right); |
7860 return NewUncasted<HInvokeFunction>(function, 2); | 7870 return NewUncasted<HInvokeFunction>(function, 2); |
7861 } | 7871 } |
7862 | 7872 |
7863 return NewUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_NONE); | 7873 return NewUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_NONE); |
7864 } | 7874 } |
7865 | 7875 |
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9824 if (ShouldProduceTraceOutput()) { | 9834 if (ShouldProduceTraceOutput()) { |
9825 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9835 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
9826 } | 9836 } |
9827 | 9837 |
9828 #ifdef DEBUG | 9838 #ifdef DEBUG |
9829 graph_->Verify(false); // No full verify. | 9839 graph_->Verify(false); // No full verify. |
9830 #endif | 9840 #endif |
9831 } | 9841 } |
9832 | 9842 |
9833 } } // namespace v8::internal | 9843 } } // namespace v8::internal |
OLD | NEW |