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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 UNREACHABLE(); | 225 UNREACHABLE(); |
226 return NULL; | 226 return NULL; |
227 } | 227 } |
228 | 228 |
229 | 229 |
230 | 230 |
231 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 231 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
232 return InstanceCall::kPatternSize; | 232 return InstanceCall::kPatternSize; |
233 } | 233 } |
234 | 234 |
235 | |
236 // The expected code pattern of an edge counter in unoptimized code: | |
237 // b8 imm32 mov EAX, immediate | |
238 class EdgeCounter : public ValueObject { | |
239 public: | |
240 EdgeCounter(uword pc, const Code& ignored) | |
241 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()) { | |
242 ASSERT(IsValid(end_)); | |
243 } | |
244 | |
245 static bool IsValid(uword end) { | |
246 return (*reinterpret_cast<uint8_t*>(end - 5) == 0xb8); | |
247 } | |
248 | |
249 RawObject* edge_counter() const { | |
250 return *reinterpret_cast<RawObject**>(end_ - 4); | |
251 } | |
252 | |
253 private: | |
254 uword end_; | |
255 }; | |
256 | |
257 | |
258 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { | |
259 ASSERT(code.ContainsInstructionAt(pc)); | |
260 EdgeCounter counter(pc, code); | |
261 return counter.edge_counter(); | |
262 } | |
263 | |
264 } // namespace dart | 235 } // namespace dart |
265 | 236 |
266 #endif // defined TARGET_ARCH_IA32 | 237 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |