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

Side by Side Diff: runtime/vm/code_patcher_x64.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: Created 5 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
« no previous file with comments | « runtime/vm/code_patcher_mips.cc ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 RawCode* CodePatcher::GetNativeCallAt(uword return_address, 262 RawCode* CodePatcher::GetNativeCallAt(uword return_address,
263 const Code& code, 263 const Code& code,
264 NativeFunction* target) { 264 NativeFunction* target) {
265 ASSERT(code.ContainsInstructionAt(return_address)); 265 ASSERT(code.ContainsInstructionAt(return_address));
266 NativeCall call(return_address, code); 266 NativeCall call(return_address, code);
267 *target = call.native_function(); 267 *target = call.native_function();
268 return call.target(); 268 return call.target();
269 } 269 }
270 270
271
272 // The expected code pattern of an edge counter in unoptimized code:
273 // 49 8b 87 imm32 mov RAX, [PP + offset]
274 class EdgeCounter : public ValueObject {
275 public:
276 EdgeCounter(uword pc, const Code& code)
277 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()),
278 object_pool_(ObjectPool::Handle(code.GetObjectPool())) {
279 ASSERT(IsValid(end_));
280 }
281
282 static bool IsValid(uword end) {
283 uint8_t* bytes = reinterpret_cast<uint8_t*>(end - 7);
284 return (bytes[0] == 0x49) && (bytes[1] == 0x8b) && (bytes[2] == 0x87);
285 }
286
287 RawObject* edge_counter() const {
288 return object_pool_.ObjectAt(IndexFromPPLoad(end_ - 4));
289 }
290
291 private:
292 uword end_;
293 const ObjectPool& object_pool_;
294 };
295
296
297 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
298 ASSERT(code.ContainsInstructionAt(pc));
299 EdgeCounter counter(pc, code);
300 return counter.edge_counter();
301 }
302
303 } // namespace dart 271 } // namespace dart
304 272
305 #endif // defined TARGET_ARCH_X64 273 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_mips.cc ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698