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" |
11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
12 #include "vm/kernel_reader.h" | 12 #include "vm/kernel_loader.h" |
13 #endif | 13 #endif |
14 #include "vm/object.h" | 14 #include "vm/object.h" |
15 #if !defined(DART_PRECOMPILED_RUNTIME) | 15 #if !defined(DART_PRECOMPILED_RUNTIME) |
16 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
17 #endif | 17 #endif |
18 | 18 |
19 namespace dart { | 19 namespace dart { |
20 | 20 |
21 #if !defined(DART_PRECOMPILED_RUNTIME) | 21 #if !defined(DART_PRECOMPILED_RUNTIME) |
22 #define MAKE_PROPERTIES(CamelName, name) \ | 22 #define MAKE_PROPERTIES(CamelName, name) \ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 ASSERT(field.Offset() == Closure::hash_offset()); | 63 ASSERT(field.Offset() == Closure::hash_offset()); |
64 #endif // defined(DEBUG) | 64 #endif // defined(DEBUG) |
65 | 65 |
66 // Eagerly compile Bool class, bool constants are used from within compiler. | 66 // Eagerly compile Bool class, bool constants are used from within compiler. |
67 cls = object_store->bool_class(); | 67 cls = object_store->bool_class(); |
68 Compiler::CompileClass(cls); | 68 Compiler::CompileClass(cls); |
69 } | 69 } |
70 | 70 |
71 RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { | 71 RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { |
72 Zone* zone = thread->zone(); | 72 Zone* zone = thread->zone(); |
73 kernel::KernelReader reader(program); | 73 kernel::KernelLoader loader(program); |
74 Isolate* isolate = thread->isolate(); | 74 Isolate* isolate = thread->isolate(); |
75 // Mark the already-pending classes. This mark bit will be used to avoid | 75 // Mark the already-pending classes. This mark bit will be used to avoid |
76 // adding classes to the list more than once. | 76 // adding classes to the list more than once. |
77 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( | 77 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( |
78 zone, isolate->object_store()->pending_classes()); | 78 zone, isolate->object_store()->pending_classes()); |
79 Class& pending = Class::Handle(zone); | 79 Class& pending = Class::Handle(zone); |
80 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { | 80 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { |
81 pending ^= pending_classes.At(i); | 81 pending ^= pending_classes.At(i); |
82 pending.set_is_marked_for_parsing(); | 82 pending.set_is_marked_for_parsing(); |
83 } | 83 } |
84 | 84 |
85 // Load the bootstrap libraries in order (see object_store.h). | 85 // Load the bootstrap libraries in order (see object_store.h). |
86 Library& library = Library::Handle(zone); | 86 Library& library = Library::Handle(zone); |
87 String& dart_name = String::Handle(zone); | 87 String& dart_name = String::Handle(zone); |
88 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { | 88 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { |
89 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 89 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
90 library = isolate->object_store()->bootstrap_library(id); | 90 library = isolate->object_store()->bootstrap_library(id); |
91 dart_name = library.url(); | 91 dart_name = library.url(); |
92 for (intptr_t j = 0; j < program->library_count(); ++j) { | 92 for (intptr_t j = 0; j < program->library_count(); ++j) { |
93 const String& kernel_name = reader.LibraryUri(j); | 93 const String& kernel_name = loader.LibraryUri(j); |
94 if (kernel_name.Equals(dart_name)) { | 94 if (kernel_name.Equals(dart_name)) { |
95 reader.ReadLibrary(reader.library_offset(j)); | 95 loader.LoadLibrary(loader.library_offset(j)); |
96 library.SetLoaded(); | 96 library.SetLoaded(); |
97 break; | 97 break; |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 // Finish bootstrapping, including class finalization. | 102 // Finish bootstrapping, including class finalization. |
103 Finish(thread, /*from_kernel=*/true); | 103 Finish(thread, /*from_kernel=*/true); |
104 | 104 |
105 // The platform binary may contain other libraries (e.g., dart:_builtin or | 105 // The platform binary may contain other libraries (e.g., dart:_builtin or |
106 // dart:io) that will not be bundled with application. Load them now. | 106 // dart:io) that will not be bundled with application. Load them now. |
107 reader.ReadProgram(); | 107 loader.LoadProgram(); |
108 | 108 |
109 // The builtin library should be registered with the VM. | 109 // The builtin library should be registered with the VM. |
110 dart_name = String::New("dart:_builtin"); | 110 dart_name = String::New("dart:_builtin"); |
111 library = Library::LookupLibrary(thread, dart_name); | 111 library = Library::LookupLibrary(thread, dart_name); |
112 isolate->object_store()->set_builtin_library(library); | 112 isolate->object_store()->set_builtin_library(library); |
113 | 113 |
114 return Error::null(); | 114 return Error::null(); |
115 } | 115 } |
116 | 116 |
117 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { | 117 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { |
(...skipping 22 matching lines...) Expand all Loading... |
140 return BootstrapFromKernel(thread, program); | 140 return BootstrapFromKernel(thread, program); |
141 } | 141 } |
142 #else | 142 #else |
143 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { | 143 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { |
144 UNREACHABLE(); | 144 UNREACHABLE(); |
145 return Error::null(); | 145 return Error::null(); |
146 } | 146 } |
147 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 147 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
148 | 148 |
149 } // namespace dart | 149 } // namespace dart |
OLD | NEW |