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 #include "vm/bootstrap_natives.h" | 9 #include "vm/bootstrap_natives.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 314 |
315 return error.raw(); | 315 return error.raw(); |
316 } | 316 } |
317 | 317 |
318 | 318 |
319 #if !defined(DART_PRECOMPILED_RUNTIME) | 319 #if !defined(DART_PRECOMPILED_RUNTIME) |
320 static RawError* BootstrapFromKernel(Thread* thread, | 320 static RawError* BootstrapFromKernel(Thread* thread, |
321 const uint8_t* buffer, | 321 const uint8_t* buffer, |
322 intptr_t buffer_size) { | 322 intptr_t buffer_size) { |
323 Zone* zone = thread->zone(); | 323 Zone* zone = thread->zone(); |
324 kernel::Program* program = | 324 kernel::KernelReader reader(buffer, buffer_size, true); |
325 ReadPrecompiledKernelFromBuffer(buffer, buffer_size); | 325 kernel::Program* program = reader.ReadPrecompiledProgram(); |
326 if (program == NULL) { | 326 if (program == NULL) { |
327 const String& message = | 327 const String& message = |
328 String::Handle(zone, String::New("Failed to read Kernel file")); | 328 String::Handle(zone, String::New("Failed to read Kernel file")); |
329 return ApiError::New(message); | 329 return ApiError::New(message); |
330 } | 330 } |
331 | 331 |
332 Isolate* isolate = thread->isolate(); | 332 Isolate* isolate = thread->isolate(); |
333 // Mark the already-pending classes. This mark bit will be used to avoid | 333 // Mark the already-pending classes. This mark bit will be used to avoid |
334 // adding classes to the list more than once. | 334 // adding classes to the list more than once. |
335 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( | 335 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( |
336 zone, isolate->object_store()->pending_classes()); | 336 zone, isolate->object_store()->pending_classes()); |
337 dart::Class& pending = dart::Class::Handle(zone); | 337 dart::Class& pending = dart::Class::Handle(zone); |
338 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { | 338 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { |
339 pending ^= pending_classes.At(i); | 339 pending ^= pending_classes.At(i); |
340 pending.set_is_marked_for_parsing(); | 340 pending.set_is_marked_for_parsing(); |
341 } | 341 } |
342 | 342 |
343 Library& library = Library::Handle(zone); | 343 Library& library = Library::Handle(zone); |
344 String& dart_name = String::Handle(zone); | 344 String& dart_name = String::Handle(zone); |
345 String& kernel_name = String::Handle(zone); | 345 String& kernel_name = String::Handle(zone); |
346 kernel::KernelReader reader(NULL, -1, true); | |
347 for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) { | 346 for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) { |
348 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; | 347 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; |
349 library = isolate->object_store()->bootstrap_library(id); | 348 library = isolate->object_store()->bootstrap_library(id); |
350 dart_name = library.url(); | 349 dart_name = library.url(); |
351 for (intptr_t j = 0; j < program->libraries().length(); ++j) { | 350 for (intptr_t j = 0; j < program->libraries().length(); ++j) { |
352 kernel::Library* kernel_library = program->libraries()[j]; | 351 kernel::Library* kernel_library = program->libraries()[j]; |
353 kernel::String* uri = kernel_library->import_uri(); | 352 kernel::String* uri = kernel_library->import_uri(); |
354 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); | 353 kernel_name = Symbols::FromUTF8(thread, uri->buffer(), uri->size()); |
355 if (kernel_name.Equals(dart_name)) { | 354 if (kernel_name.Equals(dart_name)) { |
356 reader.ReadLibrary(kernel_library); | 355 reader.ReadLibrary(kernel_library); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 isolate->object_store()->set_bootstrap_library(id, lib); | 395 isolate->object_store()->set_bootstrap_library(id, lib); |
397 } | 396 } |
398 } | 397 } |
399 | 398 |
400 return (kernel_buffer == NULL) | 399 return (kernel_buffer == NULL) |
401 ? BootstrapFromSource(thread) | 400 ? BootstrapFromSource(thread) |
402 : BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length); | 401 : BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length); |
403 } | 402 } |
404 | 403 |
405 } // namespace dart | 404 } // namespace dart |
OLD | NEW |