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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "include/dart_debugger_api.h" | 10 #include "include/dart_debugger_api.h" |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 Dart_ExitScope(); \ | 572 Dart_ExitScope(); \ |
573 Dart_ShutdownIsolate(); \ | 573 Dart_ShutdownIsolate(); \ |
574 return NULL; \ | 574 return NULL; \ |
575 } \ | 575 } \ |
576 | 576 |
577 | 577 |
578 // Returns true on success, false on failure. | 578 // Returns true on success, false on failure. |
579 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, | 579 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
580 const char* main, | 580 const char* main, |
581 const char* package_root, | 581 const char* package_root, |
| 582 Dart_IsolateFlags* flags, |
582 char** error, | 583 char** error, |
583 int* exit_code) { | 584 int* exit_code) { |
584 ASSERT(script_uri != NULL); | 585 ASSERT(script_uri != NULL); |
585 IsolateData* isolate_data = new IsolateData(script_uri, package_root); | 586 IsolateData* isolate_data = new IsolateData(script_uri, package_root); |
586 Dart_Isolate isolate = NULL; | 587 Dart_Isolate isolate = NULL; |
587 | 588 |
588 isolate = Dart_CreateIsolate(script_uri, | 589 isolate = Dart_CreateIsolate(script_uri, |
589 main, | 590 main, |
590 isolate_snapshot_buffer, | 591 isolate_snapshot_buffer, |
| 592 flags, |
591 isolate_data, | 593 isolate_data, |
592 error); | 594 error); |
593 | 595 |
594 if (isolate == NULL) { | 596 if (isolate == NULL) { |
595 return NULL; | 597 return NULL; |
596 } | 598 } |
597 | 599 |
598 Dart_EnterScope(); | 600 Dart_EnterScope(); |
599 | 601 |
600 if (isolate_snapshot_buffer != NULL) { | 602 if (isolate_snapshot_buffer != NULL) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 668 } |
667 | 669 |
668 return isolate; | 670 return isolate; |
669 } | 671 } |
670 | 672 |
671 #undef CHECK_RESULT | 673 #undef CHECK_RESULT |
672 | 674 |
673 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, | 675 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
674 const char* main, | 676 const char* main, |
675 const char* package_root, | 677 const char* package_root, |
| 678 Dart_IsolateFlags* flags, |
676 void* data, char** error) { | 679 void* data, char** error) { |
| 680 // The VM should never call the isolate helper with a NULL flags. |
| 681 ASSERT(flags != NULL); |
| 682 ASSERT(flags->version == DART_FLAGS_CURRENT_VERSION); |
677 IsolateData* parent_isolate_data = reinterpret_cast<IsolateData*>(data); | 683 IsolateData* parent_isolate_data = reinterpret_cast<IsolateData*>(data); |
678 int exit_code = 0; | 684 int exit_code = 0; |
679 if (script_uri == NULL) { | 685 if (script_uri == NULL) { |
680 if (data == NULL) { | 686 if (data == NULL) { |
681 *error = strdup("Invalid 'callback_data' - Unable to spawn new isolate"); | 687 *error = strdup("Invalid 'callback_data' - Unable to spawn new isolate"); |
682 return NULL; | 688 return NULL; |
683 } | 689 } |
684 script_uri = parent_isolate_data->script_url; | 690 script_uri = parent_isolate_data->script_url; |
685 if (script_uri == NULL) { | 691 if (script_uri == NULL) { |
686 *error = strdup("Invalid 'callback_data' - Unable to spawn new isolate"); | 692 *error = strdup("Invalid 'callback_data' - Unable to spawn new isolate"); |
687 return NULL; | 693 return NULL; |
688 } | 694 } |
689 } | 695 } |
690 if (package_root == NULL) { | 696 if (package_root == NULL) { |
691 if (parent_isolate_data != NULL) { | 697 if (parent_isolate_data != NULL) { |
692 package_root = parent_isolate_data->package_root; | 698 package_root = parent_isolate_data->package_root; |
693 } else { | 699 } else { |
694 package_root = "."; | 700 package_root = "."; |
695 } | 701 } |
696 } | 702 } |
697 return CreateIsolateAndSetupHelper(script_uri, | 703 return CreateIsolateAndSetupHelper(script_uri, |
698 main, | 704 main, |
699 package_root, | 705 package_root, |
| 706 flags, |
700 error, | 707 error, |
701 &exit_code); | 708 &exit_code); |
702 } | 709 } |
703 | 710 |
704 | 711 |
705 static void PrintVersion() { | 712 static void PrintVersion() { |
706 Log::PrintErr("Dart VM version: %s\n", Dart_VersionString()); | 713 Log::PrintErr("Dart VM version: %s\n", Dart_VersionString()); |
707 } | 714 } |
708 | 715 |
709 | 716 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 "getIO", &ServiceGetIOHandler, NULL); | 967 "getIO", &ServiceGetIOHandler, NULL); |
961 | 968 |
962 // Call CreateIsolateAndSetup which creates an isolate and loads up | 969 // Call CreateIsolateAndSetup which creates an isolate and loads up |
963 // the specified application script. | 970 // the specified application script. |
964 char* error = NULL; | 971 char* error = NULL; |
965 int exit_code = 0; | 972 int exit_code = 0; |
966 char* isolate_name = BuildIsolateName(script_name, "main"); | 973 char* isolate_name = BuildIsolateName(script_name, "main"); |
967 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, | 974 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, |
968 "main", | 975 "main", |
969 commandline_package_root, | 976 commandline_package_root, |
| 977 NULL, |
970 &error, | 978 &error, |
971 &exit_code); | 979 &exit_code); |
972 if (isolate == NULL) { | 980 if (isolate == NULL) { |
973 Log::PrintErr("%s\n", error); | 981 Log::PrintErr("%s\n", error); |
974 free(error); | 982 free(error); |
975 delete [] isolate_name; | 983 delete [] isolate_name; |
976 exit((exit_code != 0) ? exit_code : kErrorExitCode); | 984 exit((exit_code != 0) ? exit_code : kErrorExitCode); |
977 } | 985 } |
978 delete [] isolate_name; | 986 delete [] isolate_name; |
979 | 987 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 exit(Process::GlobalExitCode()); | 1102 exit(Process::GlobalExitCode()); |
1095 } | 1103 } |
1096 | 1104 |
1097 } // namespace bin | 1105 } // namespace bin |
1098 } // namespace dart | 1106 } // namespace dart |
1099 | 1107 |
1100 int main(int argc, char** argv) { | 1108 int main(int argc, char** argv) { |
1101 dart::bin::main(argc, argv); | 1109 dart::bin::main(argc, argv); |
1102 UNREACHABLE(); | 1110 UNREACHABLE(); |
1103 } | 1111 } |
OLD | NEW |