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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { | 30 RawObject* ActivationFrame::GetClosureObject(intptr_t num_actual_args) { |
31 // At a minimum we have the closure object on the stack. | 31 // At a minimum we have the closure object on the stack. |
32 ASSERT(num_actual_args > 0); | 32 ASSERT(num_actual_args > 0); |
33 // Stack pointer points to last argument that was pushed on the stack. | 33 // Stack pointer points to last argument that was pushed on the stack. |
34 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); | 34 uword closure_addr = sp() + ((num_actual_args - 1) * kWordSize); |
35 return reinterpret_cast<RawObject*>( | 35 return reinterpret_cast<RawObject*>( |
36 *reinterpret_cast<uword*>(closure_addr)); | 36 *reinterpret_cast<uword*>(closure_addr)); |
37 } | 37 } |
38 | 38 |
| 39 |
| 40 uword CodeBreakpoint::OrigStubAddress() const { |
| 41 return saved_value_; |
| 42 } |
| 43 |
| 44 |
| 45 void CodeBreakpoint::PatchCode() { |
| 46 ASSERT(!is_enabled_); |
| 47 switch (breakpoint_kind_) { |
| 48 case PcDescriptors::kIcCall: { |
| 49 const Code& code = |
| 50 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 51 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, NULL); |
| 52 CodePatcher::PatchInstanceCallAt(pc_, code, |
| 53 StubCode::BreakpointDynamicEntryPoint()); |
| 54 break; |
| 55 } |
| 56 case PcDescriptors::kUnoptStaticCall: { |
| 57 const Code& code = |
| 58 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 59 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 60 CodePatcher::PatchStaticCallAt(pc_, code, |
| 61 StubCode::BreakpointStaticEntryPoint()); |
| 62 break; |
| 63 } |
| 64 case PcDescriptors::kRuntimeCall: |
| 65 case PcDescriptors::kClosureCall: |
| 66 case PcDescriptors::kReturn: { |
| 67 const Code& code = |
| 68 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 69 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 70 CodePatcher::PatchStaticCallAt(pc_, code, |
| 71 StubCode::BreakpointRuntimeEntryPoint()); |
| 72 break; |
| 73 } |
| 74 default: |
| 75 UNREACHABLE(); |
| 76 } |
| 77 is_enabled_ = true; |
| 78 } |
| 79 |
| 80 |
| 81 void CodeBreakpoint::RestoreCode() { |
| 82 ASSERT(is_enabled_); |
| 83 switch (breakpoint_kind_) { |
| 84 case PcDescriptors::kIcCall: { |
| 85 const Code& code = |
| 86 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 87 CodePatcher::PatchInstanceCallAt(pc_, code, saved_value_); |
| 88 break; |
| 89 } |
| 90 case PcDescriptors::kUnoptStaticCall: |
| 91 case PcDescriptors::kClosureCall: |
| 92 case PcDescriptors::kRuntimeCall: |
| 93 case PcDescriptors::kReturn: { |
| 94 const Code& code = |
| 95 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 96 CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); |
| 97 break; |
| 98 } |
| 99 default: |
| 100 UNREACHABLE(); |
| 101 } |
| 102 is_enabled_ = false; |
| 103 } |
| 104 |
39 } // namespace dart | 105 } // namespace dart |
40 | 106 |
41 #endif // defined TARGET_ARCH_IA32 | 107 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |