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

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

Powered by Google App Engine
This is Rietveld 408576698