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