| 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" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // Mark the already-pending classes. This mark bit will be used to avoid | 349 // Mark the already-pending classes. This mark bit will be used to avoid |
| 350 // adding classes to the list more than once. | 350 // adding classes to the list more than once. |
| 351 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( | 351 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( |
| 352 zone, isolate->object_store()->pending_classes()); | 352 zone, isolate->object_store()->pending_classes()); |
| 353 dart::Class& pending = dart::Class::Handle(zone); | 353 dart::Class& pending = dart::Class::Handle(zone); |
| 354 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { | 354 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { |
| 355 pending ^= pending_classes.At(i); | 355 pending ^= pending_classes.At(i); |
| 356 pending.set_is_marked_for_parsing(); | 356 pending.set_is_marked_for_parsing(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Load the bootstrap libraries in order (see object_store.h). |
| 359 Library& library = Library::Handle(zone); | 360 Library& library = Library::Handle(zone); |
| 360 String& dart_name = String::Handle(zone); | 361 String& dart_name = String::Handle(zone); |
| 361 String& kernel_name = String::Handle(zone); | 362 String& kernel_name = String::Handle(zone); |
| 362 for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) { | 363 for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) { |
| 363 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 364 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
| 364 library = isolate->object_store()->bootstrap_library(id); | 365 library = isolate->object_store()->bootstrap_library(id); |
| 365 dart_name = library.url(); | 366 dart_name = library.url(); |
| 366 for (intptr_t j = 0; j < program->libraries().length(); ++j) { | 367 for (intptr_t j = 0; j < program->libraries().length(); ++j) { |
| 367 kernel::Library* kernel_library = program->libraries()[j]; | 368 kernel::Library* kernel_library = program->libraries()[j]; |
| 368 kernel::String* uri = kernel_library->import_uri(); | 369 kernel::String* uri = kernel_library->import_uri(); |
| 369 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); | 370 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); |
| 370 if (kernel_name.Equals(dart_name)) { | 371 if (kernel_name.Equals(dart_name)) { |
| 371 reader.ReadLibrary(kernel_library); | 372 reader.ReadLibrary(kernel_library); |
| 372 library.SetLoaded(); | 373 library.SetLoaded(); |
| 373 break; | 374 break; |
| 374 } | 375 } |
| 375 } | 376 } |
| 376 } | 377 } |
| 377 | 378 |
| 379 // Finish bootstrapping, including class finalization. |
| 378 Finish(thread, /*from_kernel=*/true); | 380 Finish(thread, /*from_kernel=*/true); |
| 381 |
| 382 // The platform binary may contain other libraries (e.g., dart:_builtin or |
| 383 // dart:io) that will not be bundled with application. Load them now. |
| 384 reader.ReadProgram(); |
| 385 |
| 386 // The builtin library should be registered with the VM. |
| 387 dart_name = String::New("dart:_builtin"); |
| 388 library = Library::LookupLibrary(thread, dart_name); |
| 389 isolate->object_store()->set_builtin_library(library); |
| 390 |
| 379 return Error::null(); | 391 return Error::null(); |
| 380 } | 392 } |
| 381 #else | 393 #else |
| 382 static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { | 394 static RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { |
| 383 UNREACHABLE(); | 395 UNREACHABLE(); |
| 384 return Error::null(); | 396 return Error::null(); |
| 385 } | 397 } |
| 386 #endif | 398 #endif |
| 387 | 399 |
| 388 | 400 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 407 lib.Register(thread); | 419 lib.Register(thread); |
| 408 isolate->object_store()->set_bootstrap_library(id, lib); | 420 isolate->object_store()->set_bootstrap_library(id, lib); |
| 409 } | 421 } |
| 410 } | 422 } |
| 411 | 423 |
| 412 return (kernel_program == NULL) ? BootstrapFromSource(thread) | 424 return (kernel_program == NULL) ? BootstrapFromSource(thread) |
| 413 : BootstrapFromKernel(thread, kernel_program); | 425 : BootstrapFromKernel(thread, kernel_program); |
| 414 } | 426 } |
| 415 | 427 |
| 416 } // namespace dart | 428 } // namespace dart |
| OLD | NEW |