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" |
11 #include "vm/compiler.h" | 11 #include "vm/compiler.h" |
12 #include "vm/dart_api_impl.h" | 12 #include "vm/dart_api_impl.h" |
| 13 #if !defined(DART_PRECOMPILED_RUNTIME) |
13 #include "vm/kernel.h" | 14 #include "vm/kernel.h" |
14 #include "vm/kernel_reader.h" | 15 #include "vm/kernel_reader.h" |
| 16 #endif |
15 #include "vm/object.h" | 17 #include "vm/object.h" |
16 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
17 #include "vm/symbols.h" | 19 #include "vm/symbols.h" |
18 | 20 |
19 namespace dart { | 21 namespace dart { |
20 | 22 |
21 | 23 |
22 struct BootstrapLibProps { | 24 struct BootstrapLibProps { |
23 ObjectStore::BootstrapLibraryId index; | 25 ObjectStore::BootstrapLibraryId index; |
24 const char* uri; | 26 const char* uri; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 if (error.IsNull()) { | 309 if (error.IsNull()) { |
308 Finish(thread, /*from_kernel=*/false); | 310 Finish(thread, /*from_kernel=*/false); |
309 } | 311 } |
310 // Restore the library tag handler for the isolate. | 312 // Restore the library tag handler for the isolate. |
311 isolate->set_library_tag_handler(saved_tag_handler); | 313 isolate->set_library_tag_handler(saved_tag_handler); |
312 | 314 |
313 return error.raw(); | 315 return error.raw(); |
314 } | 316 } |
315 | 317 |
316 | 318 |
| 319 #if !defined(DART_PRECOMPILED_RUNTIME) |
317 static RawError* BootstrapFromKernel(Thread* thread, | 320 static RawError* BootstrapFromKernel(Thread* thread, |
318 const uint8_t* buffer, | 321 const uint8_t* buffer, |
319 intptr_t buffer_size) { | 322 intptr_t buffer_size) { |
320 Zone* zone = thread->zone(); | 323 Zone* zone = thread->zone(); |
321 kernel::Program* program = | 324 kernel::Program* program = |
322 ReadPrecompiledKernelFromBuffer(buffer, buffer_size); | 325 ReadPrecompiledKernelFromBuffer(buffer, buffer_size); |
323 if (program == NULL) { | 326 if (program == NULL) { |
324 const String& message = | 327 const String& message = |
325 String::Handle(zone, String::New("Failed to read Kernel file")); | 328 String::Handle(zone, String::New("Failed to read Kernel file")); |
326 return ApiError::New(message); | 329 return ApiError::New(message); |
(...skipping 26 matching lines...) Expand all Loading... |
353 reader.ReadLibrary(kernel_library); | 356 reader.ReadLibrary(kernel_library); |
354 library.SetLoaded(); | 357 library.SetLoaded(); |
355 break; | 358 break; |
356 } | 359 } |
357 } | 360 } |
358 } | 361 } |
359 | 362 |
360 Finish(thread, /*from_kernel=*/true); | 363 Finish(thread, /*from_kernel=*/true); |
361 return Error::null(); | 364 return Error::null(); |
362 } | 365 } |
| 366 #else |
| 367 static RawError* BootstrapFromKernel(Thread* thread, |
| 368 const uint8_t* buffer, |
| 369 intptr_t buffer_size) { |
| 370 UNREACHABLE(); |
| 371 return Error::null(); |
| 372 } |
| 373 #endif |
363 | 374 |
364 | 375 |
365 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, | 376 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, |
366 intptr_t kernel_buffer_length) { | 377 intptr_t kernel_buffer_length) { |
367 Thread* thread = Thread::Current(); | 378 Thread* thread = Thread::Current(); |
368 Isolate* isolate = thread->isolate(); | 379 Isolate* isolate = thread->isolate(); |
369 Zone* zone = thread->zone(); | 380 Zone* zone = thread->zone(); |
370 String& uri = String::Handle(zone); | 381 String& uri = String::Handle(zone); |
371 Library& lib = Library::Handle(zone); | 382 Library& lib = Library::Handle(zone); |
372 | 383 |
(...skipping 12 matching lines...) Expand all Loading... |
385 isolate->object_store()->set_bootstrap_library(id, lib); | 396 isolate->object_store()->set_bootstrap_library(id, lib); |
386 } | 397 } |
387 } | 398 } |
388 | 399 |
389 return (kernel_buffer == NULL) | 400 return (kernel_buffer == NULL) |
390 ? BootstrapFromSource(thread) | 401 ? BootstrapFromSource(thread) |
391 : BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length); | 402 : BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length); |
392 } | 403 } |
393 | 404 |
394 } // namespace dart | 405 } // namespace dart |
OLD | NEW |