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 27 matching lines...) Expand all Loading... |
38 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a | 38 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a |
39 // snapshot otherwise it is initialized to NULL. | 39 // snapshot otherwise it is initialized to NULL. |
40 extern const uint8_t* isolate_snapshot_buffer; | 40 extern const uint8_t* isolate_snapshot_buffer; |
41 | 41 |
42 /** | 42 /** |
43 * Global state used to control and store generation of application snapshots | 43 * Global state used to control and store generation of application snapshots |
44 * (script/full). | 44 * (script/full). |
45 * A full application snapshot can be generated and run using the following | 45 * A full application snapshot can be generated and run using the following |
46 * commands | 46 * commands |
47 * - Generating a full application snapshot : | 47 * - Generating a full application snapshot : |
48 * dart_no_snapshot --full-snapshot-after-run=<filename> --package-root=<dirs> | 48 * dart_bootstrap --full-snapshot-after-run=<filename> --package-root=<dirs> |
49 * <script_uri> [<script_options>] | 49 * <script_uri> [<script_options>] |
50 * - Running the full application snapshot generated above : | 50 * - Running the full application snapshot generated above : |
51 * dart --run-full-snapshot=<filename> <script_uri> [<script_options>] | 51 * dart --run-full-snapshot=<filename> <script_uri> [<script_options>] |
52 */ | 52 */ |
53 static bool generate_script_snapshot = false; | 53 static bool generate_script_snapshot = false; |
54 static bool generate_full_snapshot_after_run = false; | 54 static bool generate_full_snapshot_after_run = false; |
55 static bool run_full_snapshot = false; | 55 static bool run_full_snapshot = false; |
56 static const char* snapshot_filename = NULL; | 56 static const char* snapshot_filename = NULL; |
57 | 57 |
58 // Value of the --package-root flag. | 58 // Value of the --package-root flag. |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return false; | 320 return false; |
321 } | 321 } |
322 compile_all = true; | 322 compile_all = true; |
323 return true; | 323 return true; |
324 } | 324 } |
325 | 325 |
326 | 326 |
327 static bool ProcessGenPrecompiledSnapshotOption( | 327 static bool ProcessGenPrecompiledSnapshotOption( |
328 const char* arg, | 328 const char* arg, |
329 CommandLineOptions* vm_options) { | 329 CommandLineOptions* vm_options) { |
330 // Ensure that we are not already running using a full snapshot. | 330 #if !defined(DART_PRECOMPILER) |
331 if (isolate_snapshot_buffer != NULL) { | 331 Log::PrintErr("Precompiled snapshots must be generated with " |
332 Log::PrintErr("Precompiled snapshots must be generated with" | 332 "dart_bootstrap.\n"); |
333 " dart_no_snapshot.\n"); | 333 return false; |
334 return false; | 334 #else // defined(DART_PRECOMPILER) |
335 } | |
336 ASSERT(arg != NULL); | 335 ASSERT(arg != NULL); |
337 if ((arg[0] == '=') || (arg[0] == ':')) { | 336 if ((arg[0] == '=') || (arg[0] == ':')) { |
338 precompiled_snapshot_directory = &arg[1]; | 337 precompiled_snapshot_directory = &arg[1]; |
339 } else { | 338 } else { |
340 precompiled_snapshot_directory = arg; | 339 precompiled_snapshot_directory = arg; |
341 } | 340 } |
342 gen_precompiled_snapshot = true; | 341 gen_precompiled_snapshot = true; |
343 vm_options->AddArgument("--precompilation"); | 342 vm_options->AddArgument("--precompilation"); |
344 return true; | 343 return true; |
| 344 #endif // defined(DART_PRECOMPILER) |
345 } | 345 } |
346 | 346 |
347 | 347 |
348 static bool ProcessRunPrecompiledSnapshotOption( | 348 static bool ProcessRunPrecompiledSnapshotOption( |
349 const char* arg, | 349 const char* arg, |
350 CommandLineOptions* vm_options) { | 350 CommandLineOptions* vm_options) { |
351 ASSERT(arg != NULL); | 351 ASSERT(arg != NULL); |
352 precompiled_snapshot_directory = arg; | 352 precompiled_snapshot_directory = arg; |
353 if ((precompiled_snapshot_directory[0] == '=') || | 353 if ((precompiled_snapshot_directory[0] == '=') || |
354 (precompiled_snapshot_directory[0] == ':')) { | 354 (precompiled_snapshot_directory[0] == ':')) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 388 } |
389 return ProcessSnapshotOptionHelper(filename, &generate_script_snapshot); | 389 return ProcessSnapshotOptionHelper(filename, &generate_script_snapshot); |
390 } | 390 } |
391 | 391 |
392 | 392 |
393 static bool ProcessFullSnapshotAfterRunOption( | 393 static bool ProcessFullSnapshotAfterRunOption( |
394 const char* filename, CommandLineOptions* vm_options) { | 394 const char* filename, CommandLineOptions* vm_options) { |
395 if ((filename == NULL) || (strlen(filename) == 0)) { | 395 if ((filename == NULL) || (strlen(filename) == 0)) { |
396 return false; | 396 return false; |
397 } | 397 } |
398 // Ensure that we are running 'dart_no_snapshot'. | 398 // Ensure that we are running 'dart_bootstrap'. |
399 if (isolate_snapshot_buffer != NULL) { | 399 if (isolate_snapshot_buffer != NULL) { |
400 Log::PrintErr("Full Application snapshots must be generated with" | 400 Log::PrintErr("Full Application snapshots must be generated with" |
401 " dart_no_snapshot\n"); | 401 " dart_bootstrap\n"); |
402 return false; | 402 return false; |
403 } | 403 } |
404 return ProcessSnapshotOptionHelper(filename, | 404 return ProcessSnapshotOptionHelper(filename, |
405 &generate_full_snapshot_after_run); | 405 &generate_full_snapshot_after_run); |
406 } | 406 } |
407 | 407 |
408 | 408 |
409 static bool ProcessRunFullSnapshotOption( | 409 static bool ProcessRunFullSnapshotOption( |
410 const char* filename, CommandLineOptions* vm_options) { | 410 const char* filename, CommandLineOptions* vm_options) { |
411 #ifndef DART_PRODUCT_BINARY | 411 #ifndef DART_PRODUCT_BINARY |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 Dart_ExitScope(); | 1414 Dart_ExitScope(); |
1415 // Shutdown the isolate. | 1415 // Shutdown the isolate. |
1416 Dart_ShutdownIsolate(); | 1416 Dart_ShutdownIsolate(); |
1417 | 1417 |
1418 // No restart. | 1418 // No restart. |
1419 return false; | 1419 return false; |
1420 } | 1420 } |
1421 | 1421 |
1422 #undef CHECK_RESULT | 1422 #undef CHECK_RESULT |
1423 | 1423 |
| 1424 |
| 1425 // Observatory assets are only needed in the regular dart binary. |
| 1426 #if !defined(DART_PRECOMPILER) |
1424 extern unsigned int observatory_assets_archive_len; | 1427 extern unsigned int observatory_assets_archive_len; |
1425 extern const uint8_t* observatory_assets_archive; | 1428 extern const uint8_t* observatory_assets_archive; |
1426 | 1429 |
1427 | 1430 |
1428 // |input| is assumed to be a gzipped stream. | 1431 // |input| is assumed to be a gzipped stream. |
1429 // This function allocates the output buffer in the C heap and the caller | 1432 // This function allocates the output buffer in the C heap and the caller |
1430 // is responsible for freeing it. | 1433 // is responsible for freeing it. |
1431 void Decompress(const uint8_t* input, unsigned int input_len, | 1434 void Decompress(const uint8_t* input, unsigned int input_len, |
1432 uint8_t** output, unsigned int* output_length) { | 1435 uint8_t** output, unsigned int* output_length) { |
1433 ASSERT(input != NULL); | 1436 ASSERT(input != NULL); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 Decompress(observatory_assets_archive, | 1498 Decompress(observatory_assets_archive, |
1496 observatory_assets_archive_len, | 1499 observatory_assets_archive_len, |
1497 &decompressed, | 1500 &decompressed, |
1498 &decompressed_len); | 1501 &decompressed_len); |
1499 Dart_Handle tar_file = DartUtils::MakeUint8Array(decompressed, | 1502 Dart_Handle tar_file = DartUtils::MakeUint8Array(decompressed, |
1500 decompressed_len); | 1503 decompressed_len); |
1501 // Free decompressed memory as it has been copied into a Dart array. | 1504 // Free decompressed memory as it has been copied into a Dart array. |
1502 free(decompressed); | 1505 free(decompressed); |
1503 return tar_file; | 1506 return tar_file; |
1504 } | 1507 } |
| 1508 #else // !defined(DART_PRECOMPILER) |
| 1509 static Dart_GetVMServiceAssetsArchive GetVMServiceAssetsArchiveCallback = NULL; |
| 1510 #endif // !defined(DART_PRECOMPILER) |
1505 | 1511 |
1506 | 1512 |
1507 void main(int argc, char** argv) { | 1513 void main(int argc, char** argv) { |
1508 char* script_name; | 1514 char* script_name; |
1509 const int EXTRA_VM_ARGUMENTS = 2; | 1515 const int EXTRA_VM_ARGUMENTS = 2; |
1510 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS); | 1516 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS); |
1511 CommandLineOptions dart_options(argc); | 1517 CommandLineOptions dart_options(argc); |
1512 bool print_flags_seen = false; | 1518 bool print_flags_seen = false; |
1513 bool verbose_debug_seen = false; | 1519 bool verbose_debug_seen = false; |
1514 | 1520 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 Platform::Exit(Process::GlobalExitCode()); | 1675 Platform::Exit(Process::GlobalExitCode()); |
1670 } | 1676 } |
1671 | 1677 |
1672 } // namespace bin | 1678 } // namespace bin |
1673 } // namespace dart | 1679 } // namespace dart |
1674 | 1680 |
1675 int main(int argc, char** argv) { | 1681 int main(int argc, char** argv) { |
1676 dart::bin::main(argc, argv); | 1682 dart::bin::main(argc, argv); |
1677 UNREACHABLE(); | 1683 UNREACHABLE(); |
1678 } | 1684 } |
OLD | NEW |