Index: src/ia32/macro-assembler-ia32.h |
diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h |
index 41c0ea6355c42384ea398e571401aa8cf5e31261..fc6a5a0d3cc4aa486b43942214651d3b7aa5addb 100644 |
--- a/src/ia32/macro-assembler-ia32.h |
+++ b/src/ia32/macro-assembler-ia32.h |
@@ -497,9 +497,26 @@ class MacroAssembler: public Assembler { |
void DecodeField(Register reg) { |
static const int shift = Field::kShift; |
static const int mask = Field::kMask >> Field::kShift; |
- sar(reg, shift); |
+ if (shift != 0) { |
+ sar(reg, shift); |
+ } |
and_(reg, Immediate(mask)); |
} |
+ |
+ template<typename Field> |
+ void DecodeFieldToSmi(Register reg) { |
+ static const int shift = Field::kShift; |
+ static const int mask = (Field::kMask >> Field::kShift) << kSmiTagSize; |
+ STATIC_ASSERT((mask & (0x80000000u >> (kSmiTagSize - 1))) == 0); |
+ STATIC_ASSERT(kSmiTag == 0); |
+ if (shift < kSmiTagSize) { |
+ shl(reg, kSmiTagSize - shift); |
+ } else if (shift > kSmiTagSize) { |
+ sar(reg, shift - kSmiTagSize); |
+ } |
+ and_(reg, Immediate(mask)); |
+ } |
+ |
void LoadPowerOf2(XMMRegister dst, Register scratch, int power); |
// Abort execution if argument is not a number, enabled via --debug-code. |