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