Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: runtime/vm/debugger_arm.cc

Issue 1139403002: VM: Clean up ARM/MIPS breakpoint patching (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/debugger_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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();
24 uword stub_target = 0;
25 switch (breakpoint_kind_) {
26 case RawPcDescriptors::kIcCall:
27 case RawPcDescriptors::kUnoptStaticCall:
28 stub_target = stub_code->ICCallBreakpointEntryPoint();
29 break;
30 case RawPcDescriptors::kClosureCall:
31 stub_target = stub_code->ClosureCallBreakpointEntryPoint();
32 break;
33 case RawPcDescriptors::kRuntimeCall:
34 stub_target = stub_code->RuntimeCallBreakpointEntryPoint();
35 break;
36 default:
37 UNREACHABLE();
38 }
23 const Code& code = Code::Handle(code_); 39 const Code& code = Code::Handle(code_);
24 const Instructions& instrs = Instructions::Handle(code.instructions()); 40 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
25 Isolate* isolate = Isolate::Current(); 41 CodePatcher::PatchStaticCallAt(pc_, code, stub_target);
26 {
27 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
28 switch (breakpoint_kind_) {
29 case RawPcDescriptors::kIcCall:
30 case RawPcDescriptors::kUnoptStaticCall: {
31 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
32 CodePatcher::PatchStaticCallAt(
33 pc_, code, isolate->stub_code()->ICCallBreakpointEntryPoint());
34 break;
35 }
36 case RawPcDescriptors::kClosureCall: {
37 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
38 CodePatcher::PatchStaticCallAt(
39 pc_, code, isolate->stub_code()->ClosureCallBreakpointEntryPoint());
40 break;
41 }
42 case RawPcDescriptors::kRuntimeCall: {
43 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
44 CodePatcher::PatchStaticCallAt(
45 pc_, code, isolate->stub_code()->RuntimeCallBreakpointEntryPoint());
46 break;
47 }
48 default:
49 UNREACHABLE();
50 }
51 }
52 is_enabled_ = true; 42 is_enabled_ = true;
53 } 43 }
54 44
55 45
56 void CodeBreakpoint::RestoreCode() { 46 void CodeBreakpoint::RestoreCode() {
57 ASSERT(is_enabled_); 47 ASSERT(is_enabled_);
58 const Code& code = Code::Handle(code_); 48 const Code& code = Code::Handle(code_);
59 const Instructions& instrs = Instructions::Handle(code.instructions()); 49 switch (breakpoint_kind_) {
60 { 50 case RawPcDescriptors::kIcCall:
61 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); 51 case RawPcDescriptors::kUnoptStaticCall:
62 switch (breakpoint_kind_) { 52 case RawPcDescriptors::kClosureCall:
63 case RawPcDescriptors::kIcCall: 53 case RawPcDescriptors::kRuntimeCall: {
64 case RawPcDescriptors::kUnoptStaticCall: 54 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
65 case RawPcDescriptors::kClosureCall: 55 break;
66 case RawPcDescriptors::kRuntimeCall: {
67 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_);
68 break;
69 }
70 default:
71 UNREACHABLE();
72 } 56 }
57 default:
58 UNREACHABLE();
73 } 59 }
74 is_enabled_ = false; 60 is_enabled_ = false;
75 } 61 }
76 62
77 } // namespace dart 63 } // namespace dart
78 64
79 #endif // defined TARGET_ARCH_ARM 65 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/debugger_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698