| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // same process. | 92 // same process. |
| 93 // Always set this with dart_noopt. | 93 // Always set this with dart_noopt. |
| 94 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT) | 94 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT) |
| 95 static const bool is_noopt = true; | 95 static const bool is_noopt = true; |
| 96 #else | 96 #else |
| 97 static const bool is_noopt = false; | 97 static const bool is_noopt = false; |
| 98 #endif | 98 #endif |
| 99 | 99 |
| 100 | 100 |
| 101 extern const char* kPrecompiledLibraryName; | 101 extern const char* kPrecompiledLibraryName; |
| 102 extern const char* kPrecompiledSymbolName; | 102 extern const char* kPrecompiledInstructionsSymbolName; |
| 103 extern const char* kPrecompiledDataSymbolName; |
| 103 static const char* kPrecompiledVmIsolateName = "precompiled.vmisolate"; | 104 static const char* kPrecompiledVmIsolateName = "precompiled.vmisolate"; |
| 104 static const char* kPrecompiledIsolateName = "precompiled.isolate"; | 105 static const char* kPrecompiledIsolateName = "precompiled.isolate"; |
| 105 static const char* kPrecompiledInstructionsName = "precompiled.S"; | 106 static const char* kPrecompiledInstructionsName = "precompiled.S"; |
| 106 static const char* kVMIsolateSuffix = "vmisolate"; | 107 static const char* kVMIsolateSuffix = "vmisolate"; |
| 107 static const char* kIsolateSuffix = "isolate"; | 108 static const char* kIsolateSuffix = "isolate"; |
| 108 | 109 |
| 109 // Global flag that is used to indicate that we want to trace resolution of | 110 // Global flag that is used to indicate that we want to trace resolution of |
| 110 // URIs and the loading of libraries, parts and scripts. | 111 // URIs and the loading of libraries, parts and scripts. |
| 111 static bool trace_loading = false; | 112 static bool trace_loading = false; |
| 112 | 113 |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 vm_options.AddArgument("--precompilation"); | 1547 vm_options.AddArgument("--precompilation"); |
| 1547 #endif | 1548 #endif |
| 1548 | 1549 |
| 1549 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 1550 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 1550 | 1551 |
| 1551 // Start event handler. | 1552 // Start event handler. |
| 1552 TimerUtils::InitOnce(); | 1553 TimerUtils::InitOnce(); |
| 1553 EventHandler::Start(); | 1554 EventHandler::Start(); |
| 1554 | 1555 |
| 1555 const uint8_t* instructions_snapshot = NULL; | 1556 const uint8_t* instructions_snapshot = NULL; |
| 1557 const uint8_t* data_snapshot = NULL; |
| 1556 if (run_precompiled_snapshot) { | 1558 if (run_precompiled_snapshot) { |
| 1557 instructions_snapshot = reinterpret_cast<const uint8_t*>( | 1559 instructions_snapshot = reinterpret_cast<const uint8_t*>( |
| 1558 LoadLibrarySymbol(kPrecompiledLibraryName, kPrecompiledSymbolName)); | 1560 LoadLibrarySymbol(kPrecompiledLibraryName, |
| 1561 kPrecompiledInstructionsSymbolName)); |
| 1562 data_snapshot = reinterpret_cast<const uint8_t*>( |
| 1563 LoadLibrarySymbol(kPrecompiledLibraryName, |
| 1564 kPrecompiledDataSymbolName)); |
| 1559 ReadSnapshotFile(precompiled_snapshot_directory, | 1565 ReadSnapshotFile(precompiled_snapshot_directory, |
| 1560 kPrecompiledVmIsolateName, | 1566 kPrecompiledVmIsolateName, |
| 1561 &vm_isolate_snapshot_buffer); | 1567 &vm_isolate_snapshot_buffer); |
| 1562 ReadSnapshotFile(precompiled_snapshot_directory, | 1568 ReadSnapshotFile(precompiled_snapshot_directory, |
| 1563 kPrecompiledIsolateName, | 1569 kPrecompiledIsolateName, |
| 1564 &isolate_snapshot_buffer); | 1570 &isolate_snapshot_buffer); |
| 1571 |
| 1565 } else if (run_full_snapshot) { | 1572 } else if (run_full_snapshot) { |
| 1566 char* vm_snapshot_fname; | 1573 char* vm_snapshot_fname; |
| 1567 char* isolate_snapshot_fname; | 1574 char* isolate_snapshot_fname; |
| 1568 | 1575 |
| 1569 // Compute file names. | 1576 // Compute file names. |
| 1570 ComputeSnapshotFilenames(snapshot_filename, | 1577 ComputeSnapshotFilenames(snapshot_filename, |
| 1571 &vm_snapshot_fname, | 1578 &vm_snapshot_fname, |
| 1572 &isolate_snapshot_fname); | 1579 &isolate_snapshot_fname); |
| 1573 | 1580 |
| 1574 ReadSnapshotFile(NULL, vm_snapshot_fname, &vm_isolate_snapshot_buffer); | 1581 ReadSnapshotFile(NULL, vm_snapshot_fname, &vm_isolate_snapshot_buffer); |
| 1575 ReadSnapshotFile(NULL, isolate_snapshot_fname, &isolate_snapshot_buffer); | 1582 ReadSnapshotFile(NULL, isolate_snapshot_fname, &isolate_snapshot_buffer); |
| 1576 delete vm_snapshot_fname; | 1583 delete vm_snapshot_fname; |
| 1577 delete isolate_snapshot_fname; | 1584 delete isolate_snapshot_fname; |
| 1578 } | 1585 } |
| 1579 | 1586 |
| 1580 // Initialize the Dart VM. | 1587 // Initialize the Dart VM. |
| 1581 char* error = Dart_Initialize( | 1588 char* error = Dart_Initialize( |
| 1582 vm_isolate_snapshot_buffer, instructions_snapshot, | 1589 vm_isolate_snapshot_buffer, instructions_snapshot, data_snapshot, |
| 1583 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, | 1590 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, |
| 1584 DartUtils::OpenFile, | 1591 DartUtils::OpenFile, |
| 1585 DartUtils::ReadFile, | 1592 DartUtils::ReadFile, |
| 1586 DartUtils::WriteFile, | 1593 DartUtils::WriteFile, |
| 1587 DartUtils::CloseFile, | 1594 DartUtils::CloseFile, |
| 1588 DartUtils::EntropySource, | 1595 DartUtils::EntropySource, |
| 1589 GetVMServiceAssetsArchiveCallback); | 1596 GetVMServiceAssetsArchiveCallback); |
| 1590 if (error != NULL) { | 1597 if (error != NULL) { |
| 1591 if (do_vm_shutdown) { | 1598 if (do_vm_shutdown) { |
| 1592 EventHandler::Stop(); | 1599 EventHandler::Stop(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 Platform::Exit(Process::GlobalExitCode()); | 1645 Platform::Exit(Process::GlobalExitCode()); |
| 1639 } | 1646 } |
| 1640 | 1647 |
| 1641 } // namespace bin | 1648 } // namespace bin |
| 1642 } // namespace dart | 1649 } // namespace dart |
| 1643 | 1650 |
| 1644 int main(int argc, char** argv) { | 1651 int main(int argc, char** argv) { |
| 1645 dart::bin::main(argc, argv); | 1652 dart::bin::main(argc, argv); |
| 1646 UNREACHABLE(); | 1653 UNREACHABLE(); |
| 1647 } | 1654 } |
| OLD | NEW |