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

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

Issue 1690303002: Add dart_product binary (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 " dart_no_snapshot\n"); 400 " dart_no_snapshot\n");
401 return false; 401 return false;
402 } 402 }
403 return ProcessSnapshotOptionHelper(filename, 403 return ProcessSnapshotOptionHelper(filename,
404 &generate_full_snapshot_after_run); 404 &generate_full_snapshot_after_run);
405 } 405 }
406 406
407 407
408 static bool ProcessRunFullSnapshotOption( 408 static bool ProcessRunFullSnapshotOption(
409 const char* filename, CommandLineOptions* vm_options) { 409 const char* filename, CommandLineOptions* vm_options) {
410 #ifndef DART_PRODUCT_BINARY
410 // Ensure that we are not running 'dart_no_snapshot'. 411 // Ensure that we are not running 'dart_no_snapshot'.
411 if (isolate_snapshot_buffer == NULL) { 412 if (isolate_snapshot_buffer == NULL) {
412 Log::PrintErr("Full Application snapshots cannot be run with" 413 Log::PrintErr("Full Application snapshots cannot be run with"
413 " dart_no_snapshot\n"); 414 " dart_no_snapshot\n");
414 return false; 415 return false;
415 } 416 }
417 #endif
416 return ProcessSnapshotOptionHelper(filename, &run_full_snapshot); 418 return ProcessSnapshotOptionHelper(filename, &run_full_snapshot);
417 } 419 }
418 420
419 421
420 static bool ProcessEnableVmServiceOption(const char* option_value, 422 static bool ProcessEnableVmServiceOption(const char* option_value,
421 CommandLineOptions* vm_options) { 423 CommandLineOptions* vm_options) {
422 ASSERT(option_value != NULL); 424 ASSERT(option_value != NULL);
423 425
424 if (!ExtractPortAndIP(option_value, 426 if (!ExtractPortAndIP(option_value,
425 &vm_service_server_port, 427 &vm_service_server_port,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 737
736 // Returns true on success, false on failure. 738 // Returns true on success, false on failure.
737 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, 739 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
738 const char* main, 740 const char* main,
739 const char* package_root, 741 const char* package_root,
740 const char* packages_config, 742 const char* packages_config,
741 Dart_IsolateFlags* flags, 743 Dart_IsolateFlags* flags,
742 char** error, 744 char** error,
743 int* exit_code) { 745 int* exit_code) {
744 ASSERT(script_uri != NULL); 746 ASSERT(script_uri != NULL);
747 #if defined(DART_PRODUCT_BINARY)
748 if (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0) {
749 // No service isolate support.
750 return NULL;
751 }
752 #endif // defined(DART_PRODUCT_BINARY)
753
745 if (run_full_snapshot && 754 if (run_full_snapshot &&
746 !strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME)) { 755 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) {
siva 2016/02/12 18:18:02 I am wondering if we can move all this run_full_sn
Cutch 2016/02/12 18:33:43 I've made it so this flag only works in the dart_p
747 // We do not create a service isolate when running a full application 756 // We do not create a service isolate when running a full application
748 // snapshot. 757 // snapshot.
749 return NULL; 758 return NULL;
750 } 759 }
751 IsolateData* isolate_data = new IsolateData(script_uri, 760 IsolateData* isolate_data = new IsolateData(script_uri,
752 package_root, 761 package_root,
753 packages_config); 762 packages_config);
754 Dart_Isolate isolate = NULL; 763 Dart_Isolate isolate = NULL;
755 764
756 isolate = Dart_CreateIsolate(script_uri, 765 isolate = Dart_CreateIsolate(script_uri,
(...skipping 13 matching lines...) Expand all
770 if (isolate_snapshot_buffer != NULL) { 779 if (isolate_snapshot_buffer != NULL) {
771 // Setup the native resolver as the snapshot does not carry it. 780 // Setup the native resolver as the snapshot does not carry it.
772 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 781 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
773 Builtin::SetNativeResolver(Builtin::kIOLibrary); 782 Builtin::SetNativeResolver(Builtin::kIOLibrary);
774 } 783 }
775 784
776 // Set up the library tag handler for this isolate. 785 // Set up the library tag handler for this isolate.
777 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); 786 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler);
778 CHECK_RESULT(result); 787 CHECK_RESULT(result);
779 788
789 #if defined(DART_PRODUCT_BINARY)
790 ASSERT(!Dart_IsServiceIsolate(isolate));
791 #else
780 if (Dart_IsServiceIsolate(isolate)) { 792 if (Dart_IsServiceIsolate(isolate)) {
781 // If this is the service isolate, load embedder specific bits and return. 793 // If this is the service isolate, load embedder specific bits and return.
782 if (!VmService::Setup(vm_service_server_ip, 794 if (!VmService::Setup(vm_service_server_ip,
783 vm_service_server_port, 795 vm_service_server_port,
784 run_precompiled_snapshot)) { 796 run_precompiled_snapshot)) {
785 *error = strdup(VmService::GetErrorMessage()); 797 *error = strdup(VmService::GetErrorMessage());
786 return NULL; 798 return NULL;
787 } 799 }
788 if (compile_all) { 800 if (compile_all) {
789 result = Dart_CompileAll(); 801 result = Dart_CompileAll();
790 CHECK_RESULT(result); 802 CHECK_RESULT(result);
791 } 803 }
792 Dart_ExitScope(); 804 Dart_ExitScope();
793 Dart_ExitIsolate(); 805 Dart_ExitIsolate();
794 return isolate; 806 return isolate;
795 } 807 }
808 #endif // defined(DART_PRODUCT_BINARY)
796 809
797 // Prepare builtin and other core libraries for use to resolve URIs. 810 // Prepare builtin and other core libraries for use to resolve URIs.
798 // Set up various closures, e.g: printing, timers etc. 811 // Set up various closures, e.g: printing, timers etc.
799 // Set up 'package root' for URI resolution. 812 // Set up 'package root' for URI resolution.
800 result = DartUtils::PrepareForScriptLoading(false, trace_loading); 813 result = DartUtils::PrepareForScriptLoading(false, trace_loading);
801 CHECK_RESULT(result); 814 CHECK_RESULT(result);
802 815
803 if (!run_full_snapshot) { 816 if (!run_full_snapshot) {
804 // Set up the load port provided by the service isolate so that we can 817 // Set up the load port provided by the service isolate so that we can
805 // load scripts. 818 // load scripts.
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 GenerateScriptSnapshot(); 1274 GenerateScriptSnapshot();
1262 } else { 1275 } else {
1263 // Lookup the library of the root script. 1276 // Lookup the library of the root script.
1264 Dart_Handle root_lib = Dart_RootLibrary(); 1277 Dart_Handle root_lib = Dart_RootLibrary();
1265 // Import the root library into the builtin library so that we can easily 1278 // Import the root library into the builtin library so that we can easily
1266 // lookup the main entry point exported from the root library. 1279 // lookup the main entry point exported from the root library.
1267 IsolateData* isolate_data = 1280 IsolateData* isolate_data =
1268 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); 1281 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate));
1269 result = Dart_LibraryImportLibrary( 1282 result = Dart_LibraryImportLibrary(
1270 isolate_data->builtin_lib(), root_lib, Dart_Null()); 1283 isolate_data->builtin_lib(), root_lib, Dart_Null());
1284 #ifndef DART_PRODUCT_BINARY
1271 if (is_noopt || gen_precompiled_snapshot) { 1285 if (is_noopt || gen_precompiled_snapshot) {
1272 // Load the embedder's portion of the VM service's Dart code so it will 1286 // Load the embedder's portion of the VM service's Dart code so it will
1273 // be included in the precompiled snapshot. 1287 // be included in the precompiled snapshot.
1274 if (!VmService::LoadForGenPrecompiled()) { 1288 if (!VmService::LoadForGenPrecompiled()) {
1275 fprintf(stderr, 1289 fprintf(stderr,
1276 "VM service loading failed: %s\n", 1290 "VM service loading failed: %s\n",
1277 VmService::GetErrorMessage()); 1291 VmService::GetErrorMessage());
1278 fflush(stderr); 1292 fflush(stderr);
1279 exit(kErrorExitCode); 1293 exit(kErrorExitCode);
1280 } 1294 }
1281 } 1295 }
1296 #endif // !DART_PRODUCT_BINARY
1282 1297
1283 if (compile_all) { 1298 if (compile_all) {
1284 result = Dart_CompileAll(); 1299 result = Dart_CompileAll();
1285 CHECK_RESULT(result); 1300 CHECK_RESULT(result);
1286 } 1301 }
1287 1302
1288 if (is_noopt || gen_precompiled_snapshot) { 1303 if (is_noopt || gen_precompiled_snapshot) {
1289 Dart_QualifiedFunctionName standalone_entry_points[] = { 1304 Dart_QualifiedFunctionName standalone_entry_points[] = {
1290 { "dart:_builtin", "::", "_getMainClosure" }, 1305 { "dart:_builtin", "::", "_getMainClosure" },
1291 { "dart:_builtin", "::", "_getPrintClosure" }, 1306 { "dart:_builtin", "::", "_getPrintClosure" },
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 Platform::Exit(Process::GlobalExitCode()); 1653 Platform::Exit(Process::GlobalExitCode());
1639 } 1654 }
1640 1655
1641 } // namespace bin 1656 } // namespace bin
1642 } // namespace dart 1657 } // namespace dart
1643 1658
1644 int main(int argc, char** argv) { 1659 int main(int argc, char** argv) {
1645 dart::bin::main(argc, argv); 1660 dart::bin::main(argc, argv);
1646 UNREACHABLE(); 1661 UNREACHABLE();
1647 } 1662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698