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

Unified Diff: runtime/vm/code_patcher_ia32.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: Incorporated review comments. 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
« no previous file with comments | « runtime/vm/code_patcher_arm.cc ('k') | runtime/vm/code_patcher_mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_patcher_ia32.cc
diff --git a/runtime/vm/code_patcher_ia32.cc b/runtime/vm/code_patcher_ia32.cc
index 9cccd56c19639dbc612561ff512f2b1b8cb77ddd..8143d6982519326621bbb00cb6af27b27395dd7a 100644
--- a/runtime/vm/code_patcher_ia32.cc
+++ b/runtime/vm/code_patcher_ia32.cc
@@ -149,7 +149,7 @@ class StaticCall : public ValueObject {
};
-// The expected pattern of a dart closure call:
+// The expected pattern of a Dart closure call:
// mov EDX, arguments_descriptor_array
// call target_address
// <- return address
@@ -259,6 +259,39 @@ intptr_t CodePatcher::InstanceCallSizeInBytes() {
return InstanceCall::kNumInstructions * InstanceCall::kInstructionSize;
}
+
+// The expected code pattern of an edge counter in unoptimized code:
+// b8 imm32 mov EAX, immediate
+class EdgeCounter : public ValueObject {
+ public:
+ EdgeCounter(uword pc, const Code& ignored) : end_(pc - kAdjust) {
+ ASSERT(IsValid(end_));
+ }
+
+ static bool IsValid(uword end) {
+ return (*reinterpret_cast<uint8_t*>(end - 5) == 0xb8);
+ }
+
+ RawObject* edge_counter() const {
+ return *reinterpret_cast<RawObject**>(end_ - 4);
+ }
+
+ private:
+ // The edge counter load is followed by the fixed-size edge counter
+ // incrementing code:
+ // 83 40 0b 02 add [eax+0xb],0x2
+ static const intptr_t kAdjust = 4;
+
+ uword end_;
+};
+
+
+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_IA32
« no previous file with comments | « runtime/vm/code_patcher_arm.cc ('k') | runtime/vm/code_patcher_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698