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

Side by Side Diff: runtime/vm/code_patcher_arm64.cc

Issue 1343383003: VM: Store edge counters in one per-function array. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: clean up comments, save space in IL Instruction class. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/instructions.h" 10 #include "vm/instructions.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 uword CodePatcher::GetNativeCallAt(uword return_address, 132 uword CodePatcher::GetNativeCallAt(uword return_address,
133 const Code& code, 133 const Code& code,
134 NativeFunction* target) { 134 NativeFunction* target) {
135 ASSERT(code.ContainsInstructionAt(return_address)); 135 ASSERT(code.ContainsInstructionAt(return_address));
136 NativeCallPattern call(return_address, code); 136 NativeCallPattern call(return_address, code);
137 *target = call.native_function(); 137 *target = call.native_function();
138 return call.target(); 138 return call.target();
139 } 139 }
140 140
141
142 // This class pattern matches on a load from the object pool. Loading on
143 // ARM64 is complicated because it can take more than one form. We
144 // match backwards from the end of the sequence so we can reuse the code for
145 // matching object pool loads at calls.
146 class EdgeCounter : public ValueObject {
147 public:
148 EdgeCounter(uword pc, const Code& code)
149 : end_(pc - kAdjust),
150 object_pool_(ObjectPool::Handle(code.GetObjectPool())) {
151 // An IsValid predicate is complicated and duplicates the code in the
152 // decoding function. Instead we rely on decoding the pattern which
153 // will assert partial validity.
154 }
155
156 RawObject* edge_counter() const {
157 Register ignored;
158 intptr_t index;
159 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index);
160 ASSERT(ignored == R0);
161 return object_pool_.ObjectAt(index);
162 }
163
164 private:
165 // The object pool load is followed by the fixed-size edge counter
166 // incrementing code:
167 // ldr ip, [r0, #+11]
168 // adds ip, ip, #2
169 // str ip, [r0, #+11]
170 static const intptr_t kAdjust = 3 * Instr::kInstrSize;
171
172 uword end_;
173 const ObjectPool& object_pool_;
174 };
175
176
177 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
178 ASSERT(code.ContainsInstructionAt(pc));
179 EdgeCounter counter(pc, code);
180 return counter.edge_counter();
181 }
182
183 } // namespace dart 141 } // namespace dart
184 142
185 #endif // defined TARGET_ARCH_ARM64 143 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698