| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 7944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7955 __ push(edx); | 7955 __ push(edx); |
| 7956 __ push(eax); | 7956 __ push(eax); |
| 7957 } | 7957 } |
| 7958 __ push(ecx); | 7958 __ push(ecx); |
| 7959 } | 7959 } |
| 7960 switch (op_) { | 7960 switch (op_) { |
| 7961 case Token::ADD: { | 7961 case Token::ADD: { |
| 7962 // Test for string arguments before calling runtime. | 7962 // Test for string arguments before calling runtime. |
| 7963 Label not_strings, not_string1, string1, string1_smi2; | 7963 Label not_strings, not_string1, string1, string1_smi2; |
| 7964 Result answer; | 7964 Result answer; |
| 7965 __ test(edx, Immediate(kSmiTagMask)); | 7965 // Registers containing left and right operands respectively. |
| 7966 Register lhs, rhs; |
| 7967 if (HasArgsReversed()) { |
| 7968 lhs = eax; |
| 7969 rhs = edx; |
| 7970 } else { |
| 7971 lhs = edx; |
| 7972 rhs = eax; |
| 7973 } |
| 7974 |
| 7975 // Test if first argument is a string. |
| 7976 __ test(lhs, Immediate(kSmiTagMask)); |
| 7966 __ j(zero, ¬_string1); | 7977 __ j(zero, ¬_string1); |
| 7967 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, ecx); | 7978 __ CmpObjectType(lhs, FIRST_NONSTRING_TYPE, ecx); |
| 7968 __ j(above_equal, ¬_string1); | 7979 __ j(above_equal, ¬_string1); |
| 7969 | 7980 |
| 7970 // First argument is a string, test second. | 7981 // First argument is a string, test second. |
| 7971 __ test(eax, Immediate(kSmiTagMask)); | 7982 __ test(rhs, Immediate(kSmiTagMask)); |
| 7972 __ j(zero, &string1_smi2); | 7983 __ j(zero, &string1_smi2); |
| 7973 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, ecx); | 7984 __ CmpObjectType(rhs, FIRST_NONSTRING_TYPE, ecx); |
| 7974 __ j(above_equal, &string1); | 7985 __ j(above_equal, &string1); |
| 7975 | 7986 |
| 7976 // First and second argument are strings. Jump to the string add stub. | 7987 // First and second argument are strings. Jump to the string add stub. |
| 7977 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB); | 7988 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB); |
| 7978 __ TailCallStub(&string_add_stub); | 7989 __ TailCallStub(&string_add_stub); |
| 7979 | 7990 |
| 7980 __ bind(&string1_smi2); | 7991 __ bind(&string1_smi2); |
| 7981 // First argument is a string, second is a smi. Try to lookup the number | 7992 // First argument is a string, second is a smi. Try to lookup the number |
| 7982 // string for the smi in the number string cache. | 7993 // string for the smi in the number string cache. |
| 7983 NumberToStringStub::GenerateLookupNumberStringCache( | 7994 NumberToStringStub::GenerateLookupNumberStringCache( |
| 7984 masm, eax, edi, ebx, ecx, true, &string1); | 7995 masm, rhs, edi, ebx, ecx, true, &string1); |
| 7985 | 7996 |
| 7986 // Call the string add stub to make the result. | 7997 // Replace second argument on stack and tailcall string add stub to make |
| 7987 __ EnterInternalFrame(); | 7998 // the result. |
| 7988 __ push(edx); // Original first argument. | 7999 __ mov(Operand(esp, 1 * kPointerSize), edi); |
| 7989 __ push(edi); // Number to string result for second argument. | 8000 __ TailCallStub(&string_add_stub); |
| 7990 __ CallStub(&string_add_stub); | |
| 7991 __ LeaveInternalFrame(); | |
| 7992 __ ret(2 * kPointerSize); | |
| 7993 | 8001 |
| 8002 // Only first argument is a string. |
| 7994 __ bind(&string1); | 8003 __ bind(&string1); |
| 7995 __ InvokeBuiltin( | 8004 __ InvokeBuiltin(Builtins::STRING_ADD_LEFT, JUMP_FUNCTION); |
| 7996 HasArgsReversed() ? | |
| 7997 Builtins::STRING_ADD_RIGHT : | |
| 7998 Builtins::STRING_ADD_LEFT, | |
| 7999 JUMP_FUNCTION); | |
| 8000 | 8005 |
| 8001 // First argument was not a string, test second. | 8006 // First argument was not a string, test second. |
| 8002 __ bind(¬_string1); | 8007 __ bind(¬_string1); |
| 8003 __ test(eax, Immediate(kSmiTagMask)); | 8008 __ test(rhs, Immediate(kSmiTagMask)); |
| 8004 __ j(zero, ¬_strings); | 8009 __ j(zero, ¬_strings); |
| 8005 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, ecx); | 8010 __ CmpObjectType(rhs, FIRST_NONSTRING_TYPE, ecx); |
| 8006 __ j(above_equal, ¬_strings); | 8011 __ j(above_equal, ¬_strings); |
| 8007 | 8012 |
| 8008 // Only second argument is a string. | 8013 // Only second argument is a string. |
| 8009 __ InvokeBuiltin( | 8014 __ InvokeBuiltin(Builtins::STRING_ADD_RIGHT, JUMP_FUNCTION); |
| 8010 HasArgsReversed() ? | |
| 8011 Builtins::STRING_ADD_LEFT : | |
| 8012 Builtins::STRING_ADD_RIGHT, | |
| 8013 JUMP_FUNCTION); | |
| 8014 | 8015 |
| 8015 __ bind(¬_strings); | 8016 __ bind(¬_strings); |
| 8016 // Neither argument is a string. | 8017 // Neither argument is a string. |
| 8017 __ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION); | 8018 __ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION); |
| 8018 break; | 8019 break; |
| 8019 } | 8020 } |
| 8020 case Token::SUB: | 8021 case Token::SUB: |
| 8021 __ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION); | 8022 __ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION); |
| 8022 break; | 8023 break; |
| 8023 case Token::MUL: | 8024 case Token::MUL: |
| (...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10791 | 10792 |
| 10792 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 10793 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 10793 // tagged as a small integer. | 10794 // tagged as a small integer. |
| 10794 __ bind(&runtime); | 10795 __ bind(&runtime); |
| 10795 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); | 10796 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); |
| 10796 } | 10797 } |
| 10797 | 10798 |
| 10798 #undef __ | 10799 #undef __ |
| 10799 | 10800 |
| 10800 } } // namespace v8::internal | 10801 } } // namespace v8::internal |
| OLD | NEW |