Index: runtime/vm/code_patcher_mips.cc |
diff --git a/runtime/vm/code_patcher_mips.cc b/runtime/vm/code_patcher_mips.cc |
index f25b4602ef81f41ca737795854b7d634991490de..20df6cfc1e3c48f436dd538534e2db745185b879 100644 |
--- a/runtime/vm/code_patcher_mips.cc |
+++ b/runtime/vm/code_patcher_mips.cc |
@@ -84,6 +84,45 @@ RawFunction* CodePatcher::GetUnoptimizedStaticCallAt( |
return ic_data.GetTargetAt(0); |
} |
+ |
+// The expected code pattern of an edge counter in unoptimized code: |
+// lw t0, imm(pp) |
+class EdgeCounter : public ValueObject { |
+ public: |
+ EdgeCounter(uword start, const Code& code) |
+ : start_(start), object_pool_(Array::Handle(code.ObjectPool())) { |
+ ASSERT(IsValid(start)); |
+ } |
+ |
+ static bool IsValid(uword start) { |
+ Instr* instr = Instr::At(start); |
+ return (instr->OpcodeField() == LW) |
+ && (instr->RtField() == T0) |
+ && (instr->RsField() == PP); |
+ } |
+ |
+ RawObject* edge_counter() const { |
+ return object_pool_.At(IndexFromPPLoad(start_)); |
+ } |
+ |
+ private: |
+ static intptr_t IndexFromPPLoad(uword start) { |
+ ASSERT(IsValid(start)); |
+ int offset = Instr::At(start)->SImmField() + kHeapObjectTag; |
Florian Schneider
2013/09/30 08:55:38
What about indices in the constant pool greater th
|
+ return (offset - Array::data_offset()) / kWordSize; |
+ } |
+ |
+ uword start_; |
+ const Array& object_pool_; |
+}; |
+ |
+ |
+RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { |
+ ASSERT(code.ContainsInstructionAt(pc)); |
+ EdgeCounter counter(pc, code); |
+ return counter.edge_counter(); |
+} |
+ |
} // namespace dart |
#endif // defined TARGET_ARCH_MIPS |