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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
9 | 9 |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
11 #include "vm/cpu.h" | |
12 #include "vm/disassembler.h" | |
11 #include "vm/object.h" | 13 #include "vm/object.h" |
12 #include "vm/os.h" | 14 #include "vm/os.h" |
13 #include "vm/stack_frame.h" | 15 #include "vm/stack_frame.h" |
14 #include "vm/stub_code.h" | 16 #include "vm/stub_code.h" |
15 | 17 |
16 namespace dart { | 18 namespace dart { |
17 | 19 |
18 // TODO(hausner): Handle captured variables. | 20 // TODO(hausner): Handle captured variables. |
19 RawInstance* ActivationFrame::GetLocalVarValue(intptr_t slot_index) { | 21 RawInstance* ActivationFrame::GetLocalVarValue(intptr_t slot_index) { |
20 uword var_address = fp() + slot_index * kWordSize; | 22 uword var_address = fp() + slot_index * kWordSize; |
21 return reinterpret_cast<RawInstance*>( | 23 return reinterpret_cast<RawInstance*>( |
22 *reinterpret_cast<uword*>(var_address)); | 24 *reinterpret_cast<uword*>(var_address)); |
regis
2012/02/24 23:32:37
strange indentation
hausner
2012/02/27 22:03:57
Done.
| |
23 } | 25 } |
24 | 26 |
27 | |
28 RawInstance* ActivationFrame::GetInstanceCallReceiver( | |
29 intptr_t num_actual_args) { | |
regis
2012/02/24 23:32:37
strange indentation
hausner
2012/02/27 22:03:57
4 character indent from the function name is stran
| |
30 ASSERT(num_actual_args > 0); // At minimum we have a receiver on the stack. | |
31 // Stack pointer points to last argument that was pushed on the stack. | |
32 uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize); | |
33 return reinterpret_cast<RawInstance*>( | |
34 *reinterpret_cast<uword*>(receiver_addr)); | |
regis
2012/02/24 23:32:37
ditto
hausner
2012/02/27 22:03:57
Done.
| |
35 } | |
36 | |
37 | |
38 void Breakpoint::PatchFunctionReturn() { | |
39 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 5); | |
40 ASSERT((code[0] == 0x89) && (code[1] == 0xEC)); // mov esp,ebp | |
41 ASSERT(code[2] == 0x5D); // pop ebp | |
42 ASSERT(code[3] == 0xC3); // ret | |
43 ASSERT(code[4] == 0x90); // nop | |
44 | |
45 // Smash code with call instruction and relative target address. | |
46 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); | |
47 code[0] = 0xE8; | |
48 *reinterpret_cast<uword*>(&code[1]) = stub_addr - pc_; | |
49 CPU::FlushICache(pc_, 5); | |
50 } | |
51 | |
52 | |
53 void Breakpoint::RestoreFunctionReturn() { | |
54 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 5); | |
55 ASSERT(code[0] == 0xE8); | |
56 code[0] = 0x89; | |
57 code[1] = 0xEC; // mov esp,ebp | |
58 code[2] = 0x5D; // pop ebp | |
59 code[3] = 0xC3; // ret | |
60 code[4] = 0x90; // nop | |
61 CPU::FlushICache(pc_, 5); | |
62 } | |
63 | |
64 | |
65 | |
25 } // namespace dart | 66 } // namespace dart |
26 | 67 |
27 #endif // defined TARGET_ARCH_IA32 | 68 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |