OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
6 // command line. | 6 // command line. |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1259 commandline_packages_file); | 1259 commandline_packages_file); |
1260 CHECK_RESULT(result); | 1260 CHECK_RESULT(result); |
1261 | 1261 |
1262 UriResolverIsolateScope::isolate = isolate; | 1262 UriResolverIsolateScope::isolate = isolate; |
1263 Dart_ExitScope(); | 1263 Dart_ExitScope(); |
1264 Dart_ExitIsolate(); | 1264 Dart_ExitIsolate(); |
1265 | 1265 |
1266 // Now we create an isolate into which we load all the code that needs to | 1266 // Now we create an isolate into which we load all the code that needs to |
1267 // be in the snapshot. | 1267 // be in the snapshot. |
1268 isolate_data = new IsolateData(NULL, NULL, NULL); | 1268 isolate_data = new IsolateData(NULL, NULL, NULL); |
1269 if (Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error) == | 1269 intptr_t payload_bytes = 0; |
1270 NULL) { | 1270 const uint8_t* payload = NULL; |
siva
2016/11/16 05:49:34
Maybe names like kernel_length and kernel would be
Vyacheslav Egorov (Google)
2016/11/16 12:47:46
Done.
| |
1271 const bool is_kernel_file = | |
1272 TryReadKernel(app_script_name, &payload, &payload_bytes); | |
1273 Dart_Isolate isolate = | |
1274 is_kernel_file | |
1275 ? Dart_CreateIsolateFromKernel(NULL, NULL, payload, payload_bytes, | |
1276 NULL, isolate_data, &error) | |
1277 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error); | |
1278 if (isolate == NULL) { | |
1271 fprintf(stderr, "%s", error); | 1279 fprintf(stderr, "%s", error); |
1272 free(error); | 1280 free(error); |
1273 exit(255); | 1281 exit(255); |
1274 } | 1282 } |
1275 Dart_EnterScope(); | 1283 Dart_EnterScope(); |
1276 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | 1284 result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
1277 CHECK_RESULT(result); | 1285 CHECK_RESULT(result); |
1278 | 1286 |
1279 // Set up the library tag handler in such a manner that it will use the | 1287 // Set up the library tag handler in such a manner that it will use the |
1280 // URL mapping specified on the command line to load the libraries. | 1288 // URL mapping specified on the command line to load the libraries. |
1281 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); | 1289 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); |
1282 CHECK_RESULT(result); | 1290 CHECK_RESULT(result); |
1283 | 1291 |
1284 Dart_QualifiedFunctionName* entry_points = | 1292 Dart_QualifiedFunctionName* entry_points = |
1285 ParseEntryPointsManifestIfPresent(); | 1293 ParseEntryPointsManifestIfPresent(); |
1286 | 1294 |
1287 intptr_t payload_bytes = 0; | |
1288 const uint8_t* payload = NULL; | |
1289 const bool is_kernel_file = | |
1290 TryReadKernel(app_script_name, &payload, &payload_bytes); | |
1291 | |
1292 if (is_kernel_file) { | 1295 if (is_kernel_file) { |
1293 Dart_Handle library = Dart_LoadKernel(payload, payload_bytes); | 1296 Dart_Handle library = Dart_LoadKernel(payload, payload_bytes); |
1294 free(const_cast<uint8_t*>(payload)); | 1297 free(const_cast<uint8_t*>(payload)); |
1295 if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR"); | 1298 if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR"); |
1296 } else { | 1299 } else { |
1297 // Set up the library tag handler in such a manner that it will use the | 1300 // Set up the library tag handler in such a manner that it will use the |
1298 // URL mapping specified on the command line to load the libraries. | 1301 // URL mapping specified on the command line to load the libraries. |
1299 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); | 1302 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); |
1300 CHECK_RESULT(result); | 1303 CHECK_RESULT(result); |
1301 } | 1304 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 EventHandler::Stop(); | 1339 EventHandler::Stop(); |
1337 return 0; | 1340 return 0; |
1338 } | 1341 } |
1339 | 1342 |
1340 } // namespace bin | 1343 } // namespace bin |
1341 } // namespace dart | 1344 } // namespace dart |
1342 | 1345 |
1343 int main(int argc, char** argv) { | 1346 int main(int argc, char** argv) { |
1344 return dart::bin::main(argc, argv); | 1347 return dart::bin::main(argc, argv); |
1345 } | 1348 } |
OLD | NEW |