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

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

Issue 2416973003: Reapply "Use a single file for app snapshots." (Closed)
Patch Set: sync Created 4 years, 2 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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1029
1030 // Shutdown the isolate. 1030 // Shutdown the isolate.
1031 Dart_ShutdownIsolate(); 1031 Dart_ShutdownIsolate();
1032 } 1032 }
1033 1033
1034 1034
1035 static void CreateAndWritePrecompiledSnapshot( 1035 static void CreateAndWritePrecompiledSnapshot(
1036 Dart_QualifiedFunctionName* standalone_entry_points) { 1036 Dart_QualifiedFunctionName* standalone_entry_points) {
1037 ASSERT(IsSnapshottingForPrecompilation()); 1037 ASSERT(IsSnapshottingForPrecompilation());
1038 Dart_Handle result; 1038 Dart_Handle result;
1039 uint8_t* vm_isolate_buffer = NULL;
1040 intptr_t vm_isolate_size = 0;
1041 uint8_t* isolate_buffer = NULL;
1042 intptr_t isolate_size = 0;
1043 uint8_t* assembly_buffer = NULL;
1044 intptr_t assembly_size = 0;
1045 uint8_t* instructions_blob_buffer = NULL;
1046 intptr_t instructions_blob_size = 0;
1047 uint8_t* rodata_blob_buffer = NULL;
1048 intptr_t rodata_blob_size = 0;
1049 1039
1050 // Precompile with specified embedder entry points 1040 // Precompile with specified embedder entry points
1051 result = Dart_Precompile(standalone_entry_points, true); 1041 result = Dart_Precompile(standalone_entry_points, true);
1052 CHECK_RESULT(result); 1042 CHECK_RESULT(result);
1053 1043
1054 // Create a precompiled snapshot. 1044 // Create a precompiled snapshot.
1055 bool as_assembly = assembly_filename != NULL; 1045 bool as_assembly = assembly_filename != NULL;
1056 if (as_assembly) { 1046 if (as_assembly) {
1057 result = Dart_CreatePrecompiledSnapshotAssembly(&vm_isolate_buffer, 1047 uint8_t* assembly_buffer = NULL;
1058 &vm_isolate_size, 1048 intptr_t assembly_size = 0;
1059 &isolate_buffer, 1049 result = Dart_CreatePrecompiledSnapshotAssembly(&assembly_buffer,
1060 &isolate_size,
1061 &assembly_buffer,
1062 &assembly_size); 1050 &assembly_size);
1063 CHECK_RESULT(result); 1051 CHECK_RESULT(result);
1052 WriteSnapshotFile(assembly_filename,
1053 assembly_buffer,
1054 assembly_size);
1064 } else { 1055 } else {
1056 uint8_t* vm_isolate_buffer = NULL;
1057 intptr_t vm_isolate_size = 0;
1058 uint8_t* isolate_buffer = NULL;
1059 intptr_t isolate_size = 0;
1060 uint8_t* instructions_blob_buffer = NULL;
1061 intptr_t instructions_blob_size = 0;
1062 uint8_t* rodata_blob_buffer = NULL;
1063 intptr_t rodata_blob_size = 0;
1065 result = Dart_CreatePrecompiledSnapshotBlob(&vm_isolate_buffer, 1064 result = Dart_CreatePrecompiledSnapshotBlob(&vm_isolate_buffer,
1066 &vm_isolate_size, 1065 &vm_isolate_size,
1067 &isolate_buffer, 1066 &isolate_buffer,
1068 &isolate_size, 1067 &isolate_size,
1069 &instructions_blob_buffer, 1068 &instructions_blob_buffer,
1070 &instructions_blob_size, 1069 &instructions_blob_size,
1071 &rodata_blob_buffer, 1070 &rodata_blob_buffer,
1072 &rodata_blob_size); 1071 &rodata_blob_size);
1073 CHECK_RESULT(result); 1072 CHECK_RESULT(result);
1074 } 1073 WriteSnapshotFile(vm_isolate_snapshot_filename,
1075 1074 vm_isolate_buffer,
1076 // Now write the snapshot pieces out to the specified files and exit. 1075 vm_isolate_size);
1077 WriteSnapshotFile(vm_isolate_snapshot_filename, 1076 WriteSnapshotFile(isolate_snapshot_filename,
1078 vm_isolate_buffer, 1077 isolate_buffer,
1079 vm_isolate_size); 1078 isolate_size);
1080 WriteSnapshotFile(isolate_snapshot_filename,
1081 isolate_buffer,
1082 isolate_size);
1083 if (as_assembly) {
1084 WriteSnapshotFile(assembly_filename,
1085 assembly_buffer,
1086 assembly_size);
1087 } else {
1088 WriteSnapshotFile(instructions_blob_filename, 1079 WriteSnapshotFile(instructions_blob_filename,
1089 instructions_blob_buffer, 1080 instructions_blob_buffer,
1090 instructions_blob_size); 1081 instructions_blob_size);
1091 WriteSnapshotFile(rodata_blob_filename, 1082 WriteSnapshotFile(rodata_blob_filename,
1092 rodata_blob_buffer, 1083 rodata_blob_buffer,
1093 rodata_blob_size); 1084 rodata_blob_size);
1094 } 1085 }
1086
1095 Dart_ExitScope(); 1087 Dart_ExitScope();
1096 1088
1097 // Shutdown the isolate. 1089 // Shutdown the isolate.
1098 Dart_ShutdownIsolate(); 1090 Dart_ShutdownIsolate();
1099 } 1091 }
1100 1092
1101 1093
1102 static void SetupForUriResolution() { 1094 static void SetupForUriResolution() {
1103 // Set up the library tag handler for this isolate. 1095 // Set up the library tag handler for this isolate.
1104 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 1096 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 EventHandler::Stop(); 1346 EventHandler::Stop();
1355 return 0; 1347 return 0;
1356 } 1348 }
1357 1349
1358 } // namespace bin 1350 } // namespace bin
1359 } // namespace dart 1351 } // namespace dart
1360 1352
1361 int main(int argc, char** argv) { 1353 int main(int argc, char** argv) {
1362 return dart::bin::main(argc, argv); 1354 return dart::bin::main(argc, argv);
1363 } 1355 }
OLDNEW
« no previous file with comments | « runtime/bin/file_win.cc ('k') | runtime/bin/main.cc » ('j') | runtime/bin/main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698