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

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

Issue 2902313004: CoreJIT snapshots without training. (Closed)
Patch Set: . Created 3 years, 6 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } \ 54 } \
55 Dart_ExitScope(); \ 55 Dart_ExitScope(); \
56 Dart_ShutdownIsolate(); \ 56 Dart_ShutdownIsolate(); \
57 exit(exit_code); \ 57 exit(exit_code); \
58 } 58 }
59 59
60 60
61 // The core snapshot to use when creating isolates. Normally NULL, but loaded 61 // The core snapshot to use when creating isolates. Normally NULL, but loaded
62 // from a file when creating script snapshots. 62 // from a file when creating script snapshots.
63 const uint8_t* isolate_snapshot_data = NULL; 63 const uint8_t* isolate_snapshot_data = NULL;
64 const uint8_t* isolate_snapshot_instructions = NULL;
64 65
65 66
66 // Global state that indicates whether a snapshot is to be created and 67 // Global state that indicates whether a snapshot is to be created and
67 // if so which file to write the snapshot into. 68 // if so which file to write the snapshot into.
68 enum SnapshotKind { 69 enum SnapshotKind {
69 kCore, 70 kCore,
71 kCoreJIT,
70 kScript, 72 kScript,
71 kAppAOTBlobs, 73 kAppAOTBlobs,
72 kAppAOTAssembly, 74 kAppAOTAssembly,
73 }; 75 };
74 static SnapshotKind snapshot_kind = kCore; 76 static SnapshotKind snapshot_kind = kCore;
75 static const char* vm_snapshot_data_filename = NULL; 77 static const char* vm_snapshot_data_filename = NULL;
76 static const char* vm_snapshot_instructions_filename = NULL; 78 static const char* vm_snapshot_instructions_filename = NULL;
77 static const char* isolate_snapshot_data_filename = NULL; 79 static const char* isolate_snapshot_data_filename = NULL;
78 static const char* isolate_snapshot_instructions_filename = NULL; 80 static const char* isolate_snapshot_instructions_filename = NULL;
79 static const char* assembly_filename = NULL; 81 static const char* assembly_filename = NULL;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 208
207 209
208 static bool ProcessSnapshotKindOption(const char* option) { 210 static bool ProcessSnapshotKindOption(const char* option) {
209 const char* kind = ProcessOption(option, "--snapshot_kind="); 211 const char* kind = ProcessOption(option, "--snapshot_kind=");
210 if (kind == NULL) { 212 if (kind == NULL) {
211 kind = ProcessOption(option, "--snapshot-kind="); 213 kind = ProcessOption(option, "--snapshot-kind=");
212 } 214 }
213 if (kind == NULL) { 215 if (kind == NULL) {
214 return false; 216 return false;
215 } 217 }
216 if (strcmp(kind, "core") == 0) { 218 if (strcmp(kind, "core-jit") == 0) {
219 snapshot_kind = kCoreJIT;
220 return true;
221 } else if (strcmp(kind, "core") == 0) {
217 snapshot_kind = kCore; 222 snapshot_kind = kCore;
218 return true; 223 return true;
219 } else if (strcmp(kind, "script") == 0) { 224 } else if (strcmp(kind, "script") == 0) {
220 snapshot_kind = kScript; 225 snapshot_kind = kScript;
221 return true; 226 return true;
222 } else if (strcmp(kind, "app-aot-blobs") == 0) { 227 } else if (strcmp(kind, "app-aot-blobs") == 0) {
223 snapshot_kind = kAppAOTBlobs; 228 snapshot_kind = kAppAOTBlobs;
224 return true; 229 return true;
225 } else if (strcmp(kind, "app-aot-assembly") == 0) { 230 } else if (strcmp(kind, "app-aot-assembly") == 0) {
226 snapshot_kind = kAppAOTAssembly; 231 snapshot_kind = kAppAOTAssembly;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 case kCore: { 454 case kCore: {
450 if ((vm_snapshot_data_filename == NULL) || 455 if ((vm_snapshot_data_filename == NULL) ||
451 (isolate_snapshot_data_filename == NULL)) { 456 (isolate_snapshot_data_filename == NULL)) {
452 Log::PrintErr( 457 Log::PrintErr(
453 "Building a core snapshot requires specifying output files for " 458 "Building a core snapshot requires specifying output files for "
454 "--vm_snapshot_data and --isolate_snapshot_data.\n\n"); 459 "--vm_snapshot_data and --isolate_snapshot_data.\n\n");
455 return -1; 460 return -1;
456 } 461 }
457 break; 462 break;
458 } 463 }
464 case kCoreJIT: {
465 if ((vm_snapshot_data_filename == NULL) ||
466 (vm_snapshot_instructions_filename == NULL) ||
467 (isolate_snapshot_data_filename == NULL) ||
468 (isolate_snapshot_instructions_filename == NULL)) {
469 Log::PrintErr(
470 "Building a core JIT snapshot requires specifying output "
471 "files for --vm_snapshot_data, --vm_snapshot_instructions, "
472 "--isolate_snapshot_data and --isolate_snapshot_instructions.\n\n");
473 return -1;
474 }
475 break;
476 }
459 case kScript: { 477 case kScript: {
460 if ((vm_snapshot_data_filename == NULL) || 478 if ((vm_snapshot_data_filename == NULL) ||
461 (isolate_snapshot_data_filename == NULL) || 479 (isolate_snapshot_data_filename == NULL) ||
462 (script_snapshot_filename == NULL) || (*script_name == NULL)) { 480 (script_snapshot_filename == NULL) || (*script_name == NULL)) {
463 Log::PrintErr( 481 Log::PrintErr(
464 "Building a script snapshot requires specifying input files for " 482 "Building a script snapshot requires specifying input files for "
465 "--vm_snapshot_data and --isolate_snapshot_data, an output file " 483 "--vm_snapshot_data and --isolate_snapshot_data, an output file "
466 "for --script_snapshot, and a Dart script.\n\n"); 484 "for --script_snapshot, and a Dart script.\n\n");
467 return -1; 485 return -1;
468 } 486 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 case kCore: 704 case kCore:
687 success &= file->Print("%s ", vm_snapshot_data_filename); 705 success &= file->Print("%s ", vm_snapshot_data_filename);
688 success &= file->Print("%s ", isolate_snapshot_data_filename); 706 success &= file->Print("%s ", isolate_snapshot_data_filename);
689 break; 707 break;
690 case kScript: 708 case kScript:
691 success &= file->Print("%s ", script_snapshot_filename); 709 success &= file->Print("%s ", script_snapshot_filename);
692 break; 710 break;
693 case kAppAOTAssembly: 711 case kAppAOTAssembly:
694 success &= file->Print("%s ", assembly_filename); 712 success &= file->Print("%s ", assembly_filename);
695 break; 713 break;
714 case kCoreJIT:
696 case kAppAOTBlobs: 715 case kAppAOTBlobs:
697 success &= file->Print("%s ", vm_snapshot_data_filename); 716 success &= file->Print("%s ", vm_snapshot_data_filename);
698 success &= file->Print("%s ", vm_snapshot_instructions_filename); 717 success &= file->Print("%s ", vm_snapshot_instructions_filename);
699 success &= file->Print("%s ", isolate_snapshot_data_filename); 718 success &= file->Print("%s ", isolate_snapshot_data_filename);
700 success &= file->Print("%s ", isolate_snapshot_instructions_filename); 719 success &= file->Print("%s ", isolate_snapshot_instructions_filename);
701 break; 720 break;
702 } 721 }
703 722
704 success &= file->Print(": "); 723 success &= file->Print(": ");
705 } 724 }
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 // First create a snapshot. 1287 // First create a snapshot.
1269 result = Dart_CreateSnapshot(&vm_snapshot_data_buffer, &vm_snapshot_data_size, 1288 result = Dart_CreateSnapshot(&vm_snapshot_data_buffer, &vm_snapshot_data_size,
1270 &isolate_snapshot_data_buffer, 1289 &isolate_snapshot_data_buffer,
1271 &isolate_snapshot_data_size); 1290 &isolate_snapshot_data_size);
1272 CHECK_RESULT(result); 1291 CHECK_RESULT(result);
1273 1292
1274 // Now write the vm isolate and isolate snapshots out to the 1293 // Now write the vm isolate and isolate snapshots out to the
1275 // specified file and exit. 1294 // specified file and exit.
1276 WriteSnapshotFile(vm_snapshot_data_filename, vm_snapshot_data_buffer, 1295 WriteSnapshotFile(vm_snapshot_data_filename, vm_snapshot_data_buffer,
1277 vm_snapshot_data_size); 1296 vm_snapshot_data_size);
1297 if (vm_snapshot_instructions_filename != NULL) {
1298 WriteSnapshotFile(vm_snapshot_instructions_filename, NULL, 0);
1299 }
1278 WriteSnapshotFile(isolate_snapshot_data_filename, 1300 WriteSnapshotFile(isolate_snapshot_data_filename,
1279 isolate_snapshot_data_buffer, isolate_snapshot_data_size); 1301 isolate_snapshot_data_buffer, isolate_snapshot_data_size);
1302 if (isolate_snapshot_instructions_filename != NULL) {
1303 WriteSnapshotFile(isolate_snapshot_instructions_filename, NULL, 0);
1304 }
1280 } 1305 }
1281 1306
1282 1307
1308 static void CreateAndWriteCoreJITSnapshot() {
1309 ASSERT(snapshot_kind == kCoreJIT);
1310 ASSERT(vm_snapshot_data_filename != NULL);
1311 ASSERT(vm_snapshot_instructions_filename != NULL);
1312 ASSERT(isolate_snapshot_data_filename != NULL);
1313 ASSERT(isolate_snapshot_instructions_filename != NULL);
1314
1315 Dart_Handle result;
1316 uint8_t* vm_snapshot_data_buffer = NULL;
1317 intptr_t vm_snapshot_data_size = 0;
1318 uint8_t* vm_snapshot_instructions_buffer = NULL;
1319 intptr_t vm_snapshot_instructions_size = 0;
1320 uint8_t* isolate_snapshot_data_buffer = NULL;
1321 intptr_t isolate_snapshot_data_size = 0;
1322 uint8_t* isolate_snapshot_instructions_buffer = NULL;
1323 intptr_t isolate_snapshot_instructions_size = 0;
1324
1325 // First create a snapshot.
1326 result = Dart_CreateCoreJITSnapshotAsBlobs(
1327 &vm_snapshot_data_buffer, &vm_snapshot_data_size,
1328 &vm_snapshot_instructions_buffer, &vm_snapshot_instructions_size,
1329 &isolate_snapshot_data_buffer, &isolate_snapshot_data_size,
1330 &isolate_snapshot_instructions_buffer,
1331 &isolate_snapshot_instructions_size);
1332 CHECK_RESULT(result);
1333
1334 // Now write the vm isolate and isolate snapshots out to the
1335 // specified file and exit.
1336 WriteSnapshotFile(vm_snapshot_data_filename, vm_snapshot_data_buffer,
1337 vm_snapshot_data_size);
1338 WriteSnapshotFile(vm_snapshot_instructions_filename,
1339 vm_snapshot_instructions_buffer,
1340 vm_snapshot_instructions_size);
1341 WriteSnapshotFile(isolate_snapshot_data_filename,
1342 isolate_snapshot_data_buffer, isolate_snapshot_data_size);
1343 WriteSnapshotFile(isolate_snapshot_instructions_filename,
1344 isolate_snapshot_instructions_buffer,
1345 isolate_snapshot_instructions_size);
1346 }
1347
1348
1283 static void CreateAndWriteScriptSnapshot() { 1349 static void CreateAndWriteScriptSnapshot() {
1284 ASSERT(snapshot_kind == kScript); 1350 ASSERT(snapshot_kind == kScript);
1285 ASSERT(script_snapshot_filename != NULL); 1351 ASSERT(script_snapshot_filename != NULL);
1286 1352
1287 // First create a snapshot. 1353 // First create a snapshot.
1288 uint8_t* buffer = NULL; 1354 uint8_t* buffer = NULL;
1289 intptr_t size = 0; 1355 intptr_t size = 0;
1290 Dart_Handle result = Dart_CreateScriptSnapshot(&buffer, &size); 1356 Dart_Handle result = Dart_CreateScriptSnapshot(&buffer, &size);
1291 CHECK_RESULT(result); 1357 CHECK_RESULT(result);
1292 1358
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 static Dart_Isolate CreateServiceIsolate(const char* script_uri, 1450 static Dart_Isolate CreateServiceIsolate(const char* script_uri,
1385 const char* main, 1451 const char* main,
1386 const char* package_root, 1452 const char* package_root,
1387 const char* package_config, 1453 const char* package_config,
1388 Dart_IsolateFlags* flags, 1454 Dart_IsolateFlags* flags,
1389 void* data, 1455 void* data,
1390 char** error) { 1456 char** error) {
1391 IsolateData* isolate_data = 1457 IsolateData* isolate_data =
1392 new IsolateData(script_uri, package_root, package_config, NULL); 1458 new IsolateData(script_uri, package_root, package_config, NULL);
1393 Dart_Isolate isolate = NULL; 1459 Dart_Isolate isolate = NULL;
1394 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, NULL, 1460 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data,
1395 NULL, isolate_data, error); 1461 isolate_snapshot_instructions, NULL,
1462 isolate_data, error);
1396 1463
1397 if (isolate == NULL) { 1464 if (isolate == NULL) {
1398 Log::PrintErr("Error: Could not create service isolate\n"); 1465 Log::PrintErr("Error: Could not create service isolate\n");
1399 return NULL; 1466 return NULL;
1400 } 1467 }
1401 1468
1402 Dart_EnterScope(); 1469 Dart_EnterScope();
1403 if (!Dart_IsServiceIsolate(isolate)) { 1470 if (!Dart_IsServiceIsolate(isolate)) {
1404 Log::PrintErr("Error: We only expect to create the service isolate\n"); 1471 Log::PrintErr("Error: We only expect to create the service isolate\n");
1405 return NULL; 1472 return NULL;
(...skipping 14 matching lines...) Expand all
1420 false /* trace_loading */)) { 1487 false /* trace_loading */)) {
1421 *error = strdup(VmService::GetErrorMessage()); 1488 *error = strdup(VmService::GetErrorMessage());
1422 return NULL; 1489 return NULL;
1423 } 1490 }
1424 Dart_ExitScope(); 1491 Dart_ExitScope();
1425 Dart_ExitIsolate(); 1492 Dart_ExitIsolate();
1426 return isolate; 1493 return isolate;
1427 } 1494 }
1428 1495
1429 1496
1497 static MappedMemory* MapFile(const char* filename, File::MapType type) {
1498 File* file = File::Open(filename, File::kRead);
1499 if (file == NULL) {
1500 Log::PrintErr("Failed to open: %s\n", filename);
1501 exit(kErrorExitCode);
1502 }
1503 MappedMemory* mapping = file->Map(type, 0, file->Length());
1504 if (mapping == NULL) {
1505 Log::PrintErr("Failed to read: %s\n", vm_snapshot_data_filename);
1506 exit(kErrorExitCode);
1507 }
1508 file->Release();
1509 return mapping;
1510 }
1511
1512
1430 int main(int argc, char** argv) { 1513 int main(int argc, char** argv) {
1431 const int EXTRA_VM_ARGUMENTS = 2; 1514 const int EXTRA_VM_ARGUMENTS = 2;
1432 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS); 1515 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
1433 1516
1434 // Initialize the URL mapping array. 1517 // Initialize the URL mapping array.
1435 CommandLineOptions cmdline_url_mapping(argc); 1518 CommandLineOptions cmdline_url_mapping(argc);
1436 DartUtils::url_mapping = &cmdline_url_mapping; 1519 DartUtils::url_mapping = &cmdline_url_mapping;
1437 1520
1438 // Initialize the entrypoints array. 1521 // Initialize the entrypoints array.
1439 CommandLineOptions entry_points_files_array(argc); 1522 CommandLineOptions entry_points_files_array(argc);
(...skipping 13 matching lines...) Expand all
1453 EventHandler::Start(); 1536 EventHandler::Start();
1454 1537
1455 #if !defined(PRODUCT) 1538 #if !defined(PRODUCT)
1456 // Constant true in PRODUCT mode. 1539 // Constant true in PRODUCT mode.
1457 vm_options.AddArgument("--load_deferred_eagerly"); 1540 vm_options.AddArgument("--load_deferred_eagerly");
1458 #endif 1541 #endif
1459 1542
1460 if (IsSnapshottingForPrecompilation()) { 1543 if (IsSnapshottingForPrecompilation()) {
1461 vm_options.AddArgument("--precompilation"); 1544 vm_options.AddArgument("--precompilation");
1462 } 1545 }
1546 if (snapshot_kind == kCoreJIT) {
1547 vm_options.AddArgument("--fields_may_be_reset");
1548 vm_options.AddArgument("--link_natives_lazily");
1549 #if !defined(PRODUCT)
1550 vm_options.AddArgument("--collect_code=false");
1551 #endif
1552 }
1463 1553
1464 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 1554 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
1465 1555
1466 // Initialize the Dart VM. 1556 // Initialize the Dart VM.
1467 // Note: We don't expect isolates to be created from dart code during 1557 // Note: We don't expect isolates to be created from dart code during
1468 // core library snapshot generation. However for the case when a full 1558 // core library snapshot generation. However for the case when a full
1469 // snasphot is generated from a script (app_script_name != NULL) we will 1559 // snasphot is generated from a script (app_script_name != NULL) we will
1470 // need the service isolate to resolve URI and load code. 1560 // need the service isolate to resolve URI and load code.
1471 1561
1472 Dart_InitializeParams init_params; 1562 Dart_InitializeParams init_params;
1473 memset(&init_params, 0, sizeof(init_params)); 1563 memset(&init_params, 0, sizeof(init_params));
1474 init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION; 1564 init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION;
1475 if (app_script_name != NULL) { 1565 if (app_script_name != NULL) {
1476 init_params.create = CreateServiceIsolate; 1566 init_params.create = CreateServiceIsolate;
1477 } 1567 }
1478 init_params.file_open = DartUtils::OpenFile; 1568 init_params.file_open = DartUtils::OpenFile;
1479 init_params.file_read = DartUtils::ReadFile; 1569 init_params.file_read = DartUtils::ReadFile;
1480 init_params.file_write = DartUtils::WriteFile; 1570 init_params.file_write = DartUtils::WriteFile;
1481 init_params.file_close = DartUtils::CloseFile; 1571 init_params.file_close = DartUtils::CloseFile;
1482 init_params.entropy_source = DartUtils::EntropySource; 1572 init_params.entropy_source = DartUtils::EntropySource;
1483 1573
1484 MappedMemory* mapped_vm_snapshot_data = NULL; 1574 MappedMemory* mapped_vm_snapshot_data = NULL;
1575 MappedMemory* mapped_vm_snapshot_instructions = NULL;
1485 MappedMemory* mapped_isolate_snapshot_data = NULL; 1576 MappedMemory* mapped_isolate_snapshot_data = NULL;
1577 MappedMemory* mapped_isolate_snapshot_instructions = NULL;
1486 if (snapshot_kind == kScript) { 1578 if (snapshot_kind == kScript) {
1487 File* file = File::Open(vm_snapshot_data_filename, File::kRead); 1579 mapped_vm_snapshot_data =
1488 if (file == NULL) { 1580 MapFile(vm_snapshot_data_filename, File::kReadOnly);
1489 Log::PrintErr("Failed to open: %s\n", vm_snapshot_data_filename);
1490 return kErrorExitCode;
1491 }
1492 mapped_vm_snapshot_data = file->Map(File::kReadOnly, 0, file->Length());
1493 if (mapped_vm_snapshot_data == NULL) {
1494 Log::PrintErr("Failed to read: %s\n", vm_snapshot_data_filename);
1495 return kErrorExitCode;
1496 }
1497 file->Release();
1498 init_params.vm_snapshot_data = 1581 init_params.vm_snapshot_data =
1499 reinterpret_cast<const uint8_t*>(mapped_vm_snapshot_data->address()); 1582 reinterpret_cast<const uint8_t*>(mapped_vm_snapshot_data->address());
1500 1583
1501 file = File::Open(isolate_snapshot_data_filename, File::kRead); 1584 if (vm_snapshot_instructions_filename != NULL) {
1502 if (file == NULL) { 1585 mapped_vm_snapshot_instructions =
1503 Log::PrintErr("Failed to open: %s\n", isolate_snapshot_data_filename); 1586 MapFile(vm_snapshot_instructions_filename, File::kReadExecute);
1504 return kErrorExitCode; 1587 init_params.vm_snapshot_instructions = reinterpret_cast<const uint8_t*>(
1588 mapped_vm_snapshot_instructions->address());
1505 } 1589 }
1590
1506 mapped_isolate_snapshot_data = 1591 mapped_isolate_snapshot_data =
1507 file->Map(File::kReadOnly, 0, file->Length()); 1592 MapFile(isolate_snapshot_data_filename, File::kReadOnly);
1508 if (mapped_isolate_snapshot_data == NULL) {
1509 Log::PrintErr("Failed to read: %s\n", isolate_snapshot_data_filename);
1510 return kErrorExitCode;
1511 }
1512 file->Release();
1513 isolate_snapshot_data = reinterpret_cast<const uint8_t*>( 1593 isolate_snapshot_data = reinterpret_cast<const uint8_t*>(
1514 mapped_isolate_snapshot_data->address()); 1594 mapped_isolate_snapshot_data->address());
1595
1596 if (isolate_snapshot_instructions_filename != NULL) {
1597 mapped_isolate_snapshot_instructions =
1598 MapFile(isolate_snapshot_instructions_filename, File::kReadExecute);
1599 isolate_snapshot_instructions = reinterpret_cast<const uint8_t*>(
1600 mapped_isolate_snapshot_instructions->address());
1601 }
1515 } 1602 }
1516 1603
1517 char* error = Dart_Initialize(&init_params); 1604 char* error = Dart_Initialize(&init_params);
1518 if (error != NULL) { 1605 if (error != NULL) {
1519 Log::PrintErr("VM initialization failed: %s\n", error); 1606 Log::PrintErr("VM initialization failed: %s\n", error);
1520 free(error); 1607 free(error);
1521 return kErrorExitCode; 1608 return kErrorExitCode;
1522 } 1609 }
1523 1610
1524 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root, 1611 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root,
1525 commandline_packages_file, NULL); 1612 commandline_packages_file, NULL);
1526 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, isolate_snapshot_data, 1613 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, isolate_snapshot_data,
1527 NULL, NULL, isolate_data, &error); 1614 isolate_snapshot_instructions, NULL,
1615 isolate_data, &error);
1528 if (isolate == NULL) { 1616 if (isolate == NULL) {
1529 Log::PrintErr("Error: %s\n", error); 1617 Log::PrintErr("Error: %s\n", error);
1530 free(error); 1618 free(error);
1531 exit(kErrorExitCode); 1619 exit(kErrorExitCode);
1532 } 1620 }
1533 1621
1534 Dart_Handle result; 1622 Dart_Handle result;
1535 Dart_Handle library; 1623 Dart_Handle library;
1536 Dart_EnterScope(); 1624 Dart_EnterScope();
1537 1625
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 void* kernel_program = NULL; 1670 void* kernel_program = NULL;
1583 if (is_kernel_file) { 1671 if (is_kernel_file) {
1584 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length); 1672 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length);
1585 free(const_cast<uint8_t*>(kernel)); 1673 free(const_cast<uint8_t*>(kernel));
1586 } 1674 }
1587 1675
1588 Dart_Isolate isolate = 1676 Dart_Isolate isolate =
1589 is_kernel_file 1677 is_kernel_file
1590 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel_program, NULL, 1678 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel_program, NULL,
1591 isolate_data, &error) 1679 isolate_data, &error)
1592 : Dart_CreateIsolate(NULL, NULL, isolate_snapshot_data, NULL, NULL, 1680 : Dart_CreateIsolate(NULL, NULL, isolate_snapshot_data,
1681 isolate_snapshot_instructions, NULL,
1593 isolate_data, &error); 1682 isolate_data, &error);
1594 if (isolate == NULL) { 1683 if (isolate == NULL) {
1595 Log::PrintErr("%s\n", error); 1684 Log::PrintErr("%s\n", error);
1596 free(error); 1685 free(error);
1597 exit(kErrorExitCode); 1686 exit(kErrorExitCode);
1598 } 1687 }
1599 Dart_EnterScope(); 1688 Dart_EnterScope();
1600 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 1689 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
1601 CHECK_RESULT(result); 1690 CHECK_RESULT(result);
1602 1691
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1725
1637 // Ensure that we mark all libraries as loaded. 1726 // Ensure that we mark all libraries as loaded.
1638 result = Dart_FinalizeLoading(false); 1727 result = Dart_FinalizeLoading(false);
1639 CHECK_RESULT(result); 1728 CHECK_RESULT(result);
1640 1729
1641 if (!dependencies_only) { 1730 if (!dependencies_only) {
1642 switch (snapshot_kind) { 1731 switch (snapshot_kind) {
1643 case kCore: 1732 case kCore:
1644 CreateAndWriteCoreSnapshot(); 1733 CreateAndWriteCoreSnapshot();
1645 break; 1734 break;
1735 case kCoreJIT:
1736 CreateAndWriteCoreJITSnapshot();
1737 break;
1646 case kScript: 1738 case kScript:
1647 CreateAndWriteScriptSnapshot(); 1739 CreateAndWriteScriptSnapshot();
1648 break; 1740 break;
1649 case kAppAOTBlobs: 1741 case kAppAOTBlobs:
1650 case kAppAOTAssembly: 1742 case kAppAOTAssembly:
1651 CreateAndWritePrecompiledSnapshot(entry_points); 1743 CreateAndWritePrecompiledSnapshot(entry_points);
1652 break; 1744 break;
1653 default: 1745 default:
1654 UNREACHABLE(); 1746 UNREACHABLE();
1655 } 1747 }
1656 } 1748 }
1657 1749
1658 CreateAndWriteDependenciesFile(); 1750 CreateAndWriteDependenciesFile();
1659 1751
1660 Dart_ExitScope(); 1752 Dart_ExitScope();
1661 Dart_ShutdownIsolate(); 1753 Dart_ShutdownIsolate();
1662 1754
1663 CleanupEntryPointsCollection(entry_points); 1755 CleanupEntryPointsCollection(entry_points);
1664 1756
1665 Dart_EnterIsolate(UriResolverIsolateScope::isolate); 1757 Dart_EnterIsolate(UriResolverIsolateScope::isolate);
1666 Dart_ShutdownIsolate(); 1758 Dart_ShutdownIsolate();
1667 } else { 1759 } else {
1668 SetupForGenericSnapshotCreation(); 1760 SetupForGenericSnapshotCreation();
1669 CreateAndWriteCoreSnapshot(); 1761 switch (snapshot_kind) {
1762 case kCore:
1763 CreateAndWriteCoreSnapshot();
1764 break;
1765 case kCoreJIT:
1766 CreateAndWriteCoreJITSnapshot();
1767 break;
1768 default:
1769 UNREACHABLE();
1770 break;
1771 }
1670 1772
1671 Dart_ExitScope(); 1773 Dart_ExitScope();
1672 Dart_ShutdownIsolate(); 1774 Dart_ShutdownIsolate();
1673 } 1775 }
1674 error = Dart_Cleanup(); 1776 error = Dart_Cleanup();
1675 if (error != NULL) { 1777 if (error != NULL) {
1676 Log::PrintErr("VM cleanup failed: %s\n", error); 1778 Log::PrintErr("VM cleanup failed: %s\n", error);
1677 free(error); 1779 free(error);
1678 } 1780 }
1679 EventHandler::Stop(); 1781 EventHandler::Stop();
1680 delete mapped_vm_snapshot_data; 1782 delete mapped_vm_snapshot_data;
1681 delete mapped_isolate_snapshot_data; 1783 delete mapped_isolate_snapshot_data;
1682 return 0; 1784 return 0;
1683 } 1785 }
1684 1786
1685 } // namespace bin 1787 } // namespace bin
1686 } // namespace dart 1788 } // namespace dart
1687 1789
1688 int main(int argc, char** argv) { 1790 int main(int argc, char** argv) {
1689 return dart::bin::main(argc, argv); 1791 return dart::bin::main(argc, argv);
1690 } 1792 }
OLDNEW
« no previous file with comments | « runtime/bin/BUILD.gn ('k') | runtime/bin/main.cc » ('j') | runtime/include/dart_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698