| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // Value of the --gen/run_precompiled_snapshot flag. | 74 // Value of the --gen/run_precompiled_snapshot flag. |
| 75 // (This pointer points into an argv buffer and does not need to be | 75 // (This pointer points into an argv buffer and does not need to be |
| 76 // free'd.) | 76 // free'd.) |
| 77 static const char* precompiled_snapshot_directory = NULL; | 77 static const char* precompiled_snapshot_directory = NULL; |
| 78 | 78 |
| 79 | 79 |
| 80 // Global flag that is used to indicate that we want to compile everything in | 80 // Global flag that is used to indicate that we want to compile everything in |
| 81 // the same way as precompilation before main, then continue running in the | 81 // the same way as precompilation before main, then continue running in the |
| 82 // same process. | 82 // same process. |
| 83 static bool has_noopt = false; | 83 // Always set this with dart_noopt. |
| 84 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT) |
| 85 static const bool has_noopt = true; |
| 86 #else |
| 87 static const bool has_noopt = false; |
| 88 #endif |
| 84 | 89 |
| 85 | 90 |
| 86 extern const char* kPrecompiledLibraryName; | 91 extern const char* kPrecompiledLibraryName; |
| 87 extern const char* kPrecompiledSymbolName; | 92 extern const char* kPrecompiledSymbolName; |
| 88 static const char* kPrecompiledVmIsolateName = "precompiled.vmisolate"; | 93 static const char* kPrecompiledVmIsolateName = "precompiled.vmisolate"; |
| 89 static const char* kPrecompiledIsolateName = "precompiled.isolate"; | 94 static const char* kPrecompiledIsolateName = "precompiled.isolate"; |
| 90 static const char* kPrecompiledInstructionsName = "precompiled.S"; | 95 static const char* kPrecompiledInstructionsName = "precompiled.S"; |
| 91 | 96 |
| 92 | 97 |
| 93 // Global flag that is used to indicate that we want to trace resolution of | 98 // Global flag that is used to indicate that we want to trace resolution of |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 595 |
| 591 // Verify consistency of arguments. | 596 // Verify consistency of arguments. |
| 592 if ((commandline_package_root != NULL) && | 597 if ((commandline_package_root != NULL) && |
| 593 (commandline_packages_file != NULL)) { | 598 (commandline_packages_file != NULL)) { |
| 594 Log::PrintErr("Specifying both a packages directory and a packages " | 599 Log::PrintErr("Specifying both a packages directory and a packages " |
| 595 "file is invalid.\n"); | 600 "file is invalid.\n"); |
| 596 return -1; | 601 return -1; |
| 597 } | 602 } |
| 598 if (has_noopt) { | 603 if (has_noopt) { |
| 599 if (has_gen_precompiled_snapshot) { | 604 if (has_gen_precompiled_snapshot) { |
| 600 Log::PrintErr("Specifying --noopt and --gen_precompiled_snapshot" | 605 Log::PrintErr("Running dart_noopt with --gen_precompiled_snapshot" |
| 601 " is invalid.\n"); | 606 " is invalid.\n"); |
| 602 return -1; | 607 return -1; |
| 603 } | 608 } |
| 604 if (has_run_precompiled_snapshot) { | 609 if (has_run_precompiled_snapshot) { |
| 605 Log::PrintErr("Specifying --noopt and --run_precompiled_snapshot" | 610 Log::PrintErr("Running dart_noopt with --run_precompiled_snapshot" |
| 606 " is invalid.\n"); | 611 " is invalid.\n"); |
| 607 return -1; | 612 return -1; |
| 608 } | 613 } |
| 609 } | 614 } |
| 610 if (has_gen_precompiled_snapshot && has_run_precompiled_snapshot) { | 615 if (has_gen_precompiled_snapshot && has_run_precompiled_snapshot) { |
| 611 Log::PrintErr("Specifying --gen_precompiled_snapshot and" | 616 Log::PrintErr("Specifying --gen_precompiled_snapshot and" |
| 612 " --run_precompiled_snapshot is invalid.\n"); | 617 " --run_precompiled_snapshot is invalid.\n"); |
| 613 return -1; | 618 return -1; |
| 614 } | 619 } |
| 615 | 620 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 fprintf(stderr, "Error determining current directory: %s\n", err.message()); | 1443 fprintf(stderr, "Error determining current directory: %s\n", err.message()); |
| 1439 fflush(stderr); | 1444 fflush(stderr); |
| 1440 Platform::Exit(kErrorExitCode); | 1445 Platform::Exit(kErrorExitCode); |
| 1441 } | 1446 } |
| 1442 | 1447 |
| 1443 if (generate_script_snapshot) { | 1448 if (generate_script_snapshot) { |
| 1444 vm_options.AddArgument("--load_deferred_eagerly"); | 1449 vm_options.AddArgument("--load_deferred_eagerly"); |
| 1445 } | 1450 } |
| 1446 | 1451 |
| 1447 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT) | 1452 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT) |
| 1448 // Always set --precompilation with dart_noopt, unless already set by these | 1453 // Always set --precompilation with dart_noopt. |
| 1449 // command line options. | 1454 ASSERT(!has_gen_precompiled_snapshot && !has_run_precompiled_snapshot); |
| 1450 if (!has_gen_precompiled_snapshot && | 1455 vm_options.AddArgument("--precompilation"); |
| 1451 !has_run_precompiled_snapshot) { | |
| 1452 has_noopt = true; | |
| 1453 vm_options.AddArgument("--precompilation"); | |
| 1454 } | |
| 1455 #endif | 1456 #endif |
| 1456 | 1457 |
| 1457 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 1458 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 1458 | 1459 |
| 1459 // Start event handler. | 1460 // Start event handler. |
| 1460 TimerUtils::InitOnce(); | 1461 TimerUtils::InitOnce(); |
| 1461 EventHandler::Start(); | 1462 EventHandler::Start(); |
| 1462 | 1463 |
| 1463 const uint8_t* instructions_snapshot = NULL; | 1464 const uint8_t* instructions_snapshot = NULL; |
| 1464 if (has_run_precompiled_snapshot) { | 1465 if (has_run_precompiled_snapshot) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 Platform::Exit(Process::GlobalExitCode()); | 1532 Platform::Exit(Process::GlobalExitCode()); |
| 1532 } | 1533 } |
| 1533 | 1534 |
| 1534 } // namespace bin | 1535 } // namespace bin |
| 1535 } // namespace dart | 1536 } // namespace dart |
| 1536 | 1537 |
| 1537 int main(int argc, char** argv) { | 1538 int main(int argc, char** argv) { |
| 1538 dart::bin::main(argc, argv); | 1539 dart::bin::main(argc, argv); |
| 1539 UNREACHABLE(); | 1540 UNREACHABLE(); |
| 1540 } | 1541 } |
| OLD | NEW |