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

Side by Side Diff: runtime/vm/code_patcher_ia32.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 *target = call.native_function(); 253 *target = call.native_function();
254 return call.target(); 254 return call.target();
255 } 255 }
256 256
257 257
258 258
259 intptr_t CodePatcher::InstanceCallSizeInBytes() { 259 intptr_t CodePatcher::InstanceCallSizeInBytes() {
260 return InstanceCall::kNumInstructions * InstanceCall::kInstructionSize; 260 return InstanceCall::kNumInstructions * InstanceCall::kInstructionSize;
261 } 261 }
262 262
263
264 // The expected code pattern of an edge counter in unoptimized code:
265 // b8 imm32 mov EAX, immediate
266 class EdgeCounter : public ValueObject {
267 public:
268 EdgeCounter(uword pc, const Code& ignored)
269 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()) {
270 ASSERT(IsValid(end_));
271 }
272
273 static bool IsValid(uword end) {
274 return (*reinterpret_cast<uint8_t*>(end - 5) == 0xb8);
275 }
276
277 RawObject* edge_counter() const {
278 return *reinterpret_cast<RawObject**>(end_ - 4);
279 }
280
281 private:
282 uword end_;
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 263 } // namespace dart
293 264
294 #endif // defined TARGET_ARCH_IA32 265 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698