| 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::Program* program = | 62 kernel::KernelReader reader(buffer, buffer_length, true); |
| 63 ReadPrecompiledKernelFromBuffer(buffer, buffer_length); | 63 kernel::Program* program = reader.ReadPrecompiledProgram(); |
| 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); | |
| 85 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { | 84 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { |
| 86 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 85 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
| 87 library = isolate->object_store()->bootstrap_library(id); | 86 library = isolate->object_store()->bootstrap_library(id); |
| 88 dart_name = library.url(); | 87 dart_name = library.url(); |
| 89 for (intptr_t j = 0; j < program->libraries().length(); ++j) { | 88 for (intptr_t j = 0; j < program->libraries().length(); ++j) { |
| 90 kernel::Library* kernel_library = program->libraries()[j]; | 89 kernel::Library* kernel_library = program->libraries()[j]; |
| 91 kernel::String* uri = kernel_library->import_uri(); | 90 kernel::String* uri = kernel_library->import_uri(); |
| 92 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); | 91 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); |
| 93 if (kernel_name.Equals(dart_name)) { | 92 if (kernel_name.Equals(dart_name)) { |
| 94 reader.ReadLibrary(kernel_library); | 93 reader.ReadLibrary(kernel_library); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 131 } |
| 133 #else | 132 #else |
| 134 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, | 133 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, |
| 135 intptr_t kernel_buffer_length) { | 134 intptr_t kernel_buffer_length) { |
| 136 UNREACHABLE(); | 135 UNREACHABLE(); |
| 137 return Error::null(); | 136 return Error::null(); |
| 138 } | 137 } |
| 139 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 138 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 140 | 139 |
| 141 } // namespace dart | 140 } // namespace dart |
| OLD | NEW |