Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: runtime/bin/main.cc

Issue 1663963002: - reorganize DartUtils::PrepareForScriptLoading so that it does not have the wait for service load … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 } 736 }
737 if (has_compile_all) { 737 if (has_compile_all) {
738 result = Dart_CompileAll(); 738 result = Dart_CompileAll();
739 CHECK_RESULT(result); 739 CHECK_RESULT(result);
740 } 740 }
741 Dart_ExitScope(); 741 Dart_ExitScope();
742 Dart_ExitIsolate(); 742 Dart_ExitIsolate();
743 return isolate; 743 return isolate;
744 } 744 }
745 745
746 // Load the specified application script into the newly created isolate. 746 // Prepare builtin and other core libraries for use to resolve URIs.
747 // Set up various closures, e.g: printing, timers etc.
748 // Set up 'package root' for URI resolution.
749 result = DartUtils::PrepareForScriptLoading(false, has_trace_loading);
750 CHECK_RESULT(result);
747 751
748 // Prepare builtin and its dependent libraries for use to resolve URIs. 752 // Set up the load port provided by the service isolate so that we can
749 // The builtin library is part of the core snapshot and would already be 753 // load scripts.
750 // available here in the case of script snapshot loading. 754 result = DartUtils::SetupServiceLoadPort();
751 Dart_Handle builtin_lib = 755 CHECK_RESULT(result);
752 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
753 CHECK_RESULT(builtin_lib);
754 756
755 // Prepare for script loading by setting up the 'print' and 'timer' 757 // Setup package root if specified.
756 // closures and setting up 'package root' for URI resolution. 758 result = DartUtils::SetupPackageRoot(package_root, packages_config);
757 result = DartUtils::PrepareForScriptLoading(package_root,
758 packages_config,
759 false,
760 has_trace_loading,
761 builtin_lib);
762 CHECK_RESULT(result); 759 CHECK_RESULT(result);
763 760
764 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 761 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
765 CHECK_RESULT(result); 762 CHECK_RESULT(result);
766 763
767 if (!has_run_precompiled_snapshot) { 764 if (!has_run_precompiled_snapshot) {
765 // Load the specified application script into the newly created isolate.
766
768 // Load the script. 767 // Load the script.
769 result = DartUtils::LoadScript(script_uri, builtin_lib); 768 result = DartUtils::LoadScript(script_uri);
770 CHECK_RESULT(result); 769 CHECK_RESULT(result);
771 770
772 // Run event-loop and wait for script loading to complete. 771 // Run event-loop and wait for script loading to complete.
773 result = Dart_RunLoop(); 772 result = Dart_RunLoop();
774 CHECK_RESULT(result); 773 CHECK_RESULT(result);
775 774
776 if (isolate_data->load_async_id >= 0) { 775 if (isolate_data->load_async_id >= 0) {
777 Dart_TimelineAsyncEnd("LoadScript", isolate_data->load_async_id); 776 Dart_TimelineAsyncEnd("LoadScript", isolate_data->load_async_id);
778 } 777 }
779 778
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 1166
1168 Dart_EnterScope(); 1167 Dart_EnterScope();
1169 1168
1170 if (generate_script_snapshot) { 1169 if (generate_script_snapshot) {
1171 GenerateScriptSnapshot(); 1170 GenerateScriptSnapshot();
1172 } else { 1171 } else {
1173 // Lookup the library of the root script. 1172 // Lookup the library of the root script.
1174 Dart_Handle root_lib = Dart_RootLibrary(); 1173 Dart_Handle root_lib = Dart_RootLibrary();
1175 // Import the root library into the builtin library so that we can easily 1174 // Import the root library into the builtin library so that we can easily
1176 // lookup the main entry point exported from the root library. 1175 // lookup the main entry point exported from the root library.
1177 Dart_Handle builtin_lib = 1176 IsolateData* isolate_data =
1178 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 1177 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate));
1179 ASSERT(!Dart_IsError(builtin_lib)); 1178 result = Dart_LibraryImportLibrary(
1180 result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null()); 1179 isolate_data->builtin_lib(), root_lib, Dart_Null());
1181
1182 if (has_gen_precompiled_snapshot) { 1180 if (has_gen_precompiled_snapshot) {
1183 // Load the embedder's portion of the VM service's Dart code so it will 1181 // Load the embedder's portion of the VM service's Dart code so it will
1184 // be included in the precompiled snapshot. 1182 // be included in the precompiled snapshot.
1185 if (!VmService::LoadForGenPrecompiled()) { 1183 if (!VmService::LoadForGenPrecompiled()) {
1186 fprintf(stderr, 1184 fprintf(stderr,
1187 "VM service loading failed: %s\n", 1185 "VM service loading failed: %s\n",
1188 VmService::GetErrorMessage()); 1186 VmService::GetErrorMessage());
1189 fflush(stderr); 1187 fflush(stderr);
1190 exit(kErrorExitCode); 1188 exit(kErrorExitCode);
1191 } 1189 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 } else { 1259 } else {
1262 if (Dart_IsNull(root_lib)) { 1260 if (Dart_IsNull(root_lib)) {
1263 ErrorExit(kErrorExitCode, 1261 ErrorExit(kErrorExitCode,
1264 "Unable to find root library for '%s'\n", 1262 "Unable to find root library for '%s'\n",
1265 script_name); 1263 script_name);
1266 } 1264 }
1267 1265
1268 // The helper function _getMainClosure creates a closure for the main 1266 // The helper function _getMainClosure creates a closure for the main
1269 // entry point which is either explicitly or implictly exported from the 1267 // entry point which is either explicitly or implictly exported from the
1270 // root library. 1268 // root library.
1271 Dart_Handle main_closure = Dart_Invoke(builtin_lib, 1269 Dart_Handle main_closure = Dart_Invoke(isolate_data->builtin_lib(),
1272 Dart_NewStringFromCString("_getMainClosure"), 0, NULL); 1270 Dart_NewStringFromCString("_getMainClosure"), 0, NULL);
1273 CHECK_RESULT(main_closure); 1271 CHECK_RESULT(main_closure);
1274 1272
1275 // Call _startIsolate in the isolate library to enable dispatching the 1273 // Call _startIsolate in the isolate library to enable dispatching the
1276 // initial startup message. 1274 // initial startup message.
1277 const intptr_t kNumIsolateArgs = 2; 1275 const intptr_t kNumIsolateArgs = 2;
1278 Dart_Handle isolate_args[kNumIsolateArgs]; 1276 Dart_Handle isolate_args[kNumIsolateArgs];
1279 isolate_args[0] = main_closure; // entryPoint 1277 isolate_args[0] = main_closure; // entryPoint
1280 isolate_args[1] = CreateRuntimeOptions(dart_options); // args 1278 isolate_args[1] = CreateRuntimeOptions(dart_options); // args
1281 1279
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 Platform::Exit(Process::GlobalExitCode()); 1531 Platform::Exit(Process::GlobalExitCode());
1534 } 1532 }
1535 1533
1536 } // namespace bin 1534 } // namespace bin
1537 } // namespace dart 1535 } // namespace dart
1538 1536
1539 int main(int argc, char** argv) { 1537 int main(int argc, char** argv) {
1540 dart::bin::main(argc, argv); 1538 dart::bin::main(argc, argv);
1541 UNREACHABLE(); 1539 UNREACHABLE();
1542 } 1540 }
OLDNEW
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698