Index: src/x87/macro-assembler-x87.h |
diff --git a/src/x87/macro-assembler-x87.h b/src/x87/macro-assembler-x87.h |
index 8f04ac35f57815bc5cde271259d3f1185fe704ec..faa9012a915c9363e141d0f9154fef659c568355 100644 |
--- a/src/x87/macro-assembler-x87.h |
+++ b/src/x87/macro-assembler-x87.h |
@@ -478,7 +478,23 @@ 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)); |
} |