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/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 | 35 |
36 uword CodeBreakpoint::OrigStubAddress() const { | 36 uword CodeBreakpoint::OrigStubAddress() const { |
37 return saved_value_; | 37 return saved_value_; |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 void CodeBreakpoint::PatchCode() { | 41 void CodeBreakpoint::PatchCode() { |
42 ASSERT(!is_enabled_); | 42 ASSERT(!is_enabled_); |
43 switch (breakpoint_kind_) { | 43 const Code& code = |
44 case PcDescriptors::kIcCall: { | 44 Code::Handle(Function::Handle(function_).unoptimized_code()); |
45 const Code& code = | 45 const Instructions& instrs = Instructions::Handle(code.instructions()); |
46 Code::Handle(Function::Handle(function_).unoptimized_code()); | 46 { |
47 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL); | 47 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
48 CodePatcher::PatchInstanceCallAt(pc_, code, | 48 switch (breakpoint_kind_) { |
49 StubCode::BreakpointDynamicEntryPoint()); | 49 case PcDescriptors::kIcCall: { |
50 break; | 50 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL); |
| 51 CodePatcher::PatchInstanceCallAt( |
| 52 pc_, code, StubCode::BreakpointDynamicEntryPoint()); |
| 53 break; |
| 54 } |
| 55 case PcDescriptors::kUnoptStaticCall: { |
| 56 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 57 CodePatcher::PatchStaticCallAt(pc_, code, |
| 58 StubCode::BreakpointStaticEntryPoint()); |
| 59 break; |
| 60 } |
| 61 case PcDescriptors::kRuntimeCall: |
| 62 case PcDescriptors::kClosureCall: |
| 63 case PcDescriptors::kReturn: { |
| 64 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 65 CodePatcher::PatchStaticCallAt(pc_, code, |
| 66 StubCode::BreakpointRuntimeEntryPoint()); |
| 67 break; |
| 68 } |
| 69 default: |
| 70 UNREACHABLE(); |
51 } | 71 } |
52 case PcDescriptors::kUnoptStaticCall: { | |
53 const Code& code = | |
54 Code::Handle(Function::Handle(function_).unoptimized_code()); | |
55 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); | |
56 CodePatcher::PatchStaticCallAt(pc_, code, | |
57 StubCode::BreakpointStaticEntryPoint()); | |
58 break; | |
59 } | |
60 case PcDescriptors::kRuntimeCall: | |
61 case PcDescriptors::kClosureCall: | |
62 case PcDescriptors::kReturn: { | |
63 const Code& code = | |
64 Code::Handle(Function::Handle(function_).unoptimized_code()); | |
65 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); | |
66 CodePatcher::PatchStaticCallAt(pc_, code, | |
67 StubCode::BreakpointRuntimeEntryPoint()); | |
68 break; | |
69 } | |
70 default: | |
71 UNREACHABLE(); | |
72 } | 72 } |
73 is_enabled_ = true; | 73 is_enabled_ = true; |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 void CodeBreakpoint::RestoreCode() { | 77 void CodeBreakpoint::RestoreCode() { |
78 ASSERT(is_enabled_); | 78 ASSERT(is_enabled_); |
79 switch (breakpoint_kind_) { | 79 const Code& code = |
80 case PcDescriptors::kIcCall: { | 80 Code::Handle(Function::Handle(function_).unoptimized_code()); |
81 const Code& code = | 81 const Instructions& instrs = Instructions::Handle(code.instructions()); |
82 Code::Handle(Function::Handle(function_).unoptimized_code()); | 82 { |
83 CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_); | 83 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
84 break; | 84 switch (breakpoint_kind_) { |
| 85 case PcDescriptors::kIcCall: { |
| 86 CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_); |
| 87 break; |
| 88 } |
| 89 case PcDescriptors::kUnoptStaticCall: |
| 90 case PcDescriptors::kClosureCall: |
| 91 case PcDescriptors::kRuntimeCall: |
| 92 case PcDescriptors::kReturn: { |
| 93 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); |
| 94 break; |
| 95 } |
| 96 default: |
| 97 UNREACHABLE(); |
85 } | 98 } |
86 case PcDescriptors::kUnoptStaticCall: | |
87 case PcDescriptors::kClosureCall: | |
88 case PcDescriptors::kRuntimeCall: | |
89 case PcDescriptors::kReturn: { | |
90 const Code& code = | |
91 Code::Handle(Function::Handle(function_).unoptimized_code()); | |
92 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); | |
93 break; | |
94 } | |
95 default: | |
96 UNREACHABLE(); | |
97 } | 99 } |
98 is_enabled_ = false; | 100 is_enabled_ = false; |
99 } | 101 } |
100 | 102 |
101 } // namespace dart | 103 } // namespace dart |
102 | 104 |
103 #endif // defined TARGET_ARCH_ARM | 105 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |