Chromium Code Reviews| Index: runtime/vm/intrinsifier_x64.cc |
| =================================================================== |
| --- runtime/vm/intrinsifier_x64.cc (revision 43118) |
| +++ runtime/vm/intrinsifier_x64.cc (working copy) |
| @@ -794,7 +794,18 @@ |
| void Intrinsifier::Smi_bitLength(Assembler* assembler) { |
| - // TODO(sra): Implement using bsrq. |
| + ASSERT(kSmiTagShift == 1); |
| + __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Index. |
| + // XOR with sign bit to complement bits if value is negative. |
| + __ movq(RCX, RAX); |
| + __ sarq(RCX, Immediate(63)); // All 0 or all 1. |
|
Lasse Reichstein Nielsen
2015/01/25 11:26:53
If you shift RAX instead of RCX here, would the de
srdjan
2015/01/26 18:43:18
Thanks for the comment. In theory yes, but with In
|
| + __ xorq(RAX, RCX); |
| + // BSR does not write the destination register if source is zero. Put a 1 in |
| + // the Smi tag bit to ensure BSR writes to destination register. |
| + __ orq(RAX, Immediate(kSmiTagMask)); |
| + __ bsrq(RAX, RAX); |
| + __ SmiTag(RAX); |
| + __ ret(); |
| } |