OLD | NEW |
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 Loading... |
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 |
OLD | NEW |