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

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

Issue 8820011: Fixing mozilla test failures regarding Math.pow. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments. 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 | src/ia32/lithium-codegen-ia32.cc » ('j') | 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 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 if (exponent_type_ != INTEGER) { 2990 if (exponent_type_ != INTEGER) {
2991 Label fast_power; 2991 Label fast_power;
2992 // xmm1: base as double that is not +/- Infinity or NaN 2992 // xmm1: base as double that is not +/- Infinity or NaN
2993 // xmm2: exponent as double 2993 // xmm2: exponent as double
2994 // Detect integer exponents stored as double. 2994 // Detect integer exponents stored as double.
2995 __ cvttsd2si(eax, Operand(xmm2)); 2995 __ cvttsd2si(eax, Operand(xmm2));
2996 // Skip to runtime if possibly NaN (indicated by the indefinite integer). 2996 // Skip to runtime if possibly NaN (indicated by the indefinite integer).
2997 __ cmp(eax, Immediate(0x80000000u)); 2997 __ cmp(eax, Immediate(0x80000000u));
2998 __ j(equal, &generic_runtime); 2998 __ j(equal, &generic_runtime);
2999 __ cvtsi2sd(xmm4, eax); 2999 __ cvtsi2sd(xmm4, eax);
3000 __ ucomisd(xmm2, xmm4); 3000 __ ucomisd(xmm2, xmm4); // Already ruled out NaNs for exponent.
3001 __ j(equal, &int_exponent); 3001 __ j(equal, &int_exponent);
3002 3002
3003 if (exponent_type_ == ON_STACK) { 3003 if (exponent_type_ == ON_STACK) {
3004 // Detect square root case. Crankshaft detects constant +/-0.5 at 3004 // Detect square root case. Crankshaft detects constant +/-0.5 at
3005 // compile time and uses DoMathPowHalf instead. We then skip this check 3005 // compile time and uses DoMathPowHalf instead. We then skip this check
3006 // for non-constant cases of +/-0.5 as these hardly occur. 3006 // for non-constant cases of +/-0.5 as these hardly occur.
3007 Label continue_sqrt, continue_rsqrt, not_plus_half; 3007 Label continue_sqrt, continue_rsqrt, not_plus_half;
3008 // Test for 0.5. 3008 // Test for 0.5.
3009 // Load xmm4 with 0.5. 3009 // Load xmm4 with 0.5.
3010 __ mov(ecx, Immediate(0x3F000000u)); 3010 __ mov(ecx, Immediate(0x3F000000u));
3011 __ movd(xmm4, ecx); 3011 __ movd(xmm4, ecx);
3012 __ cvtss2sd(xmm4, xmm4); 3012 __ cvtss2sd(xmm4, xmm4);
3013 // xmm4 now has 0.5. 3013 // xmm4 now has 0.5.
3014 __ ucomisd(xmm4, xmm2); 3014 __ ucomisd(xmm4, xmm2); // Already ruled out NaNs for exponent.
3015 __ j(not_equal, &not_plus_half, Label::kNear); 3015 __ j(not_equal, &not_plus_half, Label::kNear);
3016 3016
3017 // Calculates square root of base. Check for the special case of 3017 // Calculates square root of base. Check for the special case of
3018 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). 3018 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13).
3019 // According to IEEE-754, single-precision -Infinity has the highest 3019 // According to IEEE-754, single-precision -Infinity has the highest
3020 // 9 bits set and the lowest 23 bits cleared. 3020 // 9 bits set and the lowest 23 bits cleared.
3021 __ mov(ecx, 0xFF800000u); 3021 __ mov(ecx, 0xFF800000u);
3022 __ movd(xmm4, ecx); 3022 __ movd(xmm4, ecx);
3023 __ cvtss2sd(xmm4, xmm4); 3023 __ cvtss2sd(xmm4, xmm4);
3024 __ ucomisd(xmm1, xmm4); 3024 __ ucomisd(xmm1, xmm4);
3025 // Comparing -Infinity with NaN results in "unordered", which sets the
3026 // zero flag as if both were equal. However, it also sets the carry flag.
3025 __ j(not_equal, &continue_sqrt, Label::kNear); 3027 __ j(not_equal, &continue_sqrt, Label::kNear);
3028 __ j(carry, &continue_sqrt, Label::kNear);
3026 3029
3027 // Set result to Infinity in the special case. 3030 // Set result to Infinity in the special case.
3028 __ xorps(xmm3, xmm3); 3031 __ xorps(xmm3, xmm3);
3029 __ subsd(xmm3, xmm4); 3032 __ subsd(xmm3, xmm4);
3030 __ jmp(&done); 3033 __ jmp(&done);
3031 3034
3032 __ bind(&continue_sqrt); 3035 __ bind(&continue_sqrt);
3033 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. 3036 // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
3034 __ xorps(xmm4, xmm4); 3037 __ xorps(xmm4, xmm4);
3035 __ addsd(xmm4, xmm1); // Convert -0 to +0. 3038 __ addsd(xmm4, xmm1); // Convert -0 to +0.
3036 __ sqrtsd(xmm3, xmm4); 3039 __ sqrtsd(xmm3, xmm4);
3037 __ jmp(&done); 3040 __ jmp(&done);
3038 3041
3039 // Test for -0.5. 3042 // Test for -0.5.
3040 __ bind(&not_plus_half); 3043 __ bind(&not_plus_half);
3041 // Load xmm2 with -0.5. 3044 // Load xmm2 with -0.5.
3042 // Since xmm3 is 1 and xmm4 is 0.5 this is simply xmm4 - xmm3. 3045 // Since xmm3 is 1 and xmm4 is 0.5 this is simply xmm4 - xmm3.
3043 __ subsd(xmm4, xmm3); 3046 __ subsd(xmm4, xmm3);
3044 // xmm4 now has -0.5. 3047 // xmm4 now has -0.5.
3045 __ ucomisd(xmm4, xmm2); 3048 __ ucomisd(xmm4, xmm2); // Already ruled out NaNs for exponent.
3046 __ j(not_equal, &fast_power, Label::kNear); 3049 __ j(not_equal, &fast_power, Label::kNear);
3047 3050
3048 // Calculates reciprocal of square root of base. Check for the special 3051 // Calculates reciprocal of square root of base. Check for the special
3049 // case of Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). 3052 // case of Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13).
3050 // According to IEEE-754, single-precision -Infinity has the highest 3053 // According to IEEE-754, single-precision -Infinity has the highest
3051 // 9 bits set and the lowest 23 bits cleared. 3054 // 9 bits set and the lowest 23 bits cleared.
3052 __ mov(ecx, 0xFF800000u); 3055 __ mov(ecx, 0xFF800000u);
3053 __ movd(xmm4, ecx); 3056 __ movd(xmm4, ecx);
3054 __ cvtss2sd(xmm4, xmm4); 3057 __ cvtss2sd(xmm4, xmm4);
3055 __ ucomisd(xmm1, xmm4); 3058 __ ucomisd(xmm1, xmm4);
3059 // Comparing -Infinity with NaN results in "unordered", which sets the
3060 // zero flag as if both were equal. However, it also sets the carry flag.
3056 __ j(not_equal, &continue_rsqrt, Label::kNear); 3061 __ j(not_equal, &continue_rsqrt, Label::kNear);
3062 __ j(carry, &continue_rsqrt, Label::kNear);
3057 3063
3058 // Set result to 0 in the special case. 3064 // Set result to 0 in the special case.
3059 __ xorps(xmm3, xmm3); 3065 __ xorps(xmm3, xmm3);
3060 __ jmp(&done); 3066 __ jmp(&done);
3061 3067
3062 __ bind(&continue_rsqrt); 3068 __ bind(&continue_rsqrt);
3063 // sqrtsd returns -0 when input is -0. ECMA spec requires +0. 3069 // sqrtsd returns -0 when input is -0. ECMA spec requires +0.
3064 __ xorps(xmm2, xmm2); 3070 __ xorps(xmm2, xmm2);
3065 __ addsd(xmm2, xmm1); // Convert -0 to +0. 3071 __ addsd(xmm2, xmm1); // Convert -0 to +0.
3066 __ sqrtsd(xmm2, xmm2); 3072 __ sqrtsd(xmm2, xmm2);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 3142
3137 // base has the original value of the exponent - if the exponent is 3143 // base has the original value of the exponent - if the exponent is
3138 // negative return 1/result. 3144 // negative return 1/result.
3139 __ test(ecx, ecx); 3145 __ test(ecx, ecx);
3140 __ j(positive, &done); 3146 __ j(positive, &done);
3141 __ divsd(xmm2, xmm3); 3147 __ divsd(xmm2, xmm3);
3142 __ movsd(xmm3, xmm2); 3148 __ movsd(xmm3, xmm2);
3143 // Test whether result is zero. Bail out to check for subnormal result. 3149 // Test whether result is zero. Bail out to check for subnormal result.
3144 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. 3150 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases.
3145 __ xorps(xmm2, xmm2); 3151 __ xorps(xmm2, xmm2);
3146 __ ucomisd(xmm2, xmm3); 3152 __ ucomisd(xmm2, xmm3); // Result cannot be NaN.
3147 __ j(equal, &double_int_runtime); 3153 __ j(equal, &double_int_runtime);
3148 3154
3149 // Returning or bailing out. 3155 // Returning or bailing out.
3150 if (exponent_type_ == ON_STACK) { 3156 if (exponent_type_ == ON_STACK) {
3151 // The stub is called from non-optimized code, which expects the result 3157 // The stub is called from non-optimized code, which expects the result
3152 // as heap number in eax. 3158 // as heap number in eax.
3153 __ bind(&done); 3159 __ bind(&done);
3154 // xmm3: result 3160 // xmm3: result
3155 __ AllocateHeapNumber(eax, ecx, edx, &generic_runtime); 3161 __ AllocateHeapNumber(eax, ecx, edx, &generic_runtime);
3156 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm3); 3162 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm3);
(...skipping 4127 matching lines...) Expand 10 before | Expand all | Expand 10 after
7284 false); 7290 false);
7285 __ pop(edx); 7291 __ pop(edx);
7286 __ ret(0); 7292 __ ret(0);
7287 } 7293 }
7288 7294
7289 #undef __ 7295 #undef __
7290 7296
7291 } } // namespace v8::internal 7297 } } // namespace v8::internal
7292 7298
7293 #endif // V8_TARGET_ARCH_IA32 7299 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698