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

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: 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) 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 uword CodePatcher::GetNativeCallAt(uword return_address, 251 uword CodePatcher::GetNativeCallAt(uword return_address,
252 const Code& code, 252 const Code& code,
253 NativeFunction* target) { 253 NativeFunction* target) {
254 ASSERT(code.ContainsInstructionAt(return_address)); 254 ASSERT(code.ContainsInstructionAt(return_address));
255 NativeCall call(return_address, code); 255 NativeCall call(return_address, code);
256 *target = call.native_function(); 256 *target = call.native_function();
257 return call.target(); 257 return call.target();
258 } 258 }
259 259
260
261 // The expected code pattern of an edge counter in unoptimized code:
262 // 49 8b 87 imm32 mov RAX, [PP + offset]
263 class EdgeCounter : public ValueObject {
264 public:
265 EdgeCounter(uword pc, const Code& code)
266 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()),
267 object_pool_(ObjectPool::Handle(code.GetObjectPool())) {
268 ASSERT(IsValid(end_));
269 }
270
271 static bool IsValid(uword end) {
272 uint8_t* bytes = reinterpret_cast<uint8_t*>(end - 7);
273 return (bytes[0] == 0x49) && (bytes[1] == 0x8b) && (bytes[2] == 0x87);
274 }
275
276 RawObject* edge_counter() const {
277 return object_pool_.ObjectAt(IndexFromPPLoad(end_ - 4));
278 }
279
280 private:
281 uword end_;
282 const ObjectPool& object_pool_;
283 };
284
285
286 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
287 ASSERT(code.ContainsInstructionAt(pc));
288 EdgeCounter counter(pc, code);
289 return counter.edge_counter();
290 }
291
292 } // namespace dart 260 } // namespace dart
293 261
294 #endif // defined TARGET_ARCH_X64 262 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698