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

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 22285003: tweak of Math.abs in its x64 stub (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 4 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 | « src/x64/lithium-codegen-x64.cc ('k') | 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 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 &miss); 2239 &miss);
2240 GenerateLoadFunctionFromCell(cell, function, &miss); 2240 GenerateLoadFunctionFromCell(cell, function, &miss);
2241 } 2241 }
2242 // Load the (only) argument into rax. 2242 // Load the (only) argument into rax.
2243 __ movq(rax, Operand(rsp, 1 * kPointerSize)); 2243 __ movq(rax, Operand(rsp, 1 * kPointerSize));
2244 2244
2245 // Check if the argument is a smi. 2245 // Check if the argument is a smi.
2246 Label not_smi; 2246 Label not_smi;
2247 STATIC_ASSERT(kSmiTag == 0); 2247 STATIC_ASSERT(kSmiTag == 0);
2248 __ JumpIfNotSmi(rax, &not_smi); 2248 __ JumpIfNotSmi(rax, &not_smi);
2249 __ SmiToInteger32(rax, rax);
2250 2249
2250 // Branchless abs implementation, refer to below:
2251 // http://graphics.stanford.edu/~seander/bithacks.html#IntegerAbs
2251 // Set ebx to 1...1 (== -1) if the argument is negative, or to 0...0 2252 // Set ebx to 1...1 (== -1) if the argument is negative, or to 0...0
2252 // otherwise. 2253 // otherwise.
2253 __ movl(rbx, rax); 2254 __ movq(rbx, rax);
2254 __ sarl(rbx, Immediate(kBitsPerInt - 1)); 2255 __ sar(rbx, Immediate(kBitsPerPointer - 1));
2255 2256
2256 // Do bitwise not or do nothing depending on ebx. 2257 // Do bitwise not or do nothing depending on ebx.
2257 __ xorl(rax, rbx); 2258 __ xor_(rax, rbx);
2258 2259
2259 // Add 1 or do nothing depending on ebx. 2260 // Add 1 or do nothing depending on ebx.
2260 __ subl(rax, rbx); 2261 __ subq(rax, rbx);
2261 2262
2262 // If the result is still negative, go to the slow case. 2263 // If the result is still negative, go to the slow case.
2263 // This only happens for the most negative smi. 2264 // This only happens for the most negative smi.
2264 Label slow; 2265 Label slow;
2265 __ j(negative, &slow); 2266 __ j(negative, &slow);
2266 2267
2267 // Smi case done.
2268 __ Integer32ToSmi(rax, rax);
2269 __ ret(2 * kPointerSize); 2268 __ ret(2 * kPointerSize);
2270 2269
2271 // Check if the argument is a heap number and load its value. 2270 // Check if the argument is a heap number and load its value.
2272 __ bind(&not_smi); 2271 __ bind(&not_smi);
2273 __ CheckMap(rax, factory()->heap_number_map(), &slow, DONT_DO_SMI_CHECK); 2272 __ CheckMap(rax, factory()->heap_number_map(), &slow, DONT_DO_SMI_CHECK);
2274 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); 2273 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset));
2275 2274
2276 // Check the sign of the argument. If the argument is positive, 2275 // Check the sign of the argument. If the argument is positive,
2277 // just return it. 2276 // just return it.
2278 Label negative_sign; 2277 Label negative_sign;
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3513 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3515 } 3514 }
3516 } 3515 }
3517 3516
3518 3517
3519 #undef __ 3518 #undef __
3520 3519
3521 } } // namespace v8::internal 3520 } } // namespace v8::internal
3522 3521
3523 #endif // V8_TARGET_ARCH_X64 3522 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698