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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 Utils::RoundUp(vmisolate_position + header[1], kAppSnapshotPageSize); | 1227 Utils::RoundUp(vmisolate_position + header[1], kAppSnapshotPageSize); |
1228 int64_t rodata_position = | 1228 int64_t rodata_position = |
1229 Utils::RoundUp(isolate_position + header[2], kAppSnapshotPageSize); | 1229 Utils::RoundUp(isolate_position + header[2], kAppSnapshotPageSize); |
1230 int64_t instructions_position = | 1230 int64_t instructions_position = |
1231 Utils::RoundUp(rodata_position + header[3], kAppSnapshotPageSize); | 1231 Utils::RoundUp(rodata_position + header[3], kAppSnapshotPageSize); |
1232 | 1232 |
1233 void* read_only_buffer = | 1233 void* read_only_buffer = |
1234 file->Map(File::kReadOnly, vmisolate_position, | 1234 file->Map(File::kReadOnly, vmisolate_position, |
1235 instructions_position - vmisolate_position); | 1235 instructions_position - vmisolate_position); |
1236 if (read_only_buffer == NULL) { | 1236 if (read_only_buffer == NULL) { |
1237 ErrorExit(kErrorExitCode, "Failed to memory map snapshot\n"); | 1237 Log::PrintErr("Failed to memory map snapshot\n"); |
| 1238 Platform::Exit(kErrorExitCode); |
1238 } | 1239 } |
1239 | 1240 |
1240 *vmisolate_buffer = reinterpret_cast<const uint8_t*>(read_only_buffer) | 1241 *vmisolate_buffer = reinterpret_cast<const uint8_t*>(read_only_buffer) |
1241 + (vmisolate_position - vmisolate_position); | 1242 + (vmisolate_position - vmisolate_position); |
1242 *isolate_buffer = reinterpret_cast<const uint8_t*>(read_only_buffer) | 1243 *isolate_buffer = reinterpret_cast<const uint8_t*>(read_only_buffer) |
1243 + (isolate_position - vmisolate_position); | 1244 + (isolate_position - vmisolate_position); |
1244 if (header[3] == 0) { | 1245 if (header[3] == 0) { |
1245 *rodata_buffer = NULL; | 1246 *rodata_buffer = NULL; |
1246 } else { | 1247 } else { |
1247 *rodata_buffer = reinterpret_cast<const uint8_t*>(read_only_buffer) | 1248 *rodata_buffer = reinterpret_cast<const uint8_t*>(read_only_buffer) |
1248 + (rodata_position - vmisolate_position); | 1249 + (rodata_position - vmisolate_position); |
1249 } | 1250 } |
1250 | 1251 |
1251 if (header[4] == 0) { | 1252 if (header[4] == 0) { |
1252 *instructions_buffer = NULL; | 1253 *instructions_buffer = NULL; |
1253 } else { | 1254 } else { |
1254 *instructions_buffer = reinterpret_cast<const uint8_t*>( | 1255 *instructions_buffer = reinterpret_cast<const uint8_t*>( |
1255 file->Map(File::kReadExecute, instructions_position, header[4])); | 1256 file->Map(File::kReadExecute, instructions_position, header[4])); |
1256 if (*instructions_buffer == NULL) { | 1257 if (*instructions_buffer == NULL) { |
1257 ErrorExit(kErrorExitCode, "Failed to memory map snapshot2\n"); | 1258 Log::PrintErr("Failed to memory map snapshot\n"); |
| 1259 Platform::Exit(kErrorExitCode); |
1258 } | 1260 } |
1259 } | 1261 } |
1260 | 1262 |
1261 file->Release(); | 1263 file->Release(); |
1262 return true; | 1264 return true; |
1263 } | 1265 } |
1264 | 1266 |
1265 | 1267 |
1266 static bool ReadAppSnapshotDynamicLibrary(const char* script_name, | 1268 static bool ReadAppSnapshotDynamicLibrary(const char* script_name, |
1267 const uint8_t** vmisolate_buffer, | 1269 const uint8_t** vmisolate_buffer, |
1268 const uint8_t** isolate_buffer, | 1270 const uint8_t** isolate_buffer, |
1269 const uint8_t** instructions_buffer, | 1271 const uint8_t** instructions_buffer, |
1270 const uint8_t** rodata_buffer) { | 1272 const uint8_t** rodata_buffer) { |
1271 void* library = Extensions::LoadExtensionLibrary(script_name); | 1273 void* library = Extensions::LoadExtensionLibrary(script_name); |
1272 if (library == NULL) { | 1274 if (library == NULL) { |
1273 return false; | 1275 return false; |
1274 } | 1276 } |
1275 | 1277 |
1276 *vmisolate_buffer = reinterpret_cast<const uint8_t*>( | 1278 *vmisolate_buffer = reinterpret_cast<const uint8_t*>( |
1277 Extensions::ResolveSymbol(library, kPrecompiledVMIsolateSymbolName)); | 1279 Extensions::ResolveSymbol(library, kPrecompiledVMIsolateSymbolName)); |
1278 if (*vmisolate_buffer == NULL) { | 1280 if (*vmisolate_buffer == NULL) { |
1279 ErrorExit(kErrorExitCode, "Failed to resolve symbol '%s'\n", | 1281 Log::PrintErr("Failed to resolve symbol '%s'\n", |
1280 kPrecompiledVMIsolateSymbolName); | 1282 kPrecompiledVMIsolateSymbolName); |
| 1283 Platform::Exit(kErrorExitCode); |
1281 } | 1284 } |
1282 | 1285 |
1283 *isolate_buffer = reinterpret_cast<const uint8_t*>( | 1286 *isolate_buffer = reinterpret_cast<const uint8_t*>( |
1284 Extensions::ResolveSymbol(library, kPrecompiledIsolateSymbolName)); | 1287 Extensions::ResolveSymbol(library, kPrecompiledIsolateSymbolName)); |
1285 if (*isolate_buffer == NULL) { | 1288 if (*isolate_buffer == NULL) { |
1286 ErrorExit(kErrorExitCode, "Failed to resolve symbol '%s'\n", | 1289 Log::PrintErr("Failed to resolve symbol '%s'\n", |
1287 kPrecompiledIsolateSymbolName); | 1290 kPrecompiledIsolateSymbolName); |
| 1291 Platform::Exit(kErrorExitCode); |
1288 } | 1292 } |
1289 | 1293 |
1290 *instructions_buffer = reinterpret_cast<const uint8_t*>( | 1294 *instructions_buffer = reinterpret_cast<const uint8_t*>( |
1291 Extensions::ResolveSymbol(library, kPrecompiledInstructionsSymbolName)); | 1295 Extensions::ResolveSymbol(library, kPrecompiledInstructionsSymbolName)); |
1292 if (*instructions_buffer == NULL) { | 1296 if (*instructions_buffer == NULL) { |
1293 ErrorExit(kErrorExitCode, "Failed to resolve symbol '%s'\n", | 1297 Log::PrintErr("Failed to resolve symbol '%s'\n", |
1294 kPrecompiledInstructionsSymbolName); | 1298 kPrecompiledInstructionsSymbolName); |
| 1299 Platform::Exit(kErrorExitCode); |
1295 } | 1300 } |
1296 | 1301 |
1297 *rodata_buffer = reinterpret_cast<const uint8_t*>( | 1302 *rodata_buffer = reinterpret_cast<const uint8_t*>( |
1298 Extensions::ResolveSymbol(library, kPrecompiledDataSymbolName)); | 1303 Extensions::ResolveSymbol(library, kPrecompiledDataSymbolName)); |
1299 if (*rodata_buffer == NULL) { | 1304 if (*rodata_buffer == NULL) { |
1300 ErrorExit(kErrorExitCode, "Failed to resolve symbol '%s'\n", | 1305 Log::PrintErr("Failed to resolve symbol '%s'\n", |
1301 kPrecompiledDataSymbolName); | 1306 kPrecompiledDataSymbolName); |
| 1307 Platform::Exit(kErrorExitCode); |
1302 } | 1308 } |
1303 | 1309 |
1304 return true; | 1310 return true; |
1305 } | 1311 } |
1306 | 1312 |
1307 | 1313 |
1308 static bool ReadAppSnapshot(const char* script_name, | 1314 static bool ReadAppSnapshot(const char* script_name, |
1309 const uint8_t** vmisolate_buffer, | 1315 const uint8_t** vmisolate_buffer, |
1310 const uint8_t** isolate_buffer, | 1316 const uint8_t** isolate_buffer, |
1311 const uint8_t** instructions_buffer, | 1317 const uint8_t** instructions_buffer, |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 Platform::Exit(Process::GlobalExitCode()); | 1955 Platform::Exit(Process::GlobalExitCode()); |
1950 } | 1956 } |
1951 | 1957 |
1952 } // namespace bin | 1958 } // namespace bin |
1953 } // namespace dart | 1959 } // namespace dart |
1954 | 1960 |
1955 int main(int argc, char** argv) { | 1961 int main(int argc, char** argv) { |
1956 dart::bin::main(argc, argv); | 1962 dart::bin::main(argc, argv); |
1957 UNREACHABLE(); | 1963 UNREACHABLE(); |
1958 } | 1964 } |
OLD | NEW |