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" |
11 #include "vm/instructions.h" | 11 #include "vm/instructions.h" |
12 #include "vm/stub_code.h" | 12 #include "vm/stub_code.h" |
13 | 13 |
14 namespace dart { | 14 namespace dart { |
15 | 15 |
16 #ifndef PRODUCT | 16 #ifndef PRODUCT |
17 | 17 |
18 RawCode* CodeBreakpoint::OrigStubAddress() const { | 18 RawCode* CodeBreakpoint::OrigStubAddress() const { |
19 return saved_value_; | 19 return saved_value_; |
20 } | 20 } |
21 | 21 |
22 | |
23 void CodeBreakpoint::PatchCode() { | 22 void CodeBreakpoint::PatchCode() { |
24 ASSERT(!is_enabled_); | 23 ASSERT(!is_enabled_); |
25 Code& stub_target = Code::Handle(); | 24 Code& stub_target = Code::Handle(); |
26 switch (breakpoint_kind_) { | 25 switch (breakpoint_kind_) { |
27 case RawPcDescriptors::kIcCall: | 26 case RawPcDescriptors::kIcCall: |
28 case RawPcDescriptors::kUnoptStaticCall: | 27 case RawPcDescriptors::kUnoptStaticCall: |
29 stub_target = StubCode::ICCallBreakpoint_entry()->code(); | 28 stub_target = StubCode::ICCallBreakpoint_entry()->code(); |
30 break; | 29 break; |
31 case RawPcDescriptors::kRuntimeCall: { | 30 case RawPcDescriptors::kRuntimeCall: { |
32 stub_target = StubCode::RuntimeCallBreakpoint_entry()->code(); | 31 stub_target = StubCode::RuntimeCallBreakpoint_entry()->code(); |
33 break; | 32 break; |
34 } | 33 } |
35 default: | 34 default: |
36 UNREACHABLE(); | 35 UNREACHABLE(); |
37 } | 36 } |
38 const Code& code = Code::Handle(code_); | 37 const Code& code = Code::Handle(code_); |
39 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); | 38 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
40 CodePatcher::PatchPoolPointerCallAt(pc_, code, stub_target); | 39 CodePatcher::PatchPoolPointerCallAt(pc_, code, stub_target); |
41 is_enabled_ = true; | 40 is_enabled_ = true; |
42 } | 41 } |
43 | 42 |
44 | |
45 void CodeBreakpoint::RestoreCode() { | 43 void CodeBreakpoint::RestoreCode() { |
46 ASSERT(is_enabled_); | 44 ASSERT(is_enabled_); |
47 const Code& code = Code::Handle(code_); | 45 const Code& code = Code::Handle(code_); |
48 switch (breakpoint_kind_) { | 46 switch (breakpoint_kind_) { |
49 case RawPcDescriptors::kIcCall: | 47 case RawPcDescriptors::kIcCall: |
50 case RawPcDescriptors::kUnoptStaticCall: | 48 case RawPcDescriptors::kUnoptStaticCall: |
51 case RawPcDescriptors::kRuntimeCall: { | 49 case RawPcDescriptors::kRuntimeCall: { |
52 CodePatcher::PatchPoolPointerCallAt(pc_, code, | 50 CodePatcher::PatchPoolPointerCallAt(pc_, code, |
53 Code::Handle(saved_value_)); | 51 Code::Handle(saved_value_)); |
54 break; | 52 break; |
55 } | 53 } |
56 default: | 54 default: |
57 UNREACHABLE(); | 55 UNREACHABLE(); |
58 } | 56 } |
59 is_enabled_ = false; | 57 is_enabled_ = false; |
60 } | 58 } |
61 | 59 |
62 #endif // !PRODUCT | 60 #endif // !PRODUCT |
63 | 61 |
64 } // namespace dart | 62 } // namespace dart |
65 | 63 |
66 #endif // defined TARGET_ARCH_ARM64 | 64 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |