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

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

Issue 1584443002: VM: Precompiled rodata snapshot. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: win32, android build Created 4 years, 11 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
OLDNEW
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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 RawObject** begin = reinterpret_cast<RawObject**>(result); 1054 RawObject** begin = reinterpret_cast<RawObject**>(result);
1055 RawObject** end = reinterpret_cast<RawObject**>(result + size); 1055 RawObject** end = reinterpret_cast<RawObject**>(result + size);
1056 for (RawObject** current = begin; current < end; ++current) { 1056 for (RawObject** current = begin; current < end; ++current) {
1057 ASSERT(!(*current)->IsHeapObject()); 1057 ASSERT(!(*current)->IsHeapObject());
1058 } 1058 }
1059 #endif 1059 #endif
1060 return result; 1060 return result;
1061 } 1061 }
1062 1062
1063 1063
1064 void PageSpace::SetupInstructionsSnapshotPage(void* pointer, uword size) { 1064 void PageSpace::SetupInstructionsSnapshotPage(void* pointer,
1065 uword size,
1066 bool is_executable) {
1065 // Setup a HeapPage so precompiled Instructions can be traversed. 1067 // Setup a HeapPage so precompiled Instructions can be traversed.
1066 // Instructions are contiguous at [pointer, pointer + size). HeapPage 1068 // Instructions are contiguous at [pointer, pointer + size). HeapPage
1067 // expects to find objects at [memory->start() + ObjectStartOffset, 1069 // expects to find objects at [memory->start() + ObjectStartOffset,
1068 // memory->end()). 1070 // memory->end()).
1069 uword offset = HeapPage::ObjectStartOffset(); 1071 uword offset = HeapPage::ObjectStartOffset();
1070 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset); 1072 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset);
1071 size += offset; 1073 size += offset;
1072 1074
1073 ASSERT(Utils::IsAligned(pointer, OS::PreferredCodeAlignment()));
1074
1075 VirtualMemory* memory = VirtualMemory::ForInstructionsSnapshot(pointer, size); 1075 VirtualMemory* memory = VirtualMemory::ForInstructionsSnapshot(pointer, size);
rmacnak 2016/01/15 00:57:01 rename to VirtualMemory::ForExternalPage
Florian Schneider 2016/01/15 15:56:01 Done.
1076 ASSERT(memory != NULL); 1076 ASSERT(memory != NULL);
1077 HeapPage* page = reinterpret_cast<HeapPage*>(malloc(sizeof(HeapPage))); 1077 HeapPage* page = reinterpret_cast<HeapPage*>(malloc(sizeof(HeapPage)));
1078 page->memory_ = memory; 1078 page->memory_ = memory;
1079 page->next_ = NULL; 1079 page->next_ = NULL;
1080 page->object_end_ = memory->end(); 1080 page->object_end_ = memory->end();
1081 page->executable_ = true;
1082 1081
1083 MutexLocker ml(pages_lock_); 1082 MutexLocker ml(pages_lock_);
1084 if (exec_pages_ == NULL) { 1083 HeapPage** first, **tail;
1085 exec_pages_ = page; 1084 if (is_executable) {
1085 ASSERT(Utils::IsAligned(pointer, OS::PreferredCodeAlignment()));
1086 page->executable_ = true;
1087 first = &exec_pages_;
1088 tail = &exec_pages_tail_;
1086 } else { 1089 } else {
1087 exec_pages_tail_->set_next(page); 1090 first = &pages_;
1091 tail = &pages_tail_;
1088 } 1092 }
1089 exec_pages_tail_ = page; 1093 if (*first == NULL) {
1094 *first = page;
1095 } else {
1096 (*tail)->set_next(page);
1097 }
1098 (*tail) = page;
1090 } 1099 }
1091 1100
1092 1101
1093 PageSpaceController::PageSpaceController(Heap* heap, 1102 PageSpaceController::PageSpaceController(Heap* heap,
1094 int heap_growth_ratio, 1103 int heap_growth_ratio,
1095 int heap_growth_max, 1104 int heap_growth_max,
1096 int garbage_collection_time_ratio) 1105 int garbage_collection_time_ratio)
1097 : heap_(heap), 1106 : heap_(heap),
1098 is_enabled_(false), 1107 is_enabled_(false),
1099 grow_heap_(heap_growth_max / 2), 1108 grow_heap_(heap_growth_max / 2),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 return 0; 1224 return 0;
1216 } else { 1225 } else {
1217 ASSERT(total_time >= gc_time); 1226 ASSERT(total_time >= gc_time);
1218 int result = static_cast<int>((static_cast<double>(gc_time) / 1227 int result = static_cast<int>((static_cast<double>(gc_time) /
1219 static_cast<double>(total_time)) * 100); 1228 static_cast<double>(total_time)) * 100);
1220 return result; 1229 return result;
1221 } 1230 }
1222 } 1231 }
1223 1232
1224 } // namespace dart 1233 } // namespace dart
OLDNEW
« runtime/vm/pages.h ('K') | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698