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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
10 #include "vm/instructions.h" | 10 #include "vm/instructions.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { | 25 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { |
26 // At a minimum we have the closure object on the stack. | 26 // At a minimum we have the closure object on the stack. |
27 ASSERT(num_actual_args > 0); | 27 ASSERT(num_actual_args > 0); |
28 // Stack pointer points to last argument that was pushed on the stack. | 28 // Stack pointer points to last argument that was pushed on the stack. |
29 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); | 29 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); |
30 return reinterpret_cast<RawObject*>( | 30 return reinterpret_cast<RawObject*>( |
31 *reinterpret_cast<uword*>(closure_addr)); | 31 *reinterpret_cast<uword*>(closure_addr)); |
32 } | 32 } |
33 | 33 |
34 | |
35 void CodeBreakpoint::PatchFunctionReturn() { | |
36 uword* code = reinterpret_cast<uword*>(pc_ - 3 * Instr::kInstrSize); | |
37 ASSERT(code[0] == 0xe8bd4c00); // ldmia sp!, {pp, fp, lr} | |
38 ASSERT(code[1] == 0xe28dd004); // add sp, sp, #4 | |
39 ASSERT(code[2] == 0xe12fff1e); // bx lr | |
40 | |
41 // Smash code with call instruction and target address. | |
42 uword stub_addr = StubCode::BreakpointReturnEntryPoint(); | |
43 uint16_t target_lo = stub_addr & 0xffff; | |
44 uint16_t target_hi = stub_addr >> 16; | |
45 uword movw = 0xe300c000 | ((target_lo >> 12) << 16) | (target_lo & 0xfff); | |
46 uword movt = 0xe340c000 | ((target_hi >> 12) << 16) | (target_hi & 0xfff); | |
47 uword blx = 0xe12fff3c; | |
48 code[0] = movw; // movw ip, #target_lo | |
49 code[1] = movt; // movt ip, #target_hi | |
50 code[2] = blx; // blx ip | |
51 CPU::FlushICache(pc_ - 3 * Instr::kInstrSize, 3 * Instr::kInstrSize); | |
52 } | |
53 | |
54 | |
55 void CodeBreakpoint::RestoreFunctionReturn() { | |
56 uword* code = reinterpret_cast<uword*>(pc_ - 3 * Instr::kInstrSize); | |
57 ASSERT((code[0] & 0xfff0f000) == 0xe300c000); | |
58 code[0] = 0xe8bd4c00; // ldmia sp!, {pp, fp, lr} | |
59 code[1] = 0xe28dd004; // add sp, sp, #4 | |
60 code[2] = 0xe12fff1e; // bx lr | |
61 CPU::FlushICache(pc_ - 3 * Instr::kInstrSize, 3 * Instr::kInstrSize); | |
62 } | |
63 | |
64 } // namespace dart | 34 } // namespace dart |
65 | 35 |
66 #endif // defined TARGET_ARCH_ARM | 36 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |