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

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

Issue 1311403009: More precompiled snapshotting. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 5 years, 3 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/code_observers.h" 7 #include "vm/code_observers.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 predefined_handles_ = new ReadOnlyHandles(); 112 predefined_handles_ = new ReadOnlyHandles();
113 // Create the VM isolate and finish the VM initialization. 113 // Create the VM isolate and finish the VM initialization.
114 ASSERT(thread_pool_ == NULL); 114 ASSERT(thread_pool_ == NULL);
115 thread_pool_ = new ThreadPool(); 115 thread_pool_ = new ThreadPool();
116 { 116 {
117 Thread* T = Thread::Current(); 117 Thread* T = Thread::Current();
118 ASSERT(T != NULL); 118 ASSERT(T != NULL);
119 ASSERT(vm_isolate_ == NULL); 119 ASSERT(vm_isolate_ == NULL);
120 ASSERT(Flags::Initialized()); 120 ASSERT(Flags::Initialized());
121 const bool is_vm_isolate = true; 121 const bool is_vm_isolate = true;
122 const bool precompiled = instructions_snapshot != NULL;
122 123
123 // Setup default flags for the VM isolate. 124 // Setup default flags for the VM isolate.
124 Isolate::Flags vm_flags; 125 Isolate::Flags vm_flags;
125 Dart_IsolateFlags api_flags; 126 Dart_IsolateFlags api_flags;
126 vm_flags.CopyTo(&api_flags); 127 vm_flags.CopyTo(&api_flags);
127 vm_isolate_ = Isolate::Init("vm-isolate", api_flags, is_vm_isolate); 128 vm_isolate_ = Isolate::Init("vm-isolate", api_flags, is_vm_isolate);
129 vm_isolate_->set_compilation_allowed(!precompiled);
128 // Verify assumptions about executing in the VM isolate. 130 // Verify assumptions about executing in the VM isolate.
129 ASSERT(vm_isolate_ == Isolate::Current()); 131 ASSERT(vm_isolate_ == Isolate::Current());
130 ASSERT(vm_isolate_ == Thread::Current()->isolate()); 132 ASSERT(vm_isolate_ == Thread::Current()->isolate());
131 133
132 StackZone zone(T); 134 StackZone zone(T);
133 HandleScope handle_scope(T); 135 HandleScope handle_scope(T);
134 Object::InitNull(vm_isolate_); 136 Object::InitNull(vm_isolate_);
135 ObjectStore::Init(vm_isolate_); 137 ObjectStore::Init(vm_isolate_);
136 TargetCPUFeatures::InitOnce(); 138 TargetCPUFeatures::InitOnce();
137 Object::InitOnce(vm_isolate_); 139 Object::InitOnce(vm_isolate_);
138 ArgumentsDescriptor::InitOnce(); 140 ArgumentsDescriptor::InitOnce();
139 StubCode::InitOnce(); 141 // When precompiled the stub code is initialized from the snapshot.
140 Thread::InitOnceAfterObjectAndStubCode(); 142 if (!precompiled) {
141 // Now that the needed stub has been generated, set the stack limit. 143 StubCode::InitOnce();
142 vm_isolate_->InitializeStackLimit(); 144 }
143 if (vm_isolate_snapshot != NULL) { 145 if (vm_isolate_snapshot != NULL) {
144 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); 146 const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot);
145 if (snapshot == NULL) { 147 if (snapshot == NULL) {
146 return "Invalid vm isolate snapshot seen."; 148 return "Invalid vm isolate snapshot seen.";
147 } 149 }
148 ASSERT(snapshot->kind() == Snapshot::kFull); 150 ASSERT(snapshot->kind() == Snapshot::kFull);
149 VmIsolateSnapshotReader reader(snapshot->content(), 151 VmIsolateSnapshotReader reader(snapshot->content(),
150 snapshot->length(), 152 snapshot->length(),
151 instructions_snapshot, 153 instructions_snapshot,
152 T); 154 T);
153 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); 155 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot());
154 if (!error.IsNull()) { 156 if (!error.IsNull()) {
155 return error.ToCString(); 157 return error.ToCString();
156 } 158 }
157 if (FLAG_trace_isolates) { 159 if (FLAG_trace_isolates) {
158 OS::Print("Size of vm isolate snapshot = %" Pd "\n", 160 OS::Print("Size of vm isolate snapshot = %" Pd "\n",
159 snapshot->length()); 161 snapshot->length());
160 vm_isolate_->heap()->PrintSizes(); 162 vm_isolate_->heap()->PrintSizes();
161 MegamorphicCacheTable::PrintSizes(vm_isolate_); 163 MegamorphicCacheTable::PrintSizes(vm_isolate_);
162 intptr_t size; 164 intptr_t size;
163 intptr_t capacity; 165 intptr_t capacity;
164 Symbols::GetStats(vm_isolate_, &size, &capacity); 166 Symbols::GetStats(vm_isolate_, &size, &capacity);
165 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size); 167 OS::Print("VM Isolate: Number of symbols : %" Pd "\n", size);
166 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity); 168 OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", capacity);
167 } 169 }
168 } else { 170 } else {
169 Symbols::InitOnce(vm_isolate_); 171 Symbols::InitOnce(vm_isolate_);
170 } 172 }
173 Thread::InitOnceAfterObjectAndStubCode();
174 // Now that the needed stub has been generated, set the stack limit.
175 vm_isolate_->InitializeStackLimit();
171 Scanner::InitOnce(); 176 Scanner::InitOnce();
172 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 177 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
173 // Dart VM requires at least SSE2. 178 // Dart VM requires at least SSE2.
174 if (!TargetCPUFeatures::sse2_supported()) { 179 if (!TargetCPUFeatures::sse2_supported()) {
175 return "SSE2 is required."; 180 return "SSE2 is required.";
176 } 181 }
177 #endif 182 #endif
178 Object::FinalizeVMIsolate(vm_isolate_); 183 Object::FinalizeVMIsolate(vm_isolate_);
179 #if defined(DEBUG) 184 #if defined(DEBUG)
180 vm_isolate_->heap()->Verify(kRequireMarked); 185 vm_isolate_->heap()->Verify(kRequireMarked);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 return predefined_handles_->handles_.IsValidScopedHandle(address); 386 return predefined_handles_->handles_.IsValidScopedHandle(address);
382 } 387 }
383 388
384 389
385 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 390 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
386 ASSERT(predefined_handles_ != NULL); 391 ASSERT(predefined_handles_ != NULL);
387 return predefined_handles_->api_handles_.IsValidHandle(handle); 392 return predefined_handles_->api_handles_.IsValidHandle(handle);
388 } 393 }
389 394
390 } // namespace dart 395 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/object.h » ('j') | runtime/vm/snapshot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698