| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
| 9 | 9 |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 | 39 |
| 40 uword CodeBreakpoint::OrigStubAddress() const { | 40 uword CodeBreakpoint::OrigStubAddress() const { |
| 41 return saved_value_; | 41 return saved_value_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 | 44 |
| 45 void CodeBreakpoint::PatchCode() { | 45 void CodeBreakpoint::PatchCode() { |
| 46 ASSERT(!is_enabled_); | 46 ASSERT(!is_enabled_); |
| 47 switch (breakpoint_kind_) { | 47 const Code& code = Code::Handle(code_); |
| 48 case PcDescriptors::kIcCall: | 48 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 49 case PcDescriptors::kUnoptStaticCall: | 49 { |
| 50 case PcDescriptors::kRuntimeCall: | 50 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
| 51 case PcDescriptors::kClosureCall: | 51 switch (breakpoint_kind_) { |
| 52 case PcDescriptors::kReturn: { | 52 case PcDescriptors::kIcCall: |
| 53 const Code& code = Code::Handle(code_); | 53 case PcDescriptors::kUnoptStaticCall: |
| 54 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); | 54 case PcDescriptors::kRuntimeCall: |
| 55 CodePatcher::PatchStaticCallAt(pc_, code, | 55 case PcDescriptors::kClosureCall: |
| 56 StubCode::BreakpointRuntimeEntryPoint()); | 56 case PcDescriptors::kReturn: { |
| 57 break; | 57 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 58 CodePatcher::PatchStaticCallAt(pc_, code, |
| 59 StubCode::BreakpointRuntimeEntryPoint()); |
| 60 break; |
| 61 } |
| 62 default: |
| 63 UNREACHABLE(); |
| 58 } | 64 } |
| 59 default: | |
| 60 UNREACHABLE(); | |
| 61 } | 65 } |
| 62 is_enabled_ = true; | 66 is_enabled_ = true; |
| 63 } | 67 } |
| 64 | 68 |
| 65 | 69 |
| 66 void CodeBreakpoint::RestoreCode() { | 70 void CodeBreakpoint::RestoreCode() { |
| 67 ASSERT(is_enabled_); | 71 ASSERT(is_enabled_); |
| 68 switch (breakpoint_kind_) { | 72 const Code& code = Code::Handle(code_); |
| 69 case PcDescriptors::kIcCall: | 73 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 70 case PcDescriptors::kUnoptStaticCall: | 74 { |
| 71 case PcDescriptors::kClosureCall: | 75 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
| 72 case PcDescriptors::kRuntimeCall: | 76 switch (breakpoint_kind_) { |
| 73 case PcDescriptors::kReturn: { | 77 case PcDescriptors::kIcCall: |
| 74 const Code& code = Code::Handle(code_); | 78 case PcDescriptors::kUnoptStaticCall: |
| 75 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); | 79 case PcDescriptors::kClosureCall: |
| 76 break; | 80 case PcDescriptors::kRuntimeCall: |
| 81 case PcDescriptors::kReturn: { |
| 82 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); |
| 83 break; |
| 84 } |
| 85 default: |
| 86 UNREACHABLE(); |
| 77 } | 87 } |
| 78 default: | |
| 79 UNREACHABLE(); | |
| 80 } | 88 } |
| 81 is_enabled_ = false; | 89 is_enabled_ = false; |
| 82 } | 90 } |
| 83 | 91 |
| 84 } // namespace dart | 92 } // namespace dart |
| 85 | 93 |
| 86 #endif // defined TARGET_ARCH_IA32 | 94 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |