Index: runtime/vm/instructions_arm.cc |
diff --git a/runtime/vm/instructions_arm.cc b/runtime/vm/instructions_arm.cc |
index 4ae5936a51e8b91043af8247dd40085cc788da79..34b4995765645e06b741f21d47d190c484fa8b59 100644 |
--- a/runtime/vm/instructions_arm.cc |
+++ b/runtime/vm/instructions_arm.cc |
@@ -13,41 +13,40 @@ |
namespace dart { |
CallPattern::CallPattern(uword pc, const Code& code) |
- : end_(reinterpret_cast<uword*>(pc)), |
+ : object_pool_(Array::Handle(code.ObjectPool())), |
+ end_(reinterpret_cast<uword*>(pc)), |
+ args_desc_load_end_(NULL), |
+ ic_data_load_end_(NULL), |
target_address_pool_index_(-1), |
- args_desc_load_end_(-1), |
args_desc_(Array::Handle()), |
- ic_data_load_end_(-1), |
- ic_data_(ICData::Handle()), |
- object_pool_(Array::Handle(code.ObjectPool())) { |
+ ic_data_(ICData::Handle()) { |
ASSERT(code.ContainsInstructionAt(pc)); |
- ASSERT(Back(1) == 0xe12fff3e); // Last instruction: blx lr |
+ ASSERT(*(end_ - 1) == 0xe12fff3e); // Last instruction: blx lr |
Register reg; |
ic_data_load_end_ = |
- DecodeLoadWordFromPool(1, ®, &target_address_pool_index_); |
+ InstructionPattern::DecodeLoadWordFromPool(end_ - 1, |
+ ®, |
+ &target_address_pool_index_); |
ASSERT(reg == LR); |
} |
-uword CallPattern::Back(int n) const { |
- ASSERT(n > 0); |
- return *(end_ - n); |
-} |
- |
- |
-// Decodes a load sequence ending at end. Returns the register being loaded and |
-// the loaded object. |
-// Returns the location of the load sequence, counting the number of |
-// instructions back from the end of the call pattern. |
-int CallPattern::DecodeLoadObject(int end, Register* reg, Object* obj) { |
- ASSERT(end > 0); |
- uword instr = Back(end + 1); |
+// Decodes a load sequence ending at 'end' (the last instruction of the load |
+// sequence is the instruction before the one at end). Returns a pointer to |
+// the first instruction in the sequence. Returns the register being loaded |
+// and the loaded object in the output parameters 'reg' and 'obj' |
+// respectively. |
+const uword* InstructionPattern::DecodeLoadObject(const uword* end, |
+ const Array& object_pool, |
+ Register* reg, |
+ Object* obj) { |
+ uword instr = *(end - 1); |
if ((instr & 0xfff00000) == 0xe5900000) { // ldr reg, [reg, #+offset] |
- int index = 0; |
+ intptr_t index = 0; |
end = DecodeLoadWordFromPool(end, reg, &index); |
- *obj = object_pool_.At(index); |
+ *obj = object_pool.At(index); |
} else { |
- int value = 0; |
+ intptr_t value = 0; |
end = DecodeLoadWordImmediate(end, reg, &value); |
*obj = reinterpret_cast<RawObject*>(value); |
} |
@@ -55,18 +54,20 @@ int CallPattern::DecodeLoadObject(int end, Register* reg, Object* obj) { |
} |
-// Decodes a load sequence ending at end. Returns the register being loaded and |
-// the loaded immediate value. |
-// Returns the location of the load sequence, counting the number of |
-// instructions back from the end of the call pattern. |
-int CallPattern::DecodeLoadWordImmediate(int end, Register* reg, int* value) { |
- ASSERT(end > 0); |
- uword instr = Back(++end); |
- int imm = 0; |
+// Decodes a load sequence ending at 'end' (the last instruction of the load |
+// sequence is the instruction before the one at end). Returns a pointer to |
+// the first instruction in the sequence. Returns the register being loaded |
+// and the loaded immediate value in the output parameters 'reg' and 'value' |
+// respectively. |
+const uword* InstructionPattern::DecodeLoadWordImmediate(const uword* end, |
+ Register* reg, |
+ intptr_t* value) { |
+ uword instr = *(--end); |
+ intptr_t imm = 0; |
if ((instr & 0xfff00000) == 0xe3400000) { // movt reg, #imm_hi |
imm |= (instr & 0xf0000) << 12; |
imm |= (instr & 0xfff) << 16; |
- instr = Back(++end); |
+ instr = *(--end); |
} |
ASSERT((instr & 0xfff00000) == 0xe3000000); // movw reg, #imm_lo |
imm |= (instr & 0xf0000) >> 4; |
@@ -77,24 +78,26 @@ int CallPattern::DecodeLoadWordImmediate(int end, Register* reg, int* value) { |
} |
-// Decodes a load sequence ending at end. Returns the register being loaded and |
-// the index in the pool being read from. |
-// Returns the location of the load sequence, counting the number of |
-// instructions back from the end of the call pattern. |
-int CallPattern::DecodeLoadWordFromPool(int end, Register* reg, int* index) { |
- ASSERT(end > 0); |
- uword instr = Back(++end); |
- int offset = 0; |
+// Decodes a load sequence ending at 'end' (the last instruction of the load |
+// sequence is the instruction before the one at end). Returns a pointer to |
+// the first instruction in the sequence. Returns the register being loaded |
+// and the index in the pool being read from in the output parameters 'reg' |
+// and 'index' respectively. |
+const uword* InstructionPattern::DecodeLoadWordFromPool(const uword* end, |
+ Register* reg, |
+ intptr_t* index) { |
+ uword instr = *(--end); |
+ intptr_t offset = 0; |
if ((instr & 0xffff0000) == 0xe59a0000) { // ldr reg, [pp, #+offset] |
offset = instr & 0xfff; |
*reg = static_cast<Register>((instr & 0xf000) >> 12); |
} else { |
ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset] |
offset = instr & 0xfff; |
- instr = Back(++end); |
+ instr = *(--end); |
if ((instr & 0xffff0000) == 0xe28a0000) { // add reg, pp, shifter_op |
- const int rot = (instr & 0xf00) >> 7; |
- const int imm8 = instr & 0xff; |
+ const intptr_t rot = (instr & 0xf00) >> 7; |
+ const intptr_t imm8 = instr & 0xff; |
offset += (imm8 >> rot) | (imm8 << (32 - rot)); |
*reg = static_cast<Register>((instr & 0xf000) >> 12); |
} else { |
@@ -104,7 +107,7 @@ int CallPattern::DecodeLoadWordFromPool(int end, Register* reg, int* index) { |
} |
offset += kHeapObjectTag; |
ASSERT(Utils::IsAligned(offset, 4)); |
- *index = (offset - Array::data_offset())/4; |
+ *index = (offset - Array::data_offset()) / 4; |
return end; |
} |
@@ -112,7 +115,11 @@ int CallPattern::DecodeLoadWordFromPool(int end, Register* reg, int* index) { |
RawICData* CallPattern::IcData() { |
if (ic_data_.IsNull()) { |
Register reg; |
- args_desc_load_end_ = DecodeLoadObject(ic_data_load_end_, ®, &ic_data_); |
+ args_desc_load_end_ = |
+ InstructionPattern::DecodeLoadObject(ic_data_load_end_, |
+ object_pool_, |
+ ®, |
+ &ic_data_); |
ASSERT(reg == R5); |
} |
return ic_data_.raw(); |
@@ -123,7 +130,10 @@ RawArray* CallPattern::ClosureArgumentsDescriptor() { |
if (args_desc_.IsNull()) { |
IcData(); // Loading of the ic_data must be decoded first, if not already. |
Register reg; |
- DecodeLoadObject(args_desc_load_end_, ®, &args_desc_); |
+ InstructionPattern::DecodeLoadObject(args_desc_load_end_, |
+ object_pool_, |
+ ®, |
+ &args_desc_); |
ASSERT(reg == R4); |
} |
return args_desc_.raw(); |
@@ -198,4 +208,3 @@ void JumpPattern::SetTargetAddress(uword target_address) const { |
} // namespace dart |
#endif // defined TARGET_ARCH_ARM |
- |