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 9842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9853 if (HasArgsInRegisters()) { | 9853 if (HasArgsInRegisters()) { |
9854 __ movq(rbx, rax); | 9854 __ movq(rbx, rax); |
9855 __ movq(rax, rdx); | 9855 __ movq(rax, rdx); |
9856 } | 9856 } |
9857 } | 9857 } |
9858 if (!HasArgsInRegisters()) { | 9858 if (!HasArgsInRegisters()) { |
9859 __ movq(right, Operand(rsp, 1 * kPointerSize)); | 9859 __ movq(right, Operand(rsp, 1 * kPointerSize)); |
9860 __ movq(left, Operand(rsp, 2 * kPointerSize)); | 9860 __ movq(left, Operand(rsp, 2 * kPointerSize)); |
9861 } | 9861 } |
9862 | 9862 |
9863 // 2. Smi check both operands. Skip the check for OR as it is better combined | |
9864 // with the actual operation. | |
9865 Label not_smis; | 9863 Label not_smis; |
9866 if (op_ != Token::BIT_OR) { | 9864 // 2. Smi check both operands. |
9867 Comment smi_check_comment(masm, "-- Smi check arguments"); | 9865 if (static_operands_type_.IsSmi()) { |
9868 __ JumpIfNotBothSmi(left, right, ¬_smis); | 9866 // Skip smi check if we know that both arguments are smis. |
| 9867 if (FLAG_debug_code) { |
| 9868 __ AbortIfNotSmi(left, "Static type check claimed non-smi is smi."); |
| 9869 __ AbortIfNotSmi(right, "Static type check claimed non-smi is smi."); |
| 9870 } |
| 9871 if (op_ == Token::BIT_OR) { |
| 9872 // Handle OR here, since we do extra smi-checking in the or code below. |
| 9873 __ SmiOr(right, right, left); |
| 9874 GenerateReturn(masm); |
| 9875 return; |
| 9876 } |
| 9877 } else { |
| 9878 if (op_ != Token::BIT_OR) { |
| 9879 // Skip the check for OR as it is better combined with the |
| 9880 // actual operation. |
| 9881 Comment smi_check_comment(masm, "-- Smi check arguments"); |
| 9882 __ JumpIfNotBothSmi(left, right, ¬_smis); |
| 9883 } |
9869 } | 9884 } |
9870 | 9885 |
9871 // 3. Operands are both smis (except for OR), perform the operation leaving | 9886 // 3. Operands are both smis (except for OR), perform the operation leaving |
9872 // the result in rax and check the result if necessary. | 9887 // the result in rax and check the result if necessary. |
9873 Comment perform_smi(masm, "-- Perform smi operation"); | 9888 Comment perform_smi(masm, "-- Perform smi operation"); |
9874 Label use_fp_on_smis; | 9889 Label use_fp_on_smis; |
9875 switch (op_) { | 9890 switch (op_) { |
9876 case Token::ADD: { | 9891 case Token::ADD: { |
9877 ASSERT(right.is(rax)); | 9892 ASSERT(right.is(rax)); |
9878 __ SmiAdd(right, right, left, &use_fp_on_smis); // ADD is commutative. | 9893 __ SmiAdd(right, right, left, &use_fp_on_smis); // ADD is commutative. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9946 GenerateReturn(masm); | 9961 GenerateReturn(masm); |
9947 | 9962 |
9948 // 5. For some operations emit inline code to perform floating point | 9963 // 5. For some operations emit inline code to perform floating point |
9949 // operations on known smis (e.g., if the result of the operation | 9964 // operations on known smis (e.g., if the result of the operation |
9950 // overflowed the smi range). | 9965 // overflowed the smi range). |
9951 switch (op_) { | 9966 switch (op_) { |
9952 case Token::ADD: | 9967 case Token::ADD: |
9953 case Token::SUB: | 9968 case Token::SUB: |
9954 case Token::MUL: | 9969 case Token::MUL: |
9955 case Token::DIV: { | 9970 case Token::DIV: { |
| 9971 ASSERT(use_fp_on_smis.is_linked()); |
9956 __ bind(&use_fp_on_smis); | 9972 __ bind(&use_fp_on_smis); |
9957 if (op_ == Token::DIV) { | 9973 if (op_ == Token::DIV) { |
9958 __ movq(rdx, rax); | 9974 __ movq(rdx, rax); |
9959 __ movq(rax, rbx); | 9975 __ movq(rax, rbx); |
9960 } | 9976 } |
9961 // left is rdx, right is rax. | 9977 // left is rdx, right is rax. |
9962 __ AllocateHeapNumber(rbx, rcx, slow); | 9978 __ AllocateHeapNumber(rbx, rcx, slow); |
9963 FloatingPointHelper::LoadFloatOperandsFromSmis(masm, xmm4, xmm5); | 9979 FloatingPointHelper::LoadFloatOperandsFromSmis(masm, xmm4, xmm5); |
9964 switch (op_) { | 9980 switch (op_) { |
9965 case Token::ADD: __ addsd(xmm4, xmm5); break; | 9981 case Token::ADD: __ addsd(xmm4, xmm5); break; |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11417 // Call the function from C++. | 11433 // Call the function from C++. |
11418 return FUNCTION_CAST<ModuloFunction>(buffer); | 11434 return FUNCTION_CAST<ModuloFunction>(buffer); |
11419 } | 11435 } |
11420 | 11436 |
11421 #endif | 11437 #endif |
11422 | 11438 |
11423 | 11439 |
11424 #undef __ | 11440 #undef __ |
11425 | 11441 |
11426 } } // namespace v8::internal | 11442 } } // namespace v8::internal |
OLD | NEW |