Chromium Code Reviews| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 205 |
| 206 MutexLocker ml(pages_lock_); | 206 MutexLocker ml(pages_lock_); |
| 207 if (!is_exec) { | 207 if (!is_exec) { |
| 208 if (pages_ == NULL) { | 208 if (pages_ == NULL) { |
| 209 pages_ = page; | 209 pages_ = page; |
| 210 } else { | 210 } else { |
| 211 pages_tail_->set_next(page); | 211 pages_tail_->set_next(page); |
| 212 } | 212 } |
| 213 pages_tail_ = page; | 213 pages_tail_ = page; |
| 214 } else { | 214 } else { |
| 215 // Should not allocate executable pages when running from a precompiled | |
| 216 // snapshot. | |
| 217 ASSERT(Object::instructions_snapshot_buffer() == NULL); | |
|
siva
2015/09/15 23:22:01
ASSERT(!Dart::IsRunningPrecompiledCode());
rmacnak
2015/09/16 01:34:45
Done.
| |
| 218 | |
| 215 if (exec_pages_ == NULL) { | 219 if (exec_pages_ == NULL) { |
| 216 exec_pages_ = page; | 220 exec_pages_ = page; |
| 217 } else { | 221 } else { |
| 218 if (FLAG_write_protect_code) { | 222 if (FLAG_write_protect_code) { |
| 219 exec_pages_tail_->WriteProtect(false); | 223 exec_pages_tail_->WriteProtect(false); |
| 220 } | 224 } |
| 221 exec_pages_tail_->set_next(page); | 225 exec_pages_tail_->set_next(page); |
| 222 if (FLAG_write_protect_code) { | 226 if (FLAG_write_protect_code) { |
| 223 exec_pages_tail_->WriteProtect(true); | 227 exec_pages_tail_->WriteProtect(true); |
| 224 } | 228 } |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 RawObject** begin = reinterpret_cast<RawObject**>(result); | 1019 RawObject** begin = reinterpret_cast<RawObject**>(result); |
| 1016 RawObject** end = reinterpret_cast<RawObject**>(result + size); | 1020 RawObject** end = reinterpret_cast<RawObject**>(result + size); |
| 1017 for (RawObject** current = begin; current < end; ++current) { | 1021 for (RawObject** current = begin; current < end; ++current) { |
| 1018 ASSERT(!(*current)->IsHeapObject()); | 1022 ASSERT(!(*current)->IsHeapObject()); |
| 1019 } | 1023 } |
| 1020 #endif | 1024 #endif |
| 1021 return result; | 1025 return result; |
| 1022 } | 1026 } |
| 1023 | 1027 |
| 1024 | 1028 |
| 1029 void PageSpace::SetupInstructionsSnapshotPage(void* pointer, uword size) { | |
| 1030 // Setup a HeapPage so precompiled Instructions can be traversed. | |
| 1031 // Instructions are contiguous at [pointer, pointer + size). HeapPage | |
| 1032 // expects to find objects at [memory->start() + ObjectStartOffset, | |
| 1033 // memory->end()). | |
| 1034 uword offset = HeapPage::ObjectStartOffset(); | |
| 1035 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset); | |
| 1036 size += offset; | |
| 1037 | |
| 1038 ASSERT(Utils::IsAligned(pointer, OS::PreferredCodeAlignment())); | |
| 1039 | |
| 1040 VirtualMemory* memory = VirtualMemory::ForInstructionsSnapshot(pointer, size); | |
| 1041 ASSERT(memory != NULL); | |
| 1042 HeapPage* page = reinterpret_cast<HeapPage*>(malloc(sizeof(HeapPage))); | |
| 1043 page->memory_ = memory; | |
| 1044 page->next_ = NULL; | |
| 1045 page->object_end_ = memory->end(); | |
| 1046 page->executable_ = true; | |
| 1047 | |
| 1048 #if defined(DEBUG) | |
| 1049 OS::Print("Precompiled instructions page at [%" Px ", %" Px ")\n", | |
| 1050 page->object_start(), page->object_end()); | |
| 1051 #endif | |
| 1052 | |
| 1053 MutexLocker ml(pages_lock_); | |
| 1054 if (exec_pages_ == NULL) { | |
| 1055 exec_pages_ = page; | |
| 1056 } else { | |
| 1057 exec_pages_tail_->set_next(page); | |
| 1058 } | |
| 1059 exec_pages_tail_ = page; | |
| 1060 } | |
| 1061 | |
| 1062 | |
| 1025 PageSpaceController::PageSpaceController(Heap* heap, | 1063 PageSpaceController::PageSpaceController(Heap* heap, |
| 1026 int heap_growth_ratio, | 1064 int heap_growth_ratio, |
| 1027 int heap_growth_max, | 1065 int heap_growth_max, |
| 1028 int garbage_collection_time_ratio) | 1066 int garbage_collection_time_ratio) |
| 1029 : heap_(heap), | 1067 : heap_(heap), |
| 1030 is_enabled_(false), | 1068 is_enabled_(false), |
| 1031 grow_heap_(heap_growth_max / 2), | 1069 grow_heap_(heap_growth_max / 2), |
| 1032 heap_growth_ratio_(heap_growth_ratio), | 1070 heap_growth_ratio_(heap_growth_ratio), |
| 1033 desired_utilization_((100.0 - heap_growth_ratio) / 100.0), | 1071 desired_utilization_((100.0 - heap_growth_ratio) / 100.0), |
| 1034 heap_growth_max_(heap_growth_max), | 1072 heap_growth_max_(heap_growth_max), |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 return 0; | 1185 return 0; |
| 1148 } else { | 1186 } else { |
| 1149 ASSERT(total_time >= gc_time); | 1187 ASSERT(total_time >= gc_time); |
| 1150 int result = static_cast<int>((static_cast<double>(gc_time) / | 1188 int result = static_cast<int>((static_cast<double>(gc_time) / |
| 1151 static_cast<double>(total_time)) * 100); | 1189 static_cast<double>(total_time)) * 100); |
| 1152 return result; | 1190 return result; |
| 1153 } | 1191 } |
| 1154 } | 1192 } |
| 1155 | 1193 |
| 1156 } // namespace dart | 1194 } // namespace dart |
| OLD | NEW |