| 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/bootstrap.h" | 5 #include "vm/bootstrap.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/bootstrap_natives.h" | 9 #include "vm/bootstrap_natives.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| 11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
| 12 #include "vm/dart_api_impl.h" | 12 #include "vm/dart_api_impl.h" |
| 13 #if !defined(DART_PRECOMPILED_RUNTIME) | 13 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 14 #include "vm/kernel.h" | 14 #include "vm/kernel.h" |
| 15 #include "vm/kernel_reader.h" | 15 #include "vm/kernel_loader.h" |
| 16 #endif | 16 #endif |
| 17 #include "vm/object.h" | 17 #include "vm/object.h" |
| 18 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
| 19 #include "vm/symbols.h" | 19 #include "vm/symbols.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 struct BootstrapLibProps { | 23 struct BootstrapLibProps { |
| 24 ObjectStore::BootstrapLibraryId index; | 24 ObjectStore::BootstrapLibraryId index; |
| 25 const char* uri; | 25 const char* uri; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 // Restore the library tag handler for the isolate. | 297 // Restore the library tag handler for the isolate. |
| 298 isolate->set_library_tag_handler(saved_tag_handler); | 298 isolate->set_library_tag_handler(saved_tag_handler); |
| 299 | 299 |
| 300 return error.raw(); | 300 return error.raw(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 #if !defined(DART_PRECOMPILED_RUNTIME) | 303 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 304 static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { | 304 static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { |
| 305 Zone* zone = thread->zone(); | 305 Zone* zone = thread->zone(); |
| 306 kernel::KernelReader reader(program); | 306 kernel::KernelLoader loader(program); |
| 307 | 307 |
| 308 Isolate* isolate = thread->isolate(); | 308 Isolate* isolate = thread->isolate(); |
| 309 // Mark the already-pending classes. This mark bit will be used to avoid | 309 // Mark the already-pending classes. This mark bit will be used to avoid |
| 310 // adding classes to the list more than once. | 310 // adding classes to the list more than once. |
| 311 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( | 311 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( |
| 312 zone, isolate->object_store()->pending_classes()); | 312 zone, isolate->object_store()->pending_classes()); |
| 313 Class& pending = Class::Handle(zone); | 313 Class& pending = Class::Handle(zone); |
| 314 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { | 314 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { |
| 315 pending ^= pending_classes.At(i); | 315 pending ^= pending_classes.At(i); |
| 316 pending.set_is_marked_for_parsing(); | 316 pending.set_is_marked_for_parsing(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // Load the bootstrap libraries in order (see object_store.h). | 319 // Load the bootstrap libraries in order (see object_store.h). |
| 320 Library& library = Library::Handle(zone); | 320 Library& library = Library::Handle(zone); |
| 321 String& dart_name = String::Handle(zone); | 321 String& dart_name = String::Handle(zone); |
| 322 for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) { | 322 for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) { |
| 323 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 323 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
| 324 library = isolate->object_store()->bootstrap_library(id); | 324 library = isolate->object_store()->bootstrap_library(id); |
| 325 dart_name = library.url(); | 325 dart_name = library.url(); |
| 326 for (intptr_t j = 0; j < program->library_count(); ++j) { | 326 for (intptr_t j = 0; j < program->library_count(); ++j) { |
| 327 const String& kernel_name = reader.LibraryUri(j); | 327 const String& kernel_name = loader.LibraryUri(j); |
| 328 if (kernel_name.Equals(dart_name)) { | 328 if (kernel_name.Equals(dart_name)) { |
| 329 reader.ReadLibrary(reader.library_offset(j)); | 329 loader.LoadLibrary(loader.library_offset(j)); |
| 330 library.SetLoaded(); | 330 library.SetLoaded(); |
| 331 break; | 331 break; |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Finish bootstrapping, including class finalization. | 336 // Finish bootstrapping, including class finalization. |
| 337 Finish(thread, /*from_kernel=*/true); | 337 Finish(thread, /*from_kernel=*/true); |
| 338 | 338 |
| 339 // The platform binary may contain other libraries (e.g., dart:_builtin or | 339 // The platform binary may contain other libraries (e.g., dart:_builtin or |
| 340 // dart:io) that will not be bundled with application. Load them now. | 340 // dart:io) that will not be bundled with application. Load them now. |
| 341 reader.ReadProgram(); | 341 loader.LoadProgram(); |
| 342 | 342 |
| 343 // The builtin library should be registered with the VM. | 343 // The builtin library should be registered with the VM. |
| 344 dart_name = String::New("dart:_builtin"); | 344 dart_name = String::New("dart:_builtin"); |
| 345 library = Library::LookupLibrary(thread, dart_name); | 345 library = Library::LookupLibrary(thread, dart_name); |
| 346 isolate->object_store()->set_builtin_library(library); | 346 isolate->object_store()->set_builtin_library(library); |
| 347 | 347 |
| 348 return Error::null(); | 348 return Error::null(); |
| 349 } | 349 } |
| 350 #else | 350 #else |
| 351 static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { | 351 static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 375 lib.Register(thread); | 375 lib.Register(thread); |
| 376 isolate->object_store()->set_bootstrap_library(id, lib); | 376 isolate->object_store()->set_bootstrap_library(id, lib); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 return (kernel_program == NULL) ? BootstrapFromSource(thread) | 380 return (kernel_program == NULL) ? BootstrapFromSource(thread) |
| 381 : BootstrapFromKernel(thread, kernel_program); | 381 : BootstrapFromKernel(thread, kernel_program); |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace dart | 384 } // namespace dart |
| OLD | NEW |