| OLD | NEW |
| 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/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 11 #include "vm/freelist.h" | 11 #include "vm/freelist.h" |
| 12 #include "vm/handles.h" | 12 #include "vm/handles.h" |
| 13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
| 14 #include "vm/isolate.h" | 14 #include "vm/isolate.h" |
| 15 #include "vm/object.h" | 15 #include "vm/object.h" |
| 16 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
| 17 #include "vm/port.h" | 17 #include "vm/port.h" |
| 18 #include "vm/simulator.h" | 18 #include "vm/simulator.h" |
| 19 #include "vm/snapshot.h" | 19 #include "vm/snapshot.h" |
| 20 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
| 21 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
| 22 #include "vm/thread_pool.h" | 22 #include "vm/thread_pool.h" |
| 23 #include "vm/virtual_memory.h" | 23 #include "vm/virtual_memory.h" |
| 24 #include "vm/zone.h" | 24 #include "vm/zone.h" |
| 25 | 25 |
| 26 namespace dart { | 26 namespace dart { |
| 27 | 27 |
| 28 DEFINE_FLAG(bool, heap_profile_initialize, false, | 28 DEFINE_FLAG(bool, heap_profile_initialize, false, |
| 29 "Writes a heap profile on isolate initialization."); | 29 "Writes a heap profile on isolate initialization."); |
| 30 DECLARE_FLAG(bool, print_bootstrap); | |
| 31 DECLARE_FLAG(bool, print_class_table); | 30 DECLARE_FLAG(bool, print_class_table); |
| 32 DECLARE_FLAG(bool, trace_isolates); | 31 DECLARE_FLAG(bool, trace_isolates); |
| 33 | 32 |
| 34 Isolate* Dart::vm_isolate_ = NULL; | 33 Isolate* Dart::vm_isolate_ = NULL; |
| 35 ThreadPool* Dart::thread_pool_ = NULL; | 34 ThreadPool* Dart::thread_pool_ = NULL; |
| 36 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 35 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
| 37 ReadOnlyHandles* Dart::predefined_handles_ = NULL; | 36 ReadOnlyHandles* Dart::predefined_handles_ = NULL; |
| 38 | 37 |
| 39 // An object visitor which will mark all visited objects. This is used to | 38 // An object visitor which will mark all visited objects. This is used to |
| 40 // premark all objects in the vm_isolate_ heap. | 39 // premark all objects in the vm_isolate_ heap. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 138 |
| 140 | 139 |
| 141 Isolate* Dart::CreateIsolate(const char* name_prefix) { | 140 Isolate* Dart::CreateIsolate(const char* name_prefix) { |
| 142 // Create a new isolate. | 141 // Create a new isolate. |
| 143 Isolate* isolate = Isolate::Init(name_prefix); | 142 Isolate* isolate = Isolate::Init(name_prefix); |
| 144 ASSERT(isolate != NULL); | 143 ASSERT(isolate != NULL); |
| 145 return isolate; | 144 return isolate; |
| 146 } | 145 } |
| 147 | 146 |
| 148 | 147 |
| 149 static void PrintLibrarySources(Isolate* isolate) { | |
| 150 const GrowableObjectArray& libs = GrowableObjectArray::Handle( | |
| 151 isolate->object_store()->libraries()); | |
| 152 intptr_t lib_count = libs.Length(); | |
| 153 Library& lib = Library::Handle(); | |
| 154 Array& scripts = Array::Handle(); | |
| 155 Script& script = Script::Handle(); | |
| 156 String& url = String::Handle(); | |
| 157 String& source = String::Handle(); | |
| 158 for (int i = 0; i < lib_count; i++) { | |
| 159 lib ^= libs.At(i); | |
| 160 url = lib.url(); | |
| 161 OS::Print("Library %s:\n", url.ToCString()); | |
| 162 scripts = lib.LoadedScripts(); | |
| 163 intptr_t script_count = scripts.Length(); | |
| 164 for (intptr_t i = 0; i < script_count; i++) { | |
| 165 script ^= scripts.At(i); | |
| 166 url = script.url(); | |
| 167 source = script.Source(); | |
| 168 OS::Print("Source for %s:\n", url.ToCString()); | |
| 169 OS::Print("%s\n", source.ToCString()); | |
| 170 } | |
| 171 } | |
| 172 } | |
| 173 | |
| 174 | |
| 175 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 148 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
| 176 // Initialize the new isolate. | 149 // Initialize the new isolate. |
| 177 TIMERSCOPE(time_isolate_initialization); | 150 TIMERSCOPE(time_isolate_initialization); |
| 178 Isolate* isolate = Isolate::Current(); | 151 Isolate* isolate = Isolate::Current(); |
| 179 ASSERT(isolate != NULL); | 152 ASSERT(isolate != NULL); |
| 180 StackZone zone(isolate); | 153 StackZone zone(isolate); |
| 181 HandleScope handle_scope(isolate); | 154 HandleScope handle_scope(isolate); |
| 182 Heap::Init(isolate); | 155 Heap::Init(isolate); |
| 183 ObjectStore::Init(isolate); | 156 ObjectStore::Init(isolate); |
| 184 | 157 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 198 if (FLAG_trace_isolates) { | 171 if (FLAG_trace_isolates) { |
| 199 OS::Print("Size of isolate snapshot = %d\n", snapshot->length()); | 172 OS::Print("Size of isolate snapshot = %d\n", snapshot->length()); |
| 200 } | 173 } |
| 201 SnapshotReader reader(snapshot->content(), snapshot->length(), | 174 SnapshotReader reader(snapshot->content(), snapshot->length(), |
| 202 Snapshot::kFull, isolate); | 175 Snapshot::kFull, isolate); |
| 203 reader.ReadFullSnapshot(); | 176 reader.ReadFullSnapshot(); |
| 204 if (FLAG_trace_isolates) { | 177 if (FLAG_trace_isolates) { |
| 205 isolate->heap()->PrintSizes(); | 178 isolate->heap()->PrintSizes(); |
| 206 isolate->megamorphic_cache_table()->PrintSizes(); | 179 isolate->megamorphic_cache_table()->PrintSizes(); |
| 207 } | 180 } |
| 208 if (FLAG_print_bootstrap) { | |
| 209 PrintLibrarySources(isolate); | |
| 210 } | |
| 211 } | 181 } |
| 212 | 182 |
| 213 if (FLAG_heap_profile_initialize) { | 183 if (FLAG_heap_profile_initialize) { |
| 214 isolate->heap()->ProfileToFile("initialize"); | 184 isolate->heap()->ProfileToFile("initialize"); |
| 215 } | 185 } |
| 216 | 186 |
| 217 Object::VerifyBuiltinVtables(); | 187 Object::VerifyBuiltinVtables(); |
| 218 | 188 |
| 219 StubCode::Init(isolate); | 189 StubCode::Init(isolate); |
| 220 isolate->megamorphic_cache_table()->InitMissHandler(); | 190 isolate->megamorphic_cache_table()->InitMissHandler(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 248 return predefined_handles_->handles_.AllocateScopedHandle(); | 218 return predefined_handles_->handles_.AllocateScopedHandle(); |
| 249 } | 219 } |
| 250 | 220 |
| 251 | 221 |
| 252 bool Dart::IsReadOnlyHandle(uword address) { | 222 bool Dart::IsReadOnlyHandle(uword address) { |
| 253 ASSERT(predefined_handles_ != NULL); | 223 ASSERT(predefined_handles_ != NULL); |
| 254 return predefined_handles_->handles_.IsValidScopedHandle(address); | 224 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 255 } | 225 } |
| 256 | 226 |
| 257 } // namespace dart | 227 } // namespace dart |
| OLD | NEW |