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