OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
9 | 9 |
10 #include "vm/cpu.h" | |
11 #include "vm/stub_code.h" | |
12 | |
10 namespace dart { | 13 namespace dart { |
11 | 14 |
12 RawInstance* ActivationFrame::GetLocalVarValue(intptr_t slot_index) { | 15 RawInstance* ActivationFrame::GetLocalVarValue(intptr_t slot_index) { |
13 UNIMPLEMENTED(); | 16 UNIMPLEMENTED(); |
14 return NULL; | 17 return NULL; |
15 } | 18 } |
16 | 19 |
20 | |
21 RawInstance* ActivationFrame::GetInstanceCallReceiver( | |
22 intptr_t num_actual_args) { | |
23 ASSERT(num_actual_args > 0); // At minimum we have a receiver on the stack. | |
24 // Stack pointer points to last argument that was pushed on the stack. | |
25 uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize); | |
26 return reinterpret_cast<RawInstance*>( | |
27 *reinterpret_cast<uword*>(receiver_addr)); | |
regis
2012/02/24 23:32:37
indentation
hausner
2012/02/27 22:03:57
Done.
| |
28 } | |
29 | |
30 | |
31 void Breakpoint::PatchFunctionReturn() { | |
32 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); | |
33 // movq %rbp,%rsp | |
34 ASSERT((code[0] == 0x48) && (code[1] == 0x8b) && (code[2] == 0xe5)); | |
35 ASSERT(code[3] == 0x5d); // popq %rbp | |
36 ASSERT(code[4] == 0xc3); // ret | |
37 // Next 8 bytes are nop instructions | |
regis
2012/02/24 23:32:37
If you use nop(8), this would have to change. Sinc
hausner
2012/02/27 22:03:57
Thanks.
| |
38 ASSERT((code[5] == 0x90) && (code[6] == 0x90) && | |
39 (code[7] == 0x90) && (code[8] == 0x90) && | |
40 (code[9] == 0x90) && (code[10] == 0x90) && | |
41 (code[11] == 0x90) && (code[12] == 0x90)); | |
42 // Smash code with call instruction and relative target address. | |
43 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); | |
44 code[0] = 0x49; | |
45 code[1] = 0xbb; | |
46 *reinterpret_cast<uword*>(&code[2]) = stub_addr; | |
47 code[10] = 0x41; | |
48 code[11] = 0xff; | |
49 code[12] = 0xd3; | |
50 CPU::FlushICache(pc_, 5); | |
51 } | |
52 | |
53 | |
54 void Breakpoint::RestoreFunctionReturn() { | |
55 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 13); | |
56 ASSERT((code[0] == 0x49) && (code[1] == 0xbb)); | |
57 code[0] = 0x48; // movq %rbp,%rsp | |
58 code[1] = 0x8b; | |
59 code[2] = 0xe5; | |
60 code[3] = 0x5d; // popq %rbp | |
61 code[4] = 0xc3; // ret | |
62 code[5] = 0x90; // nop | |
63 code[6] = 0x90; // nop | |
64 code[7] = 0x90; // nop | |
65 code[8] = 0x90; // nop | |
66 code[9] = 0x90; // nop | |
67 code[10] = 0x90; // nop | |
68 code[11] = 0x90; // nop | |
69 code[12] = 0x90; // nop | |
70 CPU::FlushICache(pc_, 5); | |
71 } | |
72 | |
17 } // namespace dart | 73 } // namespace dart |
18 | 74 |
19 #endif // defined TARGET_ARCH_X64 | 75 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |