Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: runtime/vm/code_patcher_mips.cc

Issue 24744002: Pattern match on generated code to find edge counters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698