Chromium Code Reviews| 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_tools_api.h" | 10 #include "include/dart_tools_api.h" |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 const bool run_service_isolate = true; | 791 const bool run_service_isolate = true; |
| 792 #endif // PRODUCT | 792 #endif // PRODUCT |
| 793 if (!run_service_isolate && | 793 if (!run_service_isolate && |
| 794 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { | 794 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { |
| 795 return NULL; | 795 return NULL; |
| 796 } | 796 } |
| 797 | 797 |
| 798 IsolateData* isolate_data = new IsolateData(script_uri, | 798 IsolateData* isolate_data = new IsolateData(script_uri, |
| 799 package_root, | 799 package_root, |
| 800 packages_config); | 800 packages_config); |
| 801 if (gen_snapshot_kind == kAppJIT) { | |
| 802 isolate_data->set_exit_hook(SnapshotOnExitHook); | |
| 803 } | |
| 804 Dart_Isolate isolate = Dart_CreateIsolate(script_uri, | 801 Dart_Isolate isolate = Dart_CreateIsolate(script_uri, |
| 805 main, | 802 main, |
| 806 isolate_snapshot_buffer, | 803 isolate_snapshot_buffer, |
| 807 flags, | 804 flags, |
| 808 isolate_data, | 805 isolate_data, |
| 809 error); | 806 error); |
| 810 if (isolate == NULL) { | 807 if (isolate == NULL) { |
| 811 delete isolate_data; | 808 delete isolate_data; |
| 812 return NULL; | 809 return NULL; |
| 813 } | 810 } |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1531 Dart_ExitScope(); \ | 1528 Dart_ExitScope(); \ |
| 1532 Dart_ShutdownIsolate(); \ | 1529 Dart_ShutdownIsolate(); \ |
| 1533 return true; \ | 1530 return true; \ |
| 1534 } \ | 1531 } \ |
| 1535 const int exit_code = Dart_IsCompilationError(result) ? \ | 1532 const int exit_code = Dart_IsCompilationError(result) ? \ |
| 1536 kCompilationErrorExitCode : kErrorExitCode; \ | 1533 kCompilationErrorExitCode : kErrorExitCode; \ |
| 1537 ErrorExit(exit_code, "%s\n", Dart_GetError(result)); \ | 1534 ErrorExit(exit_code, "%s\n", Dart_GetError(result)); \ |
| 1538 } | 1535 } |
| 1539 | 1536 |
| 1540 | 1537 |
| 1541 static void SnapshotOnExitHook(int64_t exit_code) { | 1538 static void SnapshotOnExitHook(int64_t exit_code) { |
|
siva
2016/10/31 21:52:20
As discussed offline maybe add a check here that t
rmacnak
2016/10/31 22:38:47
Done.
| |
| 1542 if (exit_code == 0) { | 1539 if (exit_code == 0) { |
| 1543 GenerateAppSnapshot(); | 1540 GenerateAppSnapshot(); |
| 1544 } | 1541 } |
| 1545 } | 1542 } |
| 1546 | 1543 |
| 1547 | 1544 |
| 1548 bool RunMainIsolate(const char* script_name, | 1545 bool RunMainIsolate(const char* script_name, |
| 1549 CommandLineOptions* dart_options) { | 1546 CommandLineOptions* dart_options) { |
| 1550 // Call CreateIsolateAndSetup which creates an isolate and loads up | 1547 // Call CreateIsolateAndSetup which creates an isolate and loads up |
| 1551 // the specified application script. | 1548 // the specified application script. |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1884 | 1881 |
| 1885 if (gen_snapshot_kind == kAppJIT) { | 1882 if (gen_snapshot_kind == kAppJIT) { |
| 1886 vm_options.AddArgument("--fields_may_be_reset"); | 1883 vm_options.AddArgument("--fields_may_be_reset"); |
| 1887 } | 1884 } |
| 1888 if ((gen_snapshot_kind == kAppAOT) || is_noopt) { | 1885 if ((gen_snapshot_kind == kAppAOT) || is_noopt) { |
| 1889 vm_options.AddArgument("--precompilation"); | 1886 vm_options.AddArgument("--precompilation"); |
| 1890 } | 1887 } |
| 1891 #if defined(DART_PRECOMPILED_RUNTIME) | 1888 #if defined(DART_PRECOMPILED_RUNTIME) |
| 1892 vm_options.AddArgument("--precompilation"); | 1889 vm_options.AddArgument("--precompilation"); |
| 1893 #endif | 1890 #endif |
| 1891 if (gen_snapshot_kind == kAppJIT) { | |
| 1892 Process::SetExitHook(SnapshotOnExitHook); | |
| 1893 } | |
| 1894 | 1894 |
| 1895 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 1895 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 1896 | 1896 |
| 1897 // Start event handler. | 1897 // Start event handler. |
| 1898 TimerUtils::InitOnce(); | 1898 TimerUtils::InitOnce(); |
| 1899 EventHandler::Start(); | 1899 EventHandler::Start(); |
| 1900 | 1900 |
| 1901 // Initialize the Dart VM. | 1901 // Initialize the Dart VM. |
| 1902 Dart_InitializeParams init_params; | 1902 Dart_InitializeParams init_params; |
| 1903 memset(&init_params, 0, sizeof(init_params)); | 1903 memset(&init_params, 0, sizeof(init_params)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 Platform::Exit(Process::GlobalExitCode()); | 1965 Platform::Exit(Process::GlobalExitCode()); |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 } // namespace bin | 1968 } // namespace bin |
| 1969 } // namespace dart | 1969 } // namespace dart |
| 1970 | 1970 |
| 1971 int main(int argc, char** argv) { | 1971 int main(int argc, char** argv) { |
| 1972 dart::bin::main(argc, argv); | 1972 dart::bin::main(argc, argv); |
| 1973 UNREACHABLE(); | 1973 UNREACHABLE(); |
| 1974 } | 1974 } |
| OLD | NEW |