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

Side by Side Diff: runtime/bin/main.cc

Issue 1771423002: Qualify the precompiled shared library name with the snapshot directory instead of using LD_LIBRARY… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | tools/precompilation/test_linux.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 fflush(stderr); 1135 fflush(stderr);
1136 Platform::Exit(kErrorExitCode); 1136 Platform::Exit(kErrorExitCode);
1137 } 1137 }
1138 DartUtils::CloseFile(file); 1138 DartUtils::CloseFile(file);
1139 if (concat != NULL) { 1139 if (concat != NULL) {
1140 delete concat; 1140 delete concat;
1141 } 1141 }
1142 } 1142 }
1143 1143
1144 1144
1145 static void* LoadLibrarySymbol(const char* libname, const char* symname) { 1145 static void* LoadLibrarySymbol(const char* snapshot_directory,
1146 void* library = Extensions::LoadExtensionLibrary(libname); 1146 const char* libname,
1147 const char* symname) {
1148 char* concat = NULL;
1149 const char* qualified_libname;
1150 if ((snapshot_directory != NULL) && strlen(snapshot_directory) > 0) {
1151 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, libname);
1152 concat = new char[len + 1];
1153 snprintf(concat, len + 1, "%s/%s", snapshot_directory, libname);
1154 qualified_libname = concat;
1155 } else {
1156 qualified_libname = libname;
1157 }
1158 void* library = Extensions::LoadExtensionLibrary(qualified_libname);
1147 if (library == NULL) { 1159 if (library == NULL) {
1148 Log::PrintErr("Error: Failed to load library '%s'\n", libname); 1160 Log::PrintErr("Error: Failed to load library '%s'\n", qualified_libname);
1149 Platform::Exit(kErrorExitCode); 1161 Platform::Exit(kErrorExitCode);
1150 } 1162 }
1151 void* symbol = Extensions::ResolveSymbol(library, symname); 1163 void* symbol = Extensions::ResolveSymbol(library, symname);
1152 if (symbol == NULL) { 1164 if (symbol == NULL) {
1153 Log::PrintErr("Error: Failed to load symbol '%s'\n", symname); 1165 Log::PrintErr("Error: Failed to load symbol '%s'\n", symname);
1154 Platform::Exit(kErrorExitCode); 1166 Platform::Exit(kErrorExitCode);
1155 } 1167 }
1168 if (concat != NULL) {
1169 delete concat;
1170 }
1156 return symbol; 1171 return symbol;
1157 } 1172 }
1158 1173
1159 1174
1160 static void GenerateScriptSnapshot() { 1175 static void GenerateScriptSnapshot() {
1161 // First create a snapshot. 1176 // First create a snapshot.
1162 uint8_t* buffer = NULL; 1177 uint8_t* buffer = NULL;
1163 intptr_t size = 0; 1178 intptr_t size = 0;
1164 Dart_Handle result = Dart_CreateScriptSnapshot(&buffer, &size); 1179 Dart_Handle result = Dart_CreateScriptSnapshot(&buffer, &size);
1165 if (Dart_IsError(result)) { 1180 if (Dart_IsError(result)) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 1595 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
1581 1596
1582 // Start event handler. 1597 // Start event handler.
1583 TimerUtils::InitOnce(); 1598 TimerUtils::InitOnce();
1584 EventHandler::Start(); 1599 EventHandler::Start();
1585 1600
1586 const uint8_t* instructions_snapshot = NULL; 1601 const uint8_t* instructions_snapshot = NULL;
1587 const uint8_t* data_snapshot = NULL; 1602 const uint8_t* data_snapshot = NULL;
1588 if (run_precompiled_snapshot) { 1603 if (run_precompiled_snapshot) {
1589 instructions_snapshot = reinterpret_cast<const uint8_t*>( 1604 instructions_snapshot = reinterpret_cast<const uint8_t*>(
1590 LoadLibrarySymbol(kPrecompiledLibraryName, 1605 LoadLibrarySymbol(precompiled_snapshot_directory,
1606 kPrecompiledLibraryName,
1591 kPrecompiledInstructionsSymbolName)); 1607 kPrecompiledInstructionsSymbolName));
1592 data_snapshot = reinterpret_cast<const uint8_t*>( 1608 data_snapshot = reinterpret_cast<const uint8_t*>(
1593 LoadLibrarySymbol(kPrecompiledLibraryName, 1609 LoadLibrarySymbol(precompiled_snapshot_directory,
1610 kPrecompiledLibraryName,
1594 kPrecompiledDataSymbolName)); 1611 kPrecompiledDataSymbolName));
1595 ReadSnapshotFile(precompiled_snapshot_directory, 1612 ReadSnapshotFile(precompiled_snapshot_directory,
1596 kPrecompiledVmIsolateName, 1613 kPrecompiledVmIsolateName,
1597 &vm_isolate_snapshot_buffer); 1614 &vm_isolate_snapshot_buffer);
1598 ReadSnapshotFile(precompiled_snapshot_directory, 1615 ReadSnapshotFile(precompiled_snapshot_directory,
1599 kPrecompiledIsolateName, 1616 kPrecompiledIsolateName,
1600 &isolate_snapshot_buffer); 1617 &isolate_snapshot_buffer);
1601 1618
1602 } else if (run_full_snapshot) { 1619 } else if (run_full_snapshot) {
1603 char* vm_snapshot_fname; 1620 char* vm_snapshot_fname;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 Platform::Exit(Process::GlobalExitCode()); 1692 Platform::Exit(Process::GlobalExitCode());
1676 } 1693 }
1677 1694
1678 } // namespace bin 1695 } // namespace bin
1679 } // namespace dart 1696 } // namespace dart
1680 1697
1681 int main(int argc, char** argv) { 1698 int main(int argc, char** argv) {
1682 dart::bin::main(argc, argv); 1699 dart::bin::main(argc, argv);
1683 UNREACHABLE(); 1700 UNREACHABLE();
1684 } 1701 }
OLDNEW
« no previous file with comments | « no previous file | tools/precompilation/test_linux.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698