| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 ASSERT((offset % kWordSize) == 0); | 42 ASSERT((offset % kWordSize) == 0); |
| 43 const intptr_t index = (offset - Array::data_offset()) / kWordSize; | 43 const intptr_t index = (offset - Array::data_offset()) / kWordSize; |
| 44 const uword stub_address = reinterpret_cast<uword>(object_pool.At(index)); | 44 const uword stub_address = reinterpret_cast<uword>(object_pool.At(index)); |
| 45 ASSERT(stub_address % kWordSize == 0); | 45 ASSERT(stub_address % kWordSize == 0); |
| 46 return stub_address; | 46 return stub_address; |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 void CodeBreakpoint::PatchCode() { | 50 void CodeBreakpoint::PatchCode() { |
| 51 ASSERT(!is_enabled_); | 51 ASSERT(!is_enabled_); |
| 52 switch (breakpoint_kind_) { | 52 const Code& code = Code::Handle(code_); |
| 53 case PcDescriptors::kIcCall: | 53 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 54 case PcDescriptors::kUnoptStaticCall: | 54 { |
| 55 case PcDescriptors::kRuntimeCall: | 55 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
| 56 case PcDescriptors::kClosureCall: | 56 switch (breakpoint_kind_) { |
| 57 case PcDescriptors::kReturn: { | 57 case PcDescriptors::kIcCall: |
| 58 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_); | 58 case PcDescriptors::kUnoptStaticCall: |
| 59 ASSERT((offset > 0) && ((offset % 8) == 7)); | 59 case PcDescriptors::kRuntimeCall: |
| 60 saved_value_ = static_cast<uword>(offset); | 60 case PcDescriptors::kClosureCall: |
| 61 const uint32_t stub_offset = | 61 case PcDescriptors::kReturn: { |
| 62 InstructionPattern::OffsetFromPPIndex( | 62 int32_t offset = CodePatcher::GetPoolOffsetAt(pc_); |
| 63 Assembler::kBreakpointRuntimeCPIndex); | 63 ASSERT((offset > 0) && ((offset % 8) == 7)); |
| 64 CodePatcher::SetPoolOffsetAt(pc_, stub_offset); | 64 saved_value_ = static_cast<uword>(offset); |
| 65 break; | 65 const uint32_t stub_offset = |
| 66 InstructionPattern::OffsetFromPPIndex( |
| 67 Assembler::kBreakpointRuntimeCPIndex); |
| 68 CodePatcher::SetPoolOffsetAt(pc_, stub_offset); |
| 69 break; |
| 70 } |
| 71 default: |
| 72 UNREACHABLE(); |
| 66 } | 73 } |
| 67 default: | |
| 68 UNREACHABLE(); | |
| 69 } | 74 } |
| 70 is_enabled_ = true; | 75 is_enabled_ = true; |
| 71 } | 76 } |
| 72 | 77 |
| 73 | 78 |
| 74 void CodeBreakpoint::RestoreCode() { | 79 void CodeBreakpoint::RestoreCode() { |
| 75 ASSERT(is_enabled_); | 80 ASSERT(is_enabled_); |
| 76 switch (breakpoint_kind_) { | 81 const Code& code = Code::Handle(code_); |
| 77 case PcDescriptors::kIcCall: | 82 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 78 case PcDescriptors::kUnoptStaticCall: | 83 { |
| 79 case PcDescriptors::kClosureCall: | 84 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); |
| 80 case PcDescriptors::kRuntimeCall: | 85 switch (breakpoint_kind_) { |
| 81 case PcDescriptors::kReturn: { | 86 case PcDescriptors::kIcCall: |
| 82 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_)); | 87 case PcDescriptors::kUnoptStaticCall: |
| 83 break; | 88 case PcDescriptors::kClosureCall: |
| 89 case PcDescriptors::kRuntimeCall: |
| 90 case PcDescriptors::kReturn: { |
| 91 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_)); |
| 92 break; |
| 93 } |
| 94 default: |
| 95 UNREACHABLE(); |
| 84 } | 96 } |
| 85 default: | |
| 86 UNREACHABLE(); | |
| 87 } | 97 } |
| 88 is_enabled_ = false; | 98 is_enabled_ = false; |
| 89 } | 99 } |
| 90 | 100 |
| 91 | 101 |
| 92 } // namespace dart | 102 } // namespace dart |
| 93 | 103 |
| 94 #endif // defined TARGET_ARCH_X64 | 104 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |