Index: runtime/vm/code_patcher_x64.cc |
diff --git a/runtime/vm/code_patcher_x64.cc b/runtime/vm/code_patcher_x64.cc |
index b4fa546319984ebfd14fb300059820f465ee112e..4a6da2b943ee8660d60a9142389b40db202c4a6a 100644 |
--- a/runtime/vm/code_patcher_x64.cc |
+++ b/runtime/vm/code_patcher_x64.cc |
@@ -102,8 +102,9 @@ class UnoptimizedStaticCall : public UnoptimizedCall { |
// 7: <- return address |
class PoolPointerCall : public ValueObject { |
public: |
- explicit PoolPointerCall(uword return_address) |
- : start_(return_address - kCallPatternSize) { |
+ explicit PoolPointerCall(uword return_address, const Code& code) |
+ : start_(return_address - kCallPatternSize), |
+ object_pool_(Array::Handle(code.ObjectPool())) { |
ASSERT(IsValid(return_address)); |
} |
@@ -116,79 +117,50 @@ class PoolPointerCall : public ValueObject { |
(code_bytes[2] == 0x97); |
} |
- int32_t pp_offset() const { |
- return *reinterpret_cast<int32_t*>(start_ + 3); |
- } |
- |
- void set_pp_offset(int32_t offset) const { |
- *reinterpret_cast<int32_t*>(start_ + 3) = offset; |
- CPU::FlushICache(start_, kCallPatternSize); |
- } |
- |
- protected: |
- uword start_; |
- |
- private: |
- DISALLOW_IMPLICIT_CONSTRUCTORS(PoolPointerCall); |
-}; |
- |
- |
-// The expected pattern of a dart static call: |
-// 0: 41 ff 97 imm32 call [PP + off] |
-// 7: <- return address |
-class StaticCall : public PoolPointerCall { |
- public: |
- StaticCall(uword return_address, const Code& code) |
- : PoolPointerCall(return_address), |
- object_pool_(Array::Handle(code.ObjectPool())) { |
- ASSERT(IsValid(return_address)); |
- ASSERT(kCallPatternSize == Assembler::kCallExternalLabelSize); |
+ intptr_t pp_index() const { |
+ return InstructionPattern::IndexFromPPLoad(start_ + 3); |
} |
- uword target() const { |
- intptr_t index = InstructionPattern::IndexFromPPLoad(start_ + 3); |
- return reinterpret_cast<uword>(object_pool_.At(index)); |
+ uword Target() const { |
+ return reinterpret_cast<uword>(object_pool_.At(pp_index())); |
} |
- void set_target(uword target) const { |
- intptr_t index = InstructionPattern::IndexFromPPLoad(start_ + 3); |
+ void SetTarget(uword target) const { |
const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(target)); |
- object_pool_.SetAt(index, smi); |
+ object_pool_.SetAt(pp_index(), smi); |
// No need to flush the instruction cache, since the code is not modified. |
} |
- private: |
+ protected: |
+ uword start_; |
const Array& object_pool_; |
- DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); |
+ |
+ private: |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PoolPointerCall); |
}; |
uword CodePatcher::GetStaticCallTargetAt(uword return_address, |
const Code& code) { |
ASSERT(code.ContainsInstructionAt(return_address)); |
- StaticCall call(return_address, code); |
- return call.target(); |
+ PoolPointerCall call(return_address, code); |
+ return call.Target(); |
} |
void CodePatcher::PatchStaticCallAt(uword return_address, |
const Code& code, |
uword new_target) { |
- ASSERT(code.ContainsInstructionAt(return_address)); |
- StaticCall call(return_address, code); |
- call.set_target(new_target); |
+ PatchPoolPointerCallAt(return_address, code, new_target); |
} |
-int32_t CodePatcher::GetPoolOffsetAt(uword return_address) { |
- PoolPointerCall call(return_address); |
- return call.pp_offset(); |
-} |
- |
- |
-void CodePatcher::SetPoolOffsetAt(uword return_address, int32_t offset) { |
- PoolPointerCall call(return_address); |
- call.set_pp_offset(offset); |
+void CodePatcher::PatchPoolPointerCallAt(uword return_address, |
+ const Code& code, |
+ uword new_target) { |
+ ASSERT(code.ContainsInstructionAt(return_address)); |
+ PoolPointerCall call(return_address, code); |
+ call.SetTarget(new_target); |
} |