OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 void CodeBreakpoint::PatchCode() { | 48 void CodeBreakpoint::PatchCode() { |
49 ASSERT(!is_enabled_); | 49 ASSERT(!is_enabled_); |
50 const Code& code = Code::Handle(code_); | 50 const Code& code = Code::Handle(code_); |
51 const Instructions& instrs = Instructions::Handle(code.instructions()); | 51 const Instructions& instrs = Instructions::Handle(code.instructions()); |
52 { | 52 { |
53 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); | 53 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
54 switch (breakpoint_kind_) { | 54 switch (breakpoint_kind_) { |
55 case PcDescriptors::kIcCall: | 55 case PcDescriptors::kIcCall: |
56 case PcDescriptors::kUnoptStaticCall: | 56 case PcDescriptors::kUnoptStaticCall: |
57 case PcDescriptors::kRuntimeCall: | 57 case PcDescriptors::kRuntimeCall: |
58 case PcDescriptors::kClosureCall: | 58 case PcDescriptors::kClosureCall: { |
59 case PcDescriptors::kReturn: { | |
60 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_); | 59 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_); |
61 ASSERT((offset > 0) && ((offset & 0x7) == 0)); | 60 ASSERT((offset > 0) && ((offset & 0x7) == 0)); |
62 saved_value_ = static_cast<uword>(offset); | 61 saved_value_ = static_cast<uword>(offset); |
63 const uint32_t stub_offset = | 62 const uint32_t stub_offset = |
64 InstructionPattern::OffsetFromPPIndex( | 63 InstructionPattern::OffsetFromPPIndex( |
65 Assembler::kBreakpointRuntimeCPIndex); | 64 Assembler::kBreakpointRuntimeCPIndex); |
66 CodePatcher::SetPoolOffsetAt(pc_, stub_offset); | 65 CodePatcher::SetPoolOffsetAt(pc_, stub_offset); |
67 break; | 66 break; |
68 } | 67 } |
69 default: | 68 default: |
70 UNREACHABLE(); | 69 UNREACHABLE(); |
71 } | 70 } |
72 } | 71 } |
73 is_enabled_ = true; | 72 is_enabled_ = true; |
74 } | 73 } |
75 | 74 |
76 | 75 |
77 void CodeBreakpoint::RestoreCode() { | 76 void CodeBreakpoint::RestoreCode() { |
78 ASSERT(is_enabled_); | 77 ASSERT(is_enabled_); |
79 const Code& code = Code::Handle(code_); | 78 const Code& code = Code::Handle(code_); |
80 const Instructions& instrs = Instructions::Handle(code.instructions()); | 79 const Instructions& instrs = Instructions::Handle(code.instructions()); |
81 { | 80 { |
82 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); | 81 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
83 switch (breakpoint_kind_) { | 82 switch (breakpoint_kind_) { |
84 case PcDescriptors::kIcCall: | 83 case PcDescriptors::kIcCall: |
85 case PcDescriptors::kUnoptStaticCall: | 84 case PcDescriptors::kUnoptStaticCall: |
86 case PcDescriptors::kClosureCall: | 85 case PcDescriptors::kClosureCall: |
87 case PcDescriptors::kRuntimeCall: | 86 case PcDescriptors::kRuntimeCall: { |
88 case PcDescriptors::kReturn: { | |
89 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_)); | 87 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_)); |
90 break; | 88 break; |
91 } | 89 } |
92 default: | 90 default: |
93 UNREACHABLE(); | 91 UNREACHABLE(); |
94 } | 92 } |
95 } | 93 } |
96 is_enabled_ = false; | 94 is_enabled_ = false; |
97 } | 95 } |
98 | 96 |
99 } // namespace dart | 97 } // namespace dart |
100 | 98 |
101 #endif // defined TARGET_ARCH_ARM64 | 99 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |