| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3018 // xmm2: exponent as double | 3018 // xmm2: exponent as double |
| 3019 // Detect integer exponents stored as double. | 3019 // Detect integer exponents stored as double. |
| 3020 __ cvttsd2si(eax, Operand(xmm2)); | 3020 __ cvttsd2si(eax, Operand(xmm2)); |
| 3021 // Skip to runtime if possibly NaN (indicated by the indefinite integer). | 3021 // Skip to runtime if possibly NaN (indicated by the indefinite integer). |
| 3022 __ cmp(eax, Immediate(0x80000000u)); | 3022 __ cmp(eax, Immediate(0x80000000u)); |
| 3023 __ j(equal, &generic_runtime); | 3023 __ j(equal, &generic_runtime); |
| 3024 __ cvtsi2sd(xmm4, eax); | 3024 __ cvtsi2sd(xmm4, eax); |
| 3025 __ ucomisd(xmm2, xmm4); | 3025 __ ucomisd(xmm2, xmm4); |
| 3026 __ j(equal, &int_exponent); | 3026 __ j(equal, &int_exponent); |
| 3027 | 3027 |
| 3028 // Detect square root case. | 3028 if (exponent_type_ == ON_STACK) { |
| 3029 // Test for -0.5. | 3029 // Detect square root case. Crankshaft detects constant +/-0.5 at |
| 3030 // Load xmm4 with -0.5. | 3030 // compile time and uses DoMathPowHalf instead. We then skip this check |
| 3031 __ mov(ecx, Immediate(0xBF000000u)); | 3031 // for non-constant cases of +/-0.5 as these hardly occur. |
| 3032 __ movd(xmm4, ecx); | |
| 3033 __ cvtss2sd(xmm4, xmm4); | |
| 3034 // xmm3 now has -0.5. | |
| 3035 __ ucomisd(xmm4, xmm2); | |
| 3036 __ j(not_equal, ¬_minus_half, Label::kNear); | |
| 3037 | 3032 |
| 3038 // Calculates reciprocal of square root.eax | 3033 // Test for -0.5. |
| 3039 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. | 3034 // Load xmm4 with -0.5. |
| 3040 __ xorps(xmm2, xmm2); | 3035 __ mov(ecx, Immediate(0xBF000000u)); |
| 3041 __ addsd(xmm2, xmm1); | 3036 __ movd(xmm4, ecx); |
| 3042 __ sqrtsd(xmm2, xmm2); | 3037 __ cvtss2sd(xmm4, xmm4); |
| 3043 __ divsd(xmm3, xmm2); | 3038 // xmm3 now has -0.5. |
| 3044 __ jmp(&done); | 3039 __ ucomisd(xmm4, xmm2); |
| 3040 __ j(not_equal, ¬_minus_half, Label::kNear); |
| 3045 | 3041 |
| 3046 // Test for 0.5. | 3042 // Calculates reciprocal of square root.eax |
| 3047 __ bind(¬_minus_half); | 3043 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. |
| 3048 // Load xmm2 with 0.5. | 3044 __ xorps(xmm2, xmm2); |
| 3049 // Since xmm3 is 1 and xmm4 is -0.5 this is simply xmm4 + xmm3. | 3045 __ addsd(xmm2, xmm1); |
| 3050 __ addsd(xmm4, xmm3); | 3046 __ sqrtsd(xmm2, xmm2); |
| 3051 // xmm2 now has 0.5. | 3047 __ divsd(xmm3, xmm2); |
| 3052 __ ucomisd(xmm4, xmm2); | 3048 __ jmp(&done); |
| 3053 __ j(not_equal, &fast_power, Label::kNear); | 3049 |
| 3054 // Calculates square root. | 3050 // Test for 0.5. |
| 3055 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. | 3051 __ bind(¬_minus_half); |
| 3056 __ xorps(xmm4, xmm4); | 3052 // Load xmm2 with 0.5. |
| 3057 __ addsd(xmm4, xmm1); | 3053 // Since xmm3 is 1 and xmm4 is -0.5 this is simply xmm4 + xmm3. |
| 3058 __ sqrtsd(xmm3, xmm4); | 3054 __ addsd(xmm4, xmm3); |
| 3059 __ jmp(&done); | 3055 // xmm2 now has 0.5. |
| 3056 __ ucomisd(xmm4, xmm2); |
| 3057 __ j(not_equal, &fast_power, Label::kNear); |
| 3058 // Calculates square root. |
| 3059 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. |
| 3060 __ xorps(xmm4, xmm4); |
| 3061 __ addsd(xmm4, xmm1); |
| 3062 __ sqrtsd(xmm3, xmm4); |
| 3063 __ jmp(&done); |
| 3064 } |
| 3060 | 3065 |
| 3061 // Using FPU instructions to calculate power. | 3066 // Using FPU instructions to calculate power. |
| 3062 Label fast_power_failed; | 3067 Label fast_power_failed; |
| 3063 __ bind(&fast_power); | 3068 __ bind(&fast_power); |
| 3064 __ fnclex(); // Clear flags to catch exceptions later. | 3069 __ fnclex(); // Clear flags to catch exceptions later. |
| 3065 // Transfer (B)ase and (E)xponent onto the FPU register stack. | 3070 // Transfer (B)ase and (E)xponent onto the FPU register stack. |
| 3066 __ sub(esp, Immediate(kDoubleSize)); | 3071 __ sub(esp, Immediate(kDoubleSize)); |
| 3067 __ movdbl(Operand(esp, 0), xmm2); | 3072 __ movdbl(Operand(esp, 0), xmm2); |
| 3068 __ fld_d(Operand(esp, 0)); // E | 3073 __ fld_d(Operand(esp, 0)); // E |
| 3069 __ movdbl(Operand(esp, 0), xmm1); | 3074 __ movdbl(Operand(esp, 0), xmm1); |
| (...skipping 4204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7274 false); | 7279 false); |
| 7275 __ pop(edx); | 7280 __ pop(edx); |
| 7276 __ ret(0); | 7281 __ ret(0); |
| 7277 } | 7282 } |
| 7278 | 7283 |
| 7279 #undef __ | 7284 #undef __ |
| 7280 | 7285 |
| 7281 } } // namespace v8::internal | 7286 } } // namespace v8::internal |
| 7282 | 7287 |
| 7283 #endif // V8_TARGET_ARCH_IA32 | 7288 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |