OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/pages.h" | 5 #include "vm/pages.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 obj_addr = next_obj_addr; | 133 obj_addr = next_obj_addr; |
134 } | 134 } |
135 ASSERT(obj_addr == end_addr); | 135 ASSERT(obj_addr == end_addr); |
136 } | 136 } |
137 return Object::null(); | 137 return Object::null(); |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 void HeapPage::WriteProtect(bool read_only) { | 141 void HeapPage::WriteProtect(bool read_only) { |
| 142 ASSERT(!embedder_allocated()); |
| 143 |
142 VirtualMemory::Protection prot; | 144 VirtualMemory::Protection prot; |
143 if (read_only) { | 145 if (read_only) { |
144 if (type_ == kExecutable) { | 146 if (type_ == kExecutable) { |
145 prot = VirtualMemory::kReadExecute; | 147 prot = VirtualMemory::kReadExecute; |
146 } else { | 148 } else { |
147 prot = VirtualMemory::kReadOnly; | 149 prot = VirtualMemory::kReadOnly; |
148 } | 150 } |
149 } else { | 151 } else { |
150 prot = VirtualMemory::kReadWrite; | 152 prot = VirtualMemory::kReadWrite; |
151 } | 153 } |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 first = &exec_pages_; | 1095 first = &exec_pages_; |
1094 tail = &exec_pages_tail_; | 1096 tail = &exec_pages_tail_; |
1095 } else { | 1097 } else { |
1096 page->type_ = HeapPage::kReadOnlyData; | 1098 page->type_ = HeapPage::kReadOnlyData; |
1097 first = &pages_; | 1099 first = &pages_; |
1098 tail = &pages_tail_; | 1100 tail = &pages_tail_; |
1099 } | 1101 } |
1100 if (*first == NULL) { | 1102 if (*first == NULL) { |
1101 *first = page; | 1103 *first = page; |
1102 } else { | 1104 } else { |
| 1105 if (is_executable && FLAG_write_protect_code) { |
| 1106 (*tail)->WriteProtect(false); |
| 1107 } |
1103 (*tail)->set_next(page); | 1108 (*tail)->set_next(page); |
| 1109 if (is_executable && FLAG_write_protect_code) { |
| 1110 (*tail)->WriteProtect(true); |
| 1111 } |
1104 } | 1112 } |
1105 (*tail) = page; | 1113 (*tail) = page; |
1106 } | 1114 } |
1107 | 1115 |
1108 | 1116 |
1109 PageSpaceController::PageSpaceController(Heap* heap, | 1117 PageSpaceController::PageSpaceController(Heap* heap, |
1110 int heap_growth_ratio, | 1118 int heap_growth_ratio, |
1111 int heap_growth_max, | 1119 int heap_growth_max, |
1112 int garbage_collection_time_ratio) | 1120 int garbage_collection_time_ratio) |
1113 : heap_(heap), | 1121 : heap_(heap), |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 return 0; | 1269 return 0; |
1262 } else { | 1270 } else { |
1263 ASSERT(total_time >= gc_time); | 1271 ASSERT(total_time >= gc_time); |
1264 int result = static_cast<int>( | 1272 int result = static_cast<int>( |
1265 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); | 1273 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); |
1266 return result; | 1274 return result; |
1267 } | 1275 } |
1268 } | 1276 } |
1269 | 1277 |
1270 } // namespace dart | 1278 } // namespace dart |
OLD | NEW |