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" |
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 uword CodeBreakpoint::OrigStubAddress() const { | 16 uword CodeBreakpoint::OrigStubAddress() const { |
17 return saved_value_; | 17 return saved_value_; |
18 } | 18 } |
19 | 19 |
20 | 20 |
21 void CodeBreakpoint::PatchCode() { | 21 void CodeBreakpoint::PatchCode() { |
22 ASSERT(!is_enabled_); | 22 ASSERT(!is_enabled_); |
23 StubCode* stub_code = Isolate::Current()->stub_code(); | 23 StubCode* stub_code = Isolate::Current()->stub_code(); |
24 uword stub_target = 0; | 24 uword stub_target = 0; |
25 switch (breakpoint_kind_) { | 25 switch (breakpoint_kind_) { |
26 case RawPcDescriptors::kIcCall: | 26 case RawPcDescriptors::kIcCall: |
27 case RawPcDescriptors::kUnoptStaticCall: | 27 case RawPcDescriptors::kUnoptStaticCall: |
28 stub_target = stub_code->ICCallBreakpointEntryPoint(); | 28 stub_target = stub_code->ICCallBreakpointEntryPoint(); |
29 break; | 29 break; |
30 case RawPcDescriptors::kClosureCall: | |
31 stub_target = stub_code->ClosureCallBreakpointEntryPoint(); | |
32 break; | |
33 case RawPcDescriptors::kRuntimeCall: | 30 case RawPcDescriptors::kRuntimeCall: |
34 stub_target = stub_code->RuntimeCallBreakpointEntryPoint(); | 31 stub_target = stub_code->RuntimeCallBreakpointEntryPoint(); |
35 break; | 32 break; |
36 default: | 33 default: |
37 UNREACHABLE(); | 34 UNREACHABLE(); |
38 } | 35 } |
39 const Code& code = Code::Handle(code_); | 36 const Code& code = Code::Handle(code_); |
40 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); | 37 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
41 CodePatcher::PatchStaticCallAt(pc_, code, stub_target); | 38 CodePatcher::PatchStaticCallAt(pc_, code, stub_target); |
42 is_enabled_ = true; | 39 is_enabled_ = true; |
43 } | 40 } |
44 | 41 |
45 | 42 |
46 void CodeBreakpoint::RestoreCode() { | 43 void CodeBreakpoint::RestoreCode() { |
47 ASSERT(is_enabled_); | 44 ASSERT(is_enabled_); |
48 const Code& code = Code::Handle(code_); | 45 const Code& code = Code::Handle(code_); |
49 switch (breakpoint_kind_) { | 46 switch (breakpoint_kind_) { |
50 case RawPcDescriptors::kIcCall: | 47 case RawPcDescriptors::kIcCall: |
51 case RawPcDescriptors::kUnoptStaticCall: | 48 case RawPcDescriptors::kUnoptStaticCall: |
52 case RawPcDescriptors::kClosureCall: | |
53 case RawPcDescriptors::kRuntimeCall: { | 49 case RawPcDescriptors::kRuntimeCall: { |
54 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); | 50 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); |
55 break; | 51 break; |
56 } | 52 } |
57 default: | 53 default: |
58 UNREACHABLE(); | 54 UNREACHABLE(); |
59 } | 55 } |
60 is_enabled_ = false; | 56 is_enabled_ = false; |
61 } | 57 } |
62 | 58 |
63 } // namespace dart | 59 } // namespace dart |
64 | 60 |
65 #endif // defined TARGET_ARCH_ARM | 61 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |