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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Eagerly compile Bool class, bool constants are used from within compiler. | 52 // Eagerly compile Bool class, bool constants are used from within compiler. |
53 cls = object_store->bool_class(); | 53 cls = object_store->bool_class(); |
54 Compiler::CompileClass(cls); | 54 Compiler::CompileClass(cls); |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 RawError* BootstrapFromKernel(Thread* thread, | 58 RawError* BootstrapFromKernel(Thread* thread, |
59 const uint8_t* buffer, | 59 const uint8_t* buffer, |
60 intptr_t buffer_length) { | 60 intptr_t buffer_length) { |
61 Zone* zone = thread->zone(); | 61 Zone* zone = thread->zone(); |
62 kernel::KernelReader reader(buffer, buffer_length, true); | 62 kernel::Program* program = |
63 kernel::Program* program = reader.ReadPrecompiledProgram(); | 63 ReadPrecompiledKernelFromBuffer(buffer, buffer_length); |
64 if (program == NULL) { | 64 if (program == NULL) { |
65 const String& message = | 65 const String& message = |
66 String::Handle(zone, String::New("Failed to read Kernel file")); | 66 String::Handle(zone, String::New("Failed to read Kernel file")); |
67 return ApiError::New(message); | 67 return ApiError::New(message); |
68 } | 68 } |
69 | 69 |
70 Isolate* isolate = thread->isolate(); | 70 Isolate* isolate = thread->isolate(); |
71 // Mark the already-pending classes. This mark bit will be used to avoid | 71 // Mark the already-pending classes. This mark bit will be used to avoid |
72 // adding classes to the list more than once. | 72 // adding classes to the list more than once. |
73 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( | 73 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( |
74 zone, isolate->object_store()->pending_classes()); | 74 zone, isolate->object_store()->pending_classes()); |
75 dart::Class& pending = dart::Class::Handle(zone); | 75 dart::Class& pending = dart::Class::Handle(zone); |
76 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { | 76 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { |
77 pending ^= pending_classes.At(i); | 77 pending ^= pending_classes.At(i); |
78 pending.set_is_marked_for_parsing(); | 78 pending.set_is_marked_for_parsing(); |
79 } | 79 } |
80 | 80 |
81 Library& library = Library::Handle(zone); | 81 Library& library = Library::Handle(zone); |
82 String& dart_name = String::Handle(zone); | 82 String& dart_name = String::Handle(zone); |
83 String& kernel_name = String::Handle(zone); | 83 String& kernel_name = String::Handle(zone); |
| 84 kernel::KernelReader reader(NULL, -1, true); |
84 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { | 85 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { |
85 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 86 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
86 library = isolate->object_store()->bootstrap_library(id); | 87 library = isolate->object_store()->bootstrap_library(id); |
87 dart_name = library.url(); | 88 dart_name = library.url(); |
88 for (intptr_t j = 0; j < program->libraries().length(); ++j) { | 89 for (intptr_t j = 0; j < program->libraries().length(); ++j) { |
89 kernel::Library* kernel_library = program->libraries()[j]; | 90 kernel::Library* kernel_library = program->libraries()[j]; |
90 kernel::String* uri = kernel_library->import_uri(); | 91 kernel::String* uri = kernel_library->import_uri(); |
91 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); | 92 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); |
92 if (kernel_name.Equals(dart_name)) { | 93 if (kernel_name.Equals(dart_name)) { |
93 reader.ReadLibrary(kernel_library); | 94 reader.ReadLibrary(kernel_library); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 132 } |
132 #else | 133 #else |
133 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, | 134 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, |
134 intptr_t kernel_buffer_length) { | 135 intptr_t kernel_buffer_length) { |
135 UNREACHABLE(); | 136 UNREACHABLE(); |
136 return Error::null(); | 137 return Error::null(); |
137 } | 138 } |
138 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 139 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
139 | 140 |
140 } // namespace dart | 141 } // namespace dart |
OLD | NEW |