Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index c3a723f89f4192ce86db88090883d7a09bc8e5eb..bd9d20a7d456a2fe9009c2e7dce0ddc23c1c8209 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -1092,6 +1092,51 @@ void MacroAssembler::SelectNonSmi(Register dst, |
} |
+SmiIndex MacroAssembler::SmiToIndex(Register dst, Register src, int shift) { |
+ ASSERT(is_uint6(shift)); |
+ if (shift == 0) { // times_1. |
+ SmiToInteger32(dst, src); |
+ return SmiIndex(dst, times_1); |
+ } |
+ if (shift <= 4) { // 2 - 16 times multiplier. |
+ return SmiIndex(src, static_cast<ScaleFactor>(shift - kSmiTagSize)); |
William Hesse
2009/09/15 10:12:09
How are we making sure that src is zero-extended h
Lasse Reichstein
2009/09/15 10:39:08
We should make sure. I'll add a movel(dst, src).
|
+ } |
+ // Shift by shift-kSmiTagSize. |
+ if (!dst.is(src)) { |
+ movl(dst, src); |
+ } |
+ shl(dst, Immediate(shift - kSmiTagSize)); |
+ return SmiIndex(dst, times_1); |
+} |
+ |
+ |
+SmiIndex MacroAssembler::SmiToNegativeIndex(Register dst, |
+ Register src, |
+ int shift) { |
+ // Register src holds a positive smi. |
+ ASSERT(is_uint6(shift)); |
+ if (shift == 0) { // times_1. |
+ SmiToInteger32(dst, src); |
+ neg(dst); |
+ return SmiIndex(dst, times_1); |
+ } |
+ if (shift <= 4) { // 2 - 16 times multiplier is handled using ScaleFactor. |
+ if (!dst.is(src)) { |
+ movl(dst, src); |
+ } |
+ neg(dst); |
+ return SmiIndex(dst, static_cast<ScaleFactor>(shift - kSmiTagSize)); |
+ } |
+ // Shift by shift-kSmiTagSize. |
+ if (!dst.is(src)) { |
+ movl(dst, src); |
+ } |
+ neg(dst); |
+ shl(dst, Immediate(shift - kSmiTagSize)); |
+ return SmiIndex(dst, times_1); |
+} |
+ |
+ |
bool MacroAssembler::IsUnsafeSmi(Smi* value) { |
return false; |