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 #if !defined(DART_PRECOMPILED_RUNTIME) | 9 #if !defined(DART_PRECOMPILED_RUNTIME) |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Mark the already-pending classes. This mark bit will be used to avoid | 79 // Mark the already-pending classes. This mark bit will be used to avoid |
80 // adding classes to the list more than once. | 80 // adding classes to the list more than once. |
81 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( | 81 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( |
82 zone, isolate->object_store()->pending_classes()); | 82 zone, isolate->object_store()->pending_classes()); |
83 dart::Class& pending = dart::Class::Handle(zone); | 83 dart::Class& pending = dart::Class::Handle(zone); |
84 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { | 84 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { |
85 pending ^= pending_classes.At(i); | 85 pending ^= pending_classes.At(i); |
86 pending.set_is_marked_for_parsing(); | 86 pending.set_is_marked_for_parsing(); |
87 } | 87 } |
88 | 88 |
| 89 // Load the bootstrap libraries in order (see object_store.h). |
89 Library& library = Library::Handle(zone); | 90 Library& library = Library::Handle(zone); |
90 String& dart_name = String::Handle(zone); | 91 String& dart_name = String::Handle(zone); |
91 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { | 92 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { |
92 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 93 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
93 library = isolate->object_store()->bootstrap_library(id); | 94 library = isolate->object_store()->bootstrap_library(id); |
94 dart_name = library.url(); | 95 dart_name = library.url(); |
95 for (intptr_t j = 0; j < program->libraries().length(); ++j) { | 96 for (intptr_t j = 0; j < program->libraries().length(); ++j) { |
96 kernel::Library* kernel_library = program->libraries()[j]; | 97 kernel::Library* kernel_library = program->libraries()[j]; |
97 kernel::String* uri = kernel_library->import_uri(); | 98 kernel::String* uri = kernel_library->import_uri(); |
98 const String& kernel_name = reader.DartSymbol(uri); | 99 const String& kernel_name = reader.DartSymbol(uri); |
99 if (kernel_name.Equals(dart_name)) { | 100 if (kernel_name.Equals(dart_name)) { |
100 reader.ReadLibrary(kernel_library); | 101 reader.ReadLibrary(kernel_library); |
101 library.SetLoaded(); | 102 library.SetLoaded(); |
102 break; | 103 break; |
103 } | 104 } |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
| 108 // Finish bootstrapping, including class finalization. |
107 Finish(thread, /*from_kernel=*/true); | 109 Finish(thread, /*from_kernel=*/true); |
| 110 |
| 111 // The platform binary may contain other libraries (e.g., dart:_builtin or |
| 112 // dart:io) that will not be bundled with application. Load them now. |
| 113 reader.ReadProgram(); |
| 114 |
| 115 // The builtin library should be registered with the VM. |
| 116 dart_name = String::New("dart:_builtin"); |
| 117 library = Library::LookupLibrary(thread, dart_name); |
| 118 isolate->object_store()->set_builtin_library(library); |
| 119 |
108 return Error::null(); | 120 return Error::null(); |
109 } | 121 } |
110 | 122 |
111 | 123 |
112 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { | 124 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { |
113 Thread* thread = Thread::Current(); | 125 Thread* thread = Thread::Current(); |
114 Isolate* isolate = thread->isolate(); | 126 Isolate* isolate = thread->isolate(); |
115 Zone* zone = thread->zone(); | 127 Zone* zone = thread->zone(); |
116 String& uri = String::Handle(zone); | 128 String& uri = String::Handle(zone); |
117 Library& lib = Library::Handle(zone); | 129 Library& lib = Library::Handle(zone); |
(...skipping 17 matching lines...) Expand all Loading... |
135 return BootstrapFromKernel(thread, program); | 147 return BootstrapFromKernel(thread, program); |
136 } | 148 } |
137 #else | 149 #else |
138 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { | 150 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { |
139 UNREACHABLE(); | 151 UNREACHABLE(); |
140 return Error::null(); | 152 return Error::null(); |
141 } | 153 } |
142 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 154 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
143 | 155 |
144 } // namespace dart | 156 } // namespace dart |
OLD | NEW |