| 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 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 vm_options.AddArgument("--precompilation"); | 1566 vm_options.AddArgument("--precompilation"); |
| 1566 #endif | 1567 #endif |
| 1567 | 1568 |
| 1568 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 1569 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 1569 | 1570 |
| 1570 // Start event handler. | 1571 // Start event handler. |
| 1571 TimerUtils::InitOnce(); | 1572 TimerUtils::InitOnce(); |
| 1572 EventHandler::Start(); | 1573 EventHandler::Start(); |
| 1573 | 1574 |
| 1574 const uint8_t* instructions_snapshot = NULL; | 1575 const uint8_t* instructions_snapshot = NULL; |
| 1576 const uint8_t* data_snapshot = NULL; |
| 1575 if (run_precompiled_snapshot) { | 1577 if (run_precompiled_snapshot) { |
| 1576 instructions_snapshot = reinterpret_cast<const uint8_t*>( | 1578 instructions_snapshot = reinterpret_cast<const uint8_t*>( |
| 1577 LoadLibrarySymbol(kPrecompiledLibraryName, kPrecompiledSymbolName)); | 1579 LoadLibrarySymbol(kPrecompiledLibraryName, |
| 1580 kPrecompiledInstructionsSymbolName)); |
| 1581 data_snapshot = reinterpret_cast<const uint8_t*>( |
| 1582 LoadLibrarySymbol(kPrecompiledLibraryName, |
| 1583 kPrecompiledDataSymbolName)); |
| 1578 ReadSnapshotFile(precompiled_snapshot_directory, | 1584 ReadSnapshotFile(precompiled_snapshot_directory, |
| 1579 kPrecompiledVmIsolateName, | 1585 kPrecompiledVmIsolateName, |
| 1580 &vm_isolate_snapshot_buffer); | 1586 &vm_isolate_snapshot_buffer); |
| 1581 ReadSnapshotFile(precompiled_snapshot_directory, | 1587 ReadSnapshotFile(precompiled_snapshot_directory, |
| 1582 kPrecompiledIsolateName, | 1588 kPrecompiledIsolateName, |
| 1583 &isolate_snapshot_buffer); | 1589 &isolate_snapshot_buffer); |
| 1590 |
| 1584 } else if (run_full_snapshot) { | 1591 } else if (run_full_snapshot) { |
| 1585 char* vm_snapshot_fname; | 1592 char* vm_snapshot_fname; |
| 1586 char* isolate_snapshot_fname; | 1593 char* isolate_snapshot_fname; |
| 1587 | 1594 |
| 1588 // Compute file names. | 1595 // Compute file names. |
| 1589 ComputeSnapshotFilenames(snapshot_filename, | 1596 ComputeSnapshotFilenames(snapshot_filename, |
| 1590 &vm_snapshot_fname, | 1597 &vm_snapshot_fname, |
| 1591 &isolate_snapshot_fname); | 1598 &isolate_snapshot_fname); |
| 1592 | 1599 |
| 1593 ReadSnapshotFile(NULL, vm_snapshot_fname, &vm_isolate_snapshot_buffer); | 1600 ReadSnapshotFile(NULL, vm_snapshot_fname, &vm_isolate_snapshot_buffer); |
| 1594 ReadSnapshotFile(NULL, isolate_snapshot_fname, &isolate_snapshot_buffer); | 1601 ReadSnapshotFile(NULL, isolate_snapshot_fname, &isolate_snapshot_buffer); |
| 1595 delete vm_snapshot_fname; | 1602 delete vm_snapshot_fname; |
| 1596 delete isolate_snapshot_fname; | 1603 delete isolate_snapshot_fname; |
| 1597 } | 1604 } |
| 1598 | 1605 |
| 1599 // Initialize the Dart VM. | 1606 // Initialize the Dart VM. |
| 1600 char* error = Dart_Initialize( | 1607 char* error = Dart_Initialize( |
| 1601 vm_isolate_snapshot_buffer, instructions_snapshot, | 1608 vm_isolate_snapshot_buffer, instructions_snapshot, data_snapshot, |
| 1602 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, | 1609 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, |
| 1603 DartUtils::OpenFile, | 1610 DartUtils::OpenFile, |
| 1604 DartUtils::ReadFile, | 1611 DartUtils::ReadFile, |
| 1605 DartUtils::WriteFile, | 1612 DartUtils::WriteFile, |
| 1606 DartUtils::CloseFile, | 1613 DartUtils::CloseFile, |
| 1607 DartUtils::EntropySource, | 1614 DartUtils::EntropySource, |
| 1608 GetVMServiceAssetsArchiveCallback); | 1615 GetVMServiceAssetsArchiveCallback); |
| 1609 if (error != NULL) { | 1616 if (error != NULL) { |
| 1610 if (do_vm_shutdown) { | 1617 if (do_vm_shutdown) { |
| 1611 EventHandler::Stop(); | 1618 EventHandler::Stop(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 Platform::Exit(Process::GlobalExitCode()); | 1664 Platform::Exit(Process::GlobalExitCode()); |
| 1658 } | 1665 } |
| 1659 | 1666 |
| 1660 } // namespace bin | 1667 } // namespace bin |
| 1661 } // namespace dart | 1668 } // namespace dart |
| 1662 | 1669 |
| 1663 int main(int argc, char** argv) { | 1670 int main(int argc, char** argv) { |
| 1664 dart::bin::main(argc, argv); | 1671 dart::bin::main(argc, argv); |
| 1665 UNREACHABLE(); | 1672 UNREACHABLE(); |
| 1666 } | 1673 } |
| OLD | NEW |