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

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

Issue 136563002: Landing: Write protect executable pages in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Added command line flag Created 6 years, 10 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 | Annotate | Revision Log
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_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
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 }
66 } 71 }
67 default:
68 UNREACHABLE();
69 } 72 }
70 is_enabled_ = true; 73 is_enabled_ = true;
71 } 74 }
72 75
73 76
74 void CodeBreakpoint::RestoreCode() { 77 void CodeBreakpoint::RestoreCode() {
75 ASSERT(is_enabled_); 78 ASSERT(is_enabled_);
76 switch (breakpoint_kind_) { 79 const Code& code = Code::Handle(code_);
77 case PcDescriptors::kIcCall: 80 const Instructions& instrs = Instructions::Handle(code.instructions());
78 case PcDescriptors::kUnoptStaticCall: 81 {
79 case PcDescriptors::kClosureCall: 82 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
80 case PcDescriptors::kRuntimeCall: 83 switch (breakpoint_kind_) {
81 case PcDescriptors::kReturn: { 84 case PcDescriptors::kIcCall:
82 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_)); 85 case PcDescriptors::kUnoptStaticCall:
83 break; 86 case PcDescriptors::kClosureCall:
87 case PcDescriptors::kRuntimeCall:
88 case PcDescriptors::kReturn: {
89 CodePatcher::SetPoolOffsetAt(pc_, static_cast<int32_t>(saved_value_));
90 break;
91 }
92 default:
93 UNREACHABLE();
84 } 94 }
85 default:
86 UNREACHABLE();
87 } 95 }
88 is_enabled_ = false; 96 is_enabled_ = false;
89 } 97 }
90 98
91 99
92 } // namespace dart 100 } // namespace dart
93 101
94 #endif // defined TARGET_ARCH_X64 102 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698