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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 RawInstance* ActivationFrame::GetInstanceCallReceiver( | 28 RawInstance* ActivationFrame::GetInstanceCallReceiver( |
29 intptr_t num_actual_args) { | 29 intptr_t num_actual_args) { |
30 ASSERT(num_actual_args > 0); // At minimum we have a receiver on the stack. | 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. | 31 // Stack pointer points to last argument that was pushed on the stack. |
32 uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize); | 32 uword receiver_addr = sp() + ((num_actual_args - 1) * kWordSize); |
33 return reinterpret_cast<RawInstance*>( | 33 return reinterpret_cast<RawInstance*>( |
34 *reinterpret_cast<uword*>(receiver_addr)); | 34 *reinterpret_cast<uword*>(receiver_addr)); |
35 } | 35 } |
36 | 36 |
37 | 37 |
| 38 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { |
| 39 // At a minimum we have the closure object on the stack. |
| 40 ASSERT(num_actual_args > 0); |
| 41 // Stack pointer points to last argument that was pushed on the stack. |
| 42 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); |
| 43 return reinterpret_cast<RawObject*>( |
| 44 *reinterpret_cast<uword*>(closure_addr)); |
| 45 } |
| 46 |
| 47 |
38 void CodeBreakpoint::PatchFunctionReturn() { | 48 void CodeBreakpoint::PatchFunctionReturn() { |
39 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 5); | 49 uint8_t* code = reinterpret_cast<uint8_t*>(pc_ - 5); |
40 ASSERT((code[0] == 0x89) && (code[1] == 0xEC)); // mov esp,ebp | 50 ASSERT((code[0] == 0x89) && (code[1] == 0xEC)); // mov esp,ebp |
41 ASSERT(code[2] == 0x5D); // pop ebp | 51 ASSERT(code[2] == 0x5D); // pop ebp |
42 ASSERT(code[3] == 0xC3); // ret | 52 ASSERT(code[3] == 0xC3); // ret |
43 ASSERT(code[4] == 0x90); // nop | 53 ASSERT(code[4] == 0x90); // nop |
44 | 54 |
45 // Smash code with call instruction and relative target address. | 55 // Smash code with call instruction and relative target address. |
46 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); | 56 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); |
47 code[0] = 0xE8; | 57 code[0] = 0xE8; |
(...skipping 11 matching lines...) Expand all Loading... |
59 code[3] = 0xC3; // ret | 69 code[3] = 0xC3; // ret |
60 code[4] = 0x90; // nop | 70 code[4] = 0x90; // nop |
61 CPU::FlushICache(pc_ - 5, 5); | 71 CPU::FlushICache(pc_ - 5, 5); |
62 } | 72 } |
63 | 73 |
64 | 74 |
65 | 75 |
66 } // namespace dart | 76 } // namespace dart |
67 | 77 |
68 #endif // defined TARGET_ARCH_IA32 | 78 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |