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

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

Issue 2517683002: Don't include usage counters, etc in snapshots with code. If we already have code, eagerly recompil… (Closed)
Patch Set: . 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/log_android.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 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 // |CleanupEntryPointsCollection| 988 // |CleanupEntryPointsCollection|
989 return entries; 989 return entries;
990 } 990 }
991 991
992 992
993 static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() { 993 static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() {
994 Dart_QualifiedFunctionName* entries = ParseEntryPointsManifestFiles(); 994 Dart_QualifiedFunctionName* entries = ParseEntryPointsManifestFiles();
995 if ((entries == NULL) && IsSnapshottingForPrecompilation()) { 995 if ((entries == NULL) && IsSnapshottingForPrecompilation()) {
996 Log::PrintErr( 996 Log::PrintErr(
997 "Could not find native embedder entry points during precompilation\n"); 997 "Could not find native embedder entry points during precompilation\n");
998 exit(255); 998 exit(kErrorExitCode);
999 } 999 }
1000 return entries; 1000 return entries;
1001 } 1001 }
1002 1002
1003 1003
1004 static void CreateAndWriteSnapshot() { 1004 static void CreateAndWriteSnapshot() {
1005 ASSERT(!IsSnapshottingForPrecompilation()); 1005 ASSERT(!IsSnapshottingForPrecompilation());
1006 Dart_Handle result; 1006 Dart_Handle result;
1007 uint8_t* vm_isolate_buffer = NULL; 1007 uint8_t* vm_isolate_buffer = NULL;
1008 intptr_t vm_isolate_size = 0; 1008 intptr_t vm_isolate_size = 0;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 } 1074 }
1075 1075
1076 1076
1077 static void SetupForUriResolution() { 1077 static void SetupForUriResolution() {
1078 // Set up the library tag handler for this isolate. 1078 // Set up the library tag handler for this isolate.
1079 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 1079 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
1080 if (Dart_IsError(result)) { 1080 if (Dart_IsError(result)) {
1081 Log::PrintErr("%s", Dart_GetError(result)); 1081 Log::PrintErr("%s", Dart_GetError(result));
1082 Dart_ExitScope(); 1082 Dart_ExitScope();
1083 Dart_ShutdownIsolate(); 1083 Dart_ShutdownIsolate();
1084 exit(255); 1084 exit(kErrorExitCode);
1085 } 1085 }
1086 // This is a generic dart snapshot which needs builtin library setup. 1086 // This is a generic dart snapshot which needs builtin library setup.
1087 Dart_Handle library = 1087 Dart_Handle library =
1088 LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary); 1088 LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary);
1089 VerifyLoaded(library); 1089 VerifyLoaded(library);
1090 } 1090 }
1091 1091
1092 1092
1093 static void SetupForGenericSnapshotCreation() { 1093 static void SetupForGenericSnapshotCreation() {
1094 SetupForUriResolution(); 1094 SetupForUriResolution();
1095 1095
1096 Dart_Handle library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary); 1096 Dart_Handle library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary);
1097 VerifyLoaded(library); 1097 VerifyLoaded(library);
1098 Dart_Handle result = Dart_FinalizeLoading(false); 1098 Dart_Handle result = Dart_FinalizeLoading(false);
1099 if (Dart_IsError(result)) { 1099 if (Dart_IsError(result)) {
1100 const char* err_msg = Dart_GetError(library); 1100 const char* err_msg = Dart_GetError(library);
1101 Log::PrintErr("Errors encountered while loading: %s\n", err_msg); 1101 Log::PrintErr("Errors encountered while loading: %s\n", err_msg);
1102 Dart_ExitScope(); 1102 Dart_ExitScope();
1103 Dart_ShutdownIsolate(); 1103 Dart_ShutdownIsolate();
1104 exit(255); 1104 exit(kErrorExitCode);
1105 } 1105 }
1106 } 1106 }
1107 1107
1108 1108
1109 static Dart_Isolate CreateServiceIsolate(const char* script_uri, 1109 static Dart_Isolate CreateServiceIsolate(const char* script_uri,
1110 const char* main, 1110 const char* main,
1111 const char* package_root, 1111 const char* package_root,
1112 const char* package_config, 1112 const char* package_config,
1113 Dart_IsolateFlags* flags, 1113 Dart_IsolateFlags* flags,
1114 void* data, 1114 void* data,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 CommandLineOptions cmdline_url_mapping(argc); 1159 CommandLineOptions cmdline_url_mapping(argc);
1160 DartUtils::url_mapping = &cmdline_url_mapping; 1160 DartUtils::url_mapping = &cmdline_url_mapping;
1161 1161
1162 // Initialize the entrypoints array. 1162 // Initialize the entrypoints array.
1163 CommandLineOptions entry_points_files_array(argc); 1163 CommandLineOptions entry_points_files_array(argc);
1164 entry_points_files = &entry_points_files_array; 1164 entry_points_files = &entry_points_files_array;
1165 1165
1166 // Parse command line arguments. 1166 // Parse command line arguments.
1167 if (ParseArguments(argc, argv, &vm_options, &app_script_name) < 0) { 1167 if (ParseArguments(argc, argv, &vm_options, &app_script_name) < 0) {
1168 PrintUsage(); 1168 PrintUsage();
1169 return 255; 1169 return kErrorExitCode;
1170 } 1170 }
1171 1171
1172 Thread::InitOnce(); 1172 Thread::InitOnce();
1173 Loader::InitOnce(); 1173 Loader::InitOnce();
1174 DartUtils::SetOriginalWorkingDirectory(); 1174 DartUtils::SetOriginalWorkingDirectory();
1175 // Start event handler. 1175 // Start event handler.
1176 TimerUtils::InitOnce(); 1176 TimerUtils::InitOnce();
1177 EventHandler::Start(); 1177 EventHandler::Start();
1178 1178
1179 #if !defined(PRODUCT) 1179 #if !defined(PRODUCT)
1180 // Constant true in PRODUCT mode. 1180 // Constant true in PRODUCT mode.
1181 vm_options.AddArgument("--load_deferred_eagerly"); 1181 vm_options.AddArgument("--load_deferred_eagerly");
1182 #endif 1182 #endif
1183 1183
1184 if (IsSnapshottingForPrecompilation()) { 1184 if (IsSnapshottingForPrecompilation()) {
1185 vm_options.AddArgument("--precompilation"); 1185 vm_options.AddArgument("--precompilation");
1186 vm_options.AddArgument("--print_snapshot_sizes");
1186 #if TARGET_ARCH_ARM 1187 #if TARGET_ARCH_ARM
1187 // This is for the iPod Touch 5th Generation (and maybe other older devices) 1188 // This is for the iPod Touch 5th Generation (and maybe other older devices)
1188 vm_options.AddArgument("--no-use_integer_division"); 1189 vm_options.AddArgument("--no-use_integer_division");
1189 #endif 1190 #endif
1190 } 1191 }
1191 1192
1192 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 1193 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
1193 1194
1194 // Initialize the Dart VM. 1195 // Initialize the Dart VM.
1195 // Note: We don't expect isolates to be created from dart code during 1196 // Note: We don't expect isolates to be created from dart code during
(...skipping 10 matching lines...) Expand all
1206 init_params.file_open = DartUtils::OpenFile; 1207 init_params.file_open = DartUtils::OpenFile;
1207 init_params.file_read = DartUtils::ReadFile; 1208 init_params.file_read = DartUtils::ReadFile;
1208 init_params.file_write = DartUtils::WriteFile; 1209 init_params.file_write = DartUtils::WriteFile;
1209 init_params.file_close = DartUtils::CloseFile; 1210 init_params.file_close = DartUtils::CloseFile;
1210 init_params.entropy_source = DartUtils::EntropySource; 1211 init_params.entropy_source = DartUtils::EntropySource;
1211 1212
1212 char* error = Dart_Initialize(&init_params); 1213 char* error = Dart_Initialize(&init_params);
1213 if (error != NULL) { 1214 if (error != NULL) {
1214 Log::PrintErr("VM initialization failed: %s\n", error); 1215 Log::PrintErr("VM initialization failed: %s\n", error);
1215 free(error); 1216 free(error);
1216 return 255; 1217 return kErrorExitCode;
1217 } 1218 }
1218 1219
1219 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root, 1220 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root,
1220 commandline_packages_file); 1221 commandline_packages_file);
1221 Dart_Isolate isolate = 1222 Dart_Isolate isolate =
1222 Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error); 1223 Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error);
1223 if (isolate == NULL) { 1224 if (isolate == NULL) {
1224 Log::PrintErr("Error: %s", error); 1225 Log::PrintErr("Error: %s", error);
1225 free(error); 1226 free(error);
1226 exit(255); 1227 exit(kErrorExitCode);
1227 } 1228 }
1228 1229
1229 Dart_Handle result; 1230 Dart_Handle result;
1230 Dart_Handle library; 1231 Dart_Handle library;
1231 Dart_EnterScope(); 1232 Dart_EnterScope();
1232 1233
1233 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 1234 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
1234 CHECK_RESULT(result); 1235 CHECK_RESULT(result);
1235 1236
1236 ASSERT(vm_isolate_snapshot_filename != NULL); 1237 ASSERT(vm_isolate_snapshot_filename != NULL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 const uint8_t* kernel = NULL; 1270 const uint8_t* kernel = NULL;
1270 intptr_t kernel_length = 0; 1271 intptr_t kernel_length = 0;
1271 const bool is_kernel_file = 1272 const bool is_kernel_file =
1272 TryReadKernel(app_script_name, &kernel, &kernel_length); 1273 TryReadKernel(app_script_name, &kernel, &kernel_length);
1273 Dart_Isolate isolate = 1274 Dart_Isolate isolate =
1274 is_kernel_file 1275 is_kernel_file
1275 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel, kernel_length, 1276 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel, kernel_length,
1276 NULL, isolate_data, &error) 1277 NULL, isolate_data, &error)
1277 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error); 1278 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error);
1278 if (isolate == NULL) { 1279 if (isolate == NULL) {
1279 fprintf(stderr, "%s", error); 1280 Log::PrintErr("%s", error);
1280 free(error); 1281 free(error);
1281 exit(255); 1282 exit(kErrorExitCode);
1282 } 1283 }
1283 Dart_EnterScope(); 1284 Dart_EnterScope();
1284 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 1285 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
1285 CHECK_RESULT(result); 1286 CHECK_RESULT(result);
1286 1287
1287 // Set up the library tag handler in such a manner that it will use the 1288 // Set up the library tag handler in such a manner that it will use the
1288 // URL mapping specified on the command line to load the libraries. 1289 // URL mapping specified on the command line to load the libraries.
1289 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); 1290 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler);
1290 CHECK_RESULT(result); 1291 CHECK_RESULT(result);
1291 1292
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 EventHandler::Stop(); 1340 EventHandler::Stop();
1340 return 0; 1341 return 0;
1341 } 1342 }
1342 1343
1343 } // namespace bin 1344 } // namespace bin
1344 } // namespace dart 1345 } // namespace dart
1345 1346
1346 int main(int argc, char** argv) { 1347 int main(int argc, char** argv) {
1347 return dart::bin::main(argc, argv); 1348 return dart::bin::main(argc, argv);
1348 } 1349 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/log_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698