Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3206 } | 3206 } |
| 3207 | 3207 |
| 3208 // Calculate power with integer exponent. | 3208 // Calculate power with integer exponent. |
| 3209 __ bind(&int_exponent); | 3209 __ bind(&int_exponent); |
| 3210 const XMMRegister double_scratch2 = double_exponent; | 3210 const XMMRegister double_scratch2 = double_exponent; |
| 3211 __ mov(scratch, exponent); // Back up exponent. | 3211 __ mov(scratch, exponent); // Back up exponent. |
| 3212 __ movsd(double_scratch, double_base); // Back up base. | 3212 __ movsd(double_scratch, double_base); // Back up base. |
| 3213 __ movsd(double_scratch2, double_result); // Load double_exponent with 1. | 3213 __ movsd(double_scratch2, double_result); // Load double_exponent with 1. |
| 3214 | 3214 |
| 3215 // Get absolute value of exponent. | 3215 // Get absolute value of exponent. |
| 3216 Label no_neg, while_true, no_multiply; | 3216 Label no_neg, while_true, no_multiply, while_false; |
|
Vyacheslav Egorov (Google)
2012/09/17 22:12:02
I have an impression that no_multiply is not used
| |
| 3217 __ test(scratch, scratch); | 3217 __ test(scratch, scratch); |
| 3218 __ j(positive, &no_neg, Label::kNear); | 3218 __ j(positive, &no_neg, Label::kNear); |
| 3219 __ neg(scratch); | 3219 __ neg(scratch); |
| 3220 __ bind(&no_neg); | 3220 __ bind(&no_neg); |
| 3221 | 3221 |
| 3222 __ j(zero, &while_false, Label::kNear); | |
| 3223 __ shr(scratch, 1); | |
| 3224 // Above condition means CF=0 && ZF =0. | |
| 3225 // So the last shifted bit is 0 and the rest is not 0. | |
| 3226 __ j(above, &while_true, Label::kNear); | |
| 3227 __ movsd(double_result, double_scratch); | |
| 3228 __ j(zero, &while_false, Label::kNear); | |
| 3229 | |
| 3222 __ bind(&while_true); | 3230 __ bind(&while_true); |
| 3223 __ shr(scratch, 1); | 3231 __ shr(scratch, 1); |
| 3224 __ j(not_carry, &no_multiply, Label::kNear); | 3232 __ mulsd(double_scratch, double_scratch); |
| 3233 __ j(above, &while_true, Label::kNear); | |
| 3225 __ mulsd(double_result, double_scratch); | 3234 __ mulsd(double_result, double_scratch); |
| 3226 __ bind(&no_multiply); | |
| 3227 | |
| 3228 __ mulsd(double_scratch, double_scratch); | |
| 3229 __ j(not_zero, &while_true); | 3235 __ j(not_zero, &while_true); |
| 3230 | 3236 |
| 3237 __ bind(&while_false); | |
| 3231 // scratch has the original value of the exponent - if the exponent is | 3238 // scratch has the original value of the exponent - if the exponent is |
| 3232 // negative, return 1/result. | 3239 // negative, return 1/result. |
| 3233 __ test(exponent, exponent); | 3240 __ test(exponent, exponent); |
| 3234 __ j(positive, &done); | 3241 __ j(positive, &done); |
| 3235 __ divsd(double_scratch2, double_result); | 3242 __ divsd(double_scratch2, double_result); |
| 3236 __ movsd(double_result, double_scratch2); | 3243 __ movsd(double_result, double_scratch2); |
| 3237 // Test whether result is zero. Bail out to check for subnormal result. | 3244 // Test whether result is zero. Bail out to check for subnormal result. |
| 3238 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. | 3245 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. |
| 3239 __ xorps(double_scratch2, double_scratch2); | 3246 __ xorps(double_scratch2, double_scratch2); |
| 3240 __ ucomisd(double_scratch2, double_result); // Result cannot be NaN. | 3247 __ ucomisd(double_scratch2, double_result); // Result cannot be NaN. |
| (...skipping 4263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7504 // Restore ecx. | 7511 // Restore ecx. |
| 7505 __ pop(ecx); | 7512 __ pop(ecx); |
| 7506 __ ret(0); | 7513 __ ret(0); |
| 7507 } | 7514 } |
| 7508 | 7515 |
| 7509 #undef __ | 7516 #undef __ |
| 7510 | 7517 |
| 7511 } } // namespace v8::internal | 7518 } } // namespace v8::internal |
| 7512 | 7519 |
| 7513 #endif // V8_TARGET_ARCH_IA32 | 7520 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |