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

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

Issue 2525623002: VM: [Kernel] Split kernel API into 3 steps: ([read binary], parse-binary, bootstrap, load program) (Closed)
Patch Set: addressed comments Created 4 years 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 | runtime/bin/loader.cc » ('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) 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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 Dart_ExitScope(); 1289 Dart_ExitScope();
1290 Dart_ExitIsolate(); 1290 Dart_ExitIsolate();
1291 1291
1292 // Now we create an isolate into which we load all the code that needs to 1292 // Now we create an isolate into which we load all the code that needs to
1293 // be in the snapshot. 1293 // be in the snapshot.
1294 isolate_data = new IsolateData(NULL, NULL, NULL); 1294 isolate_data = new IsolateData(NULL, NULL, NULL);
1295 const uint8_t* kernel = NULL; 1295 const uint8_t* kernel = NULL;
1296 intptr_t kernel_length = 0; 1296 intptr_t kernel_length = 0;
1297 const bool is_kernel_file = 1297 const bool is_kernel_file =
1298 TryReadKernel(app_script_name, &kernel, &kernel_length); 1298 TryReadKernel(app_script_name, &kernel, &kernel_length);
1299
1300 void* kernel_program = NULL;
1301 if (is_kernel_file) {
1302 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length);
1303 free(const_cast<uint8_t*>(kernel));
1304 }
1305
1299 Dart_Isolate isolate = 1306 Dart_Isolate isolate =
1300 is_kernel_file 1307 is_kernel_file
1301 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel, kernel_length, 1308 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel_program, NULL,
1302 NULL, isolate_data, &error) 1309 isolate_data, &error)
1303 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error); 1310 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error);
1304 if (isolate == NULL) { 1311 if (isolate == NULL) {
1305 Log::PrintErr("%s", error); 1312 Log::PrintErr("%s", error);
1306 free(error); 1313 free(error);
1307 exit(kErrorExitCode); 1314 exit(kErrorExitCode);
1308 } 1315 }
1309 Dart_EnterScope(); 1316 Dart_EnterScope();
1310 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 1317 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
1311 CHECK_RESULT(result); 1318 CHECK_RESULT(result);
1312 1319
1313 // Set up the library tag handler in such a manner that it will use the 1320 // Set up the library tag handler in such a manner that it will use the
1314 // URL mapping specified on the command line to load the libraries. 1321 // URL mapping specified on the command line to load the libraries.
1315 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); 1322 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler);
1316 CHECK_RESULT(result); 1323 CHECK_RESULT(result);
1317 1324
1318 Dart_QualifiedFunctionName* entry_points = 1325 Dart_QualifiedFunctionName* entry_points =
1319 ParseEntryPointsManifestIfPresent(); 1326 ParseEntryPointsManifestIfPresent();
1320 1327
1321 if (is_kernel_file) { 1328 if (is_kernel_file) {
1322 Dart_Handle library = Dart_LoadKernel(kernel, kernel_length); 1329 Dart_Handle library = Dart_LoadKernel(kernel_program);
1323 free(const_cast<uint8_t*>(kernel));
1324 if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR"); 1330 if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR");
1325 } else { 1331 } else {
1326 // Set up the library tag handler in such a manner that it will use the 1332 // Set up the library tag handler in such a manner that it will use the
1327 // URL mapping specified on the command line to load the libraries. 1333 // URL mapping specified on the command line to load the libraries.
1328 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); 1334 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler);
1329 CHECK_RESULT(result); 1335 CHECK_RESULT(result);
1330 } 1336 }
1331 1337
1332 SetupStubNativeResolversForPrecompilation(entry_points); 1338 SetupStubNativeResolversForPrecompilation(entry_points);
1333 1339
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 EventHandler::Stop(); 1373 EventHandler::Stop();
1368 return 0; 1374 return 0;
1369 } 1375 }
1370 1376
1371 } // namespace bin 1377 } // namespace bin
1372 } // namespace dart 1378 } // namespace dart
1373 1379
1374 int main(int argc, char** argv) { 1380 int main(int argc, char** argv) {
1375 return dart::bin::main(argc, argv); 1381 return dart::bin::main(argc, argv);
1376 } 1382 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698