Index: src/arm/macro-assembler-arm.h |
diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h |
index 4000478eb6359b458df80138eef19284b11107a4..5f77be6a4293feb82e6bde281ae0c5769b4c97bf 100644 |
--- a/src/arm/macro-assembler-arm.h |
+++ b/src/arm/macro-assembler-arm.h |
@@ -1357,17 +1357,33 @@ class MacroAssembler: public Assembler { |
template<typename Field> |
void DecodeField(Register dst, Register src) { |
+ Ubfx(dst, src, Field::kShift, Field::kSize); |
+ } |
+ |
+ template<typename Field> |
+ void DecodeField(Register reg) { |
+ DecodeField<Field>(reg, reg); |
+ } |
+ |
+ template<typename Field> |
+ void DecodeFieldToSmi(Register dst, Register src) { |
static const int shift = Field::kShift; |
- static const int mask = Field::kMask >> shift; |
- static const int size = Field::kSize; |
- mov(dst, Operand(src, LSR, shift)); |
- if (shift + size != 32) { |
+ static const int mask = Field::kMask >> shift << kSmiTagSize; |
+ STATIC_ASSERT((mask & (0x80000000u >> (kSmiTagSize - 1))) == 0); |
+ STATIC_ASSERT(kSmiTag == 0); |
+ if (shift < kSmiTagSize) { |
+ mov(dst, Operand(src, LSL, kSmiTagSize - shift)); |
+ and_(dst, dst, Operand(mask)); |
+ } else if (shift > kSmiTagSize) { |
+ mov(dst, Operand(src, LSR, shift - kSmiTagSize)); |
and_(dst, dst, Operand(mask)); |
+ } else { |
+ and_(dst, src, Operand(mask)); |
} |
} |
template<typename Field> |
- void DecodeField(Register reg) { |
+ void DecodeFieldToSmi(Register reg) { |
DecodeField<Field>(reg, reg); |
} |