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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 9
10 #include "vm/instructions.h" 10 #include "vm/instructions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ASSERT(code.ContainsInstructionAt(return_address)); 77 ASSERT(code.ContainsInstructionAt(return_address));
78 CallPattern static_call(return_address, code); 78 CallPattern static_call(return_address, code);
79 ICData& ic_data = ICData::Handle(); 79 ICData& ic_data = ICData::Handle();
80 ic_data ^= static_call.IcData(); 80 ic_data ^= static_call.IcData();
81 if (ic_data_result != NULL) { 81 if (ic_data_result != NULL) {
82 *ic_data_result = ic_data.raw(); 82 *ic_data_result = ic_data.raw();
83 } 83 }
84 return ic_data.GetTargetAt(0); 84 return ic_data.GetTargetAt(0);
85 } 85 }
86 86
87
88 // The expected code pattern of an edge counter in unoptimized code:
89 // lw t0, imm(pp)
90 class EdgeCounter : public ValueObject {
91 public:
92 EdgeCounter(uword start, const Code& code)
93 : start_(start), object_pool_(Array::Handle(code.ObjectPool())) {
94 ASSERT(IsValid(start));
95 }
96
97 static bool IsValid(uword start) {
98 Instr* instr = Instr::At(start);
99 return (instr->OpcodeField() == LW)
100 && (instr->RtField() == T0)
101 && (instr->RsField() == PP);
102 }
103
104 RawObject* edge_counter() const {
105 return object_pool_.At(IndexFromPPLoad(start_));
106 }
107
108 private:
109 static intptr_t IndexFromPPLoad(uword start) {
110 ASSERT(IsValid(start));
111 int offset = Instr::At(start)->SImmField() + kHeapObjectTag;
Florian Schneider 2013/09/30 08:55:38 What about indices in the constant pool greater th
112 return (offset - Array::data_offset()) / kWordSize;
113 }
114
115 uword start_;
116 const Array& object_pool_;
117 };
118
119
120 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
121 ASSERT(code.ContainsInstructionAt(pc));
122 EdgeCounter counter(pc, code);
123 return counter.edge_counter();
124 }
125
87 } // namespace dart 126 } // namespace dart
88 127
89 #endif // defined TARGET_ARCH_MIPS 128 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698