OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
6 // command line. | 6 // command line. |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 | 537 |
538 vm_options.AddArgument("--load_deferred_eagerly"); | 538 vm_options.AddArgument("--load_deferred_eagerly"); |
539 // Workaround until issue 21620 is fixed. | 539 // Workaround until issue 21620 is fixed. |
540 // (https://github.com/dart-lang/sdk/issues/21620) | 540 // (https://github.com/dart-lang/sdk/issues/21620) |
541 vm_options.AddArgument("--no-concurrent_sweep"); | 541 vm_options.AddArgument("--no-concurrent_sweep"); |
542 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 542 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
543 | 543 |
544 // Initialize the Dart VM. | 544 // Initialize the Dart VM. |
545 // Note: We don't expect isolates to be created from dart code during | 545 // Note: We don't expect isolates to be created from dart code during |
546 // snapshot generation. | 546 // snapshot generation. |
547 if (!Dart_Initialize(NULL, | 547 char* error = Dart_Initialize(NULL, NULL, NULL, NULL, NULL, |
548 NULL, NULL, NULL, NULL, | 548 DartUtils::OpenFile, |
549 DartUtils::OpenFile, | 549 DartUtils::ReadFile, |
550 DartUtils::ReadFile, | 550 DartUtils::WriteFile, |
551 DartUtils::WriteFile, | 551 DartUtils::CloseFile, |
552 DartUtils::CloseFile, | 552 DartUtils::EntropySource); |
553 DartUtils::EntropySource)) { | 553 if (error != NULL) { |
554 Log::PrintErr("VM initialization failed\n"); | 554 Log::PrintErr("VM initialization failed: %s\n", error); |
| 555 free(error); |
555 return 255; | 556 return 255; |
556 } | 557 } |
557 | 558 |
558 char* error; | |
559 Dart_Isolate isolate = Dart_CreateIsolate( | 559 Dart_Isolate isolate = Dart_CreateIsolate( |
560 NULL, NULL, NULL, NULL, NULL, &error); | 560 NULL, NULL, NULL, NULL, NULL, &error); |
561 if (isolate == NULL) { | 561 if (isolate == NULL) { |
562 Log::PrintErr("Error: %s", error); | 562 Log::PrintErr("Error: %s", error); |
563 free(error); | 563 free(error); |
564 exit(255); | 564 exit(255); |
565 } | 565 } |
566 | 566 |
567 Dart_Handle result; | 567 Dart_Handle result; |
568 Dart_Handle library; | 568 Dart_Handle library; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 631 } |
632 return 0; | 632 return 0; |
633 } | 633 } |
634 | 634 |
635 } // namespace bin | 635 } // namespace bin |
636 } // namespace dart | 636 } // namespace dart |
637 | 637 |
638 int main(int argc, char** argv) { | 638 int main(int argc, char** argv) { |
639 return dart::bin::main(argc, argv); | 639 return dart::bin::main(argc, argv); |
640 } | 640 } |
OLD | NEW |