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

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

Issue 10939013: Improve the assembly code for power function with integer exponential on x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 3 months 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 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 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 2255
2256 // Calculate power with integer exponent. 2256 // Calculate power with integer exponent.
2257 __ bind(&int_exponent); 2257 __ bind(&int_exponent);
2258 const XMMRegister double_scratch2 = double_exponent; 2258 const XMMRegister double_scratch2 = double_exponent;
2259 // Back up exponent as we need to check if exponent is negative later. 2259 // Back up exponent as we need to check if exponent is negative later.
2260 __ movq(scratch, exponent); // Back up exponent. 2260 __ movq(scratch, exponent); // Back up exponent.
2261 __ movsd(double_scratch, double_base); // Back up base. 2261 __ movsd(double_scratch, double_base); // Back up base.
2262 __ movsd(double_scratch2, double_result); // Load double_exponent with 1. 2262 __ movsd(double_scratch2, double_result); // Load double_exponent with 1.
2263 2263
2264 // Get absolute value of exponent. 2264 // Get absolute value of exponent.
2265 Label no_neg, while_true, no_multiply; 2265 Label no_neg, while_true, while_false;
2266 __ testl(scratch, scratch); 2266 __ testl(scratch, scratch);
2267 __ j(positive, &no_neg, Label::kNear); 2267 __ j(positive, &no_neg, Label::kNear);
2268 __ negl(scratch); 2268 __ negl(scratch);
2269 __ bind(&no_neg); 2269 __ bind(&no_neg);
2270 2270
2271 __ j(zero, &while_false, Label::kNear);
2272 __ shrl(scratch, Immediate(1));
2273 // Above condition means CF=0 && ZF =0.
2274 // So the last shifted bit is 0 and the rest is not 0.
2275 __ j(above, &while_true, Label::kNear);
2276 __ movsd(double_result, double_scratch);
2277 __ j(zero, &while_false, Label::kNear);
2278
2271 __ bind(&while_true); 2279 __ bind(&while_true);
2272 __ shrl(scratch, Immediate(1)); 2280 __ shrl(scratch, Immediate(1));
2273 __ j(not_carry, &no_multiply, Label::kNear); 2281 __ mulsd(double_scratch, double_scratch);
2282 __ j(above, &while_true, Label::kNear);
2274 __ mulsd(double_result, double_scratch); 2283 __ mulsd(double_result, double_scratch);
2275 __ bind(&no_multiply);
2276
2277 __ mulsd(double_scratch, double_scratch);
2278 __ j(not_zero, &while_true); 2284 __ j(not_zero, &while_true);
2279 2285
2286 __ bind(&while_false);
2280 // If the exponent is negative, return 1/result. 2287 // If the exponent is negative, return 1/result.
2281 __ testl(exponent, exponent); 2288 __ testl(exponent, exponent);
2282 __ j(greater, &done); 2289 __ j(greater, &done);
2283 __ divsd(double_scratch2, double_result); 2290 __ divsd(double_scratch2, double_result);
2284 __ movsd(double_result, double_scratch2); 2291 __ movsd(double_result, double_scratch2);
2285 // Test whether result is zero. Bail out to check for subnormal result. 2292 // Test whether result is zero. Bail out to check for subnormal result.
2286 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. 2293 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases.
2287 __ xorps(double_scratch2, double_scratch2); 2294 __ xorps(double_scratch2, double_scratch2);
2288 __ ucomisd(double_scratch2, double_result); 2295 __ ucomisd(double_scratch2, double_result);
2289 // double_exponent aliased as double_scratch2 has already been overwritten 2296 // double_exponent aliased as double_scratch2 has already been overwritten
(...skipping 4192 matching lines...) Expand 10 before | Expand all | Expand 10 after
6482 #endif 6489 #endif
6483 6490
6484 __ Ret(); 6491 __ Ret();
6485 } 6492 }
6486 6493
6487 #undef __ 6494 #undef __
6488 6495
6489 } } // namespace v8::internal 6496 } } // namespace v8::internal
6490 6497
6491 #endif // V8_TARGET_ARCH_X64 6498 #endif // V8_TARGET_ARCH_X64
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