Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 8820007: Skip check for +/-0.5 in optimized Math.pow (ia32). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, &not_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, &not_minus_half, Label::kNear);
3045 3041
3046 // Test for 0.5. 3042 // Calculates reciprocal of square root.eax
3047 __ bind(&not_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(&not_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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698