| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 static Instr* FastSmiInstructionFromReturnAddress(uword pc) { | 28 static Instr* FastSmiInstructionFromReturnAddress(uword pc) { |
| 29 return reinterpret_cast<Instr*>(pc) - 2; | 29 return reinterpret_cast<Instr*>(pc) - 2; |
| 30 } | 30 } |
| 31 | 31 |
| 32 | 32 |
| 33 void CodeBreakpoint::PatchCode() { | 33 void CodeBreakpoint::PatchCode() { |
| 34 ASSERT(!is_enabled_); | 34 ASSERT(!is_enabled_); |
| 35 const Code& code = Code::Handle(code_); | 35 const Code& code = Code::Handle(code_); |
| 36 const Instructions& instrs = Instructions::Handle(code.instructions()); | 36 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 37 { | 37 { |
| 38 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.size()); | 38 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.Size()); |
| 39 saved_value_ = *CallInstructionFromReturnAddress(pc_); | 39 saved_value_ = *CallInstructionFromReturnAddress(pc_); |
| 40 switch (breakpoint_kind_) { | 40 switch (breakpoint_kind_) { |
| 41 case RawPcDescriptors::kIcCall: | 41 case RawPcDescriptors::kIcCall: |
| 42 case RawPcDescriptors::kUnoptStaticCall: { | 42 case RawPcDescriptors::kUnoptStaticCall: { |
| 43 // DebugBreak has an A operand matching the call it replaces. | 43 // DebugBreak has an A operand matching the call it replaces. |
| 44 // This ensures that Return instructions continue to work - as they | 44 // This ensures that Return instructions continue to work - as they |
| 45 // look at calls to figure out how many arguments to drop. | 45 // look at calls to figure out how many arguments to drop. |
| 46 *CallInstructionFromReturnAddress(pc_) = Bytecode::Encode( | 46 *CallInstructionFromReturnAddress(pc_) = Bytecode::Encode( |
| 47 Bytecode::kDebugBreak, Bytecode::DecodeArgc(saved_value_), 0, 0); | 47 Bytecode::kDebugBreak, Bytecode::DecodeArgc(saved_value_), 0, 0); |
| 48 break; | 48 break; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 } | 70 } |
| 71 is_enabled_ = true; | 71 is_enabled_ = true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 void CodeBreakpoint::RestoreCode() { | 75 void CodeBreakpoint::RestoreCode() { |
| 76 ASSERT(is_enabled_); | 76 ASSERT(is_enabled_); |
| 77 const Code& code = Code::Handle(code_); | 77 const Code& code = Code::Handle(code_); |
| 78 const Instructions& instrs = Instructions::Handle(code.instructions()); | 78 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 79 { | 79 { |
| 80 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.size()); | 80 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.Size()); |
| 81 switch (breakpoint_kind_) { | 81 switch (breakpoint_kind_) { |
| 82 case RawPcDescriptors::kIcCall: | 82 case RawPcDescriptors::kIcCall: |
| 83 case RawPcDescriptors::kUnoptStaticCall: | 83 case RawPcDescriptors::kUnoptStaticCall: |
| 84 case RawPcDescriptors::kRuntimeCall: { | 84 case RawPcDescriptors::kRuntimeCall: { |
| 85 *CallInstructionFromReturnAddress(pc_) = saved_value_; | 85 *CallInstructionFromReturnAddress(pc_) = saved_value_; |
| 86 break; | 86 break; |
| 87 } | 87 } |
| 88 default: | 88 default: |
| 89 UNREACHABLE(); | 89 UNREACHABLE(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 if (saved_value_fastsmi_ != Bytecode::kTrap) { | 92 if (saved_value_fastsmi_ != Bytecode::kTrap) { |
| 93 Instr current_instr = *FastSmiInstructionFromReturnAddress(pc_); | 93 Instr current_instr = *FastSmiInstructionFromReturnAddress(pc_); |
| 94 ASSERT(Bytecode::DecodeOpcode(current_instr) == Bytecode::kNop); | 94 ASSERT(Bytecode::DecodeOpcode(current_instr) == Bytecode::kNop); |
| 95 *FastSmiInstructionFromReturnAddress(pc_) = saved_value_fastsmi_; | 95 *FastSmiInstructionFromReturnAddress(pc_) = saved_value_fastsmi_; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 is_enabled_ = false; | 98 is_enabled_ = false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 #endif // !PRODUCT | 101 #endif // !PRODUCT |
| 102 | 102 |
| 103 } // namespace dart | 103 } // namespace dart |
| 104 | 104 |
| 105 #endif // defined TARGET_ARCH_DBC | 105 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |