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

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

Issue 2694103004: Cleanup app snapshots on isolate/vm exit. (Closed)
Patch Set: . Created 3 years, 10 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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1141
1142 1142
1143 static Dart_Isolate CreateServiceIsolate(const char* script_uri, 1143 static Dart_Isolate CreateServiceIsolate(const char* script_uri,
1144 const char* main, 1144 const char* main,
1145 const char* package_root, 1145 const char* package_root,
1146 const char* package_config, 1146 const char* package_config,
1147 Dart_IsolateFlags* flags, 1147 Dart_IsolateFlags* flags,
1148 void* data, 1148 void* data,
1149 char** error) { 1149 char** error) {
1150 IsolateData* isolate_data = 1150 IsolateData* isolate_data =
1151 new IsolateData(script_uri, package_root, package_config); 1151 new IsolateData(script_uri, package_root, package_config, NULL);
1152 Dart_Isolate isolate = NULL; 1152 Dart_Isolate isolate = NULL;
1153 isolate = Dart_CreateIsolate(script_uri, main, NULL, NULL, NULL, isolate_data, 1153 isolate = Dart_CreateIsolate(script_uri, main, NULL, NULL, NULL, isolate_data,
1154 error); 1154 error);
1155 1155
1156 if (isolate == NULL) { 1156 if (isolate == NULL) {
1157 Log::PrintErr("Error: Could not create service isolate"); 1157 Log::PrintErr("Error: Could not create service isolate");
1158 return NULL; 1158 return NULL;
1159 } 1159 }
1160 1160
1161 Dart_EnterScope(); 1161 Dart_EnterScope();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 init_params.entropy_source = DartUtils::EntropySource; 1245 init_params.entropy_source = DartUtils::EntropySource;
1246 1246
1247 char* error = Dart_Initialize(&init_params); 1247 char* error = Dart_Initialize(&init_params);
1248 if (error != NULL) { 1248 if (error != NULL) {
1249 Log::PrintErr("VM initialization failed: %s\n", error); 1249 Log::PrintErr("VM initialization failed: %s\n", error);
1250 free(error); 1250 free(error);
1251 return kErrorExitCode; 1251 return kErrorExitCode;
1252 } 1252 }
1253 1253
1254 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root, 1254 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root,
1255 commandline_packages_file); 1255 commandline_packages_file, NULL);
1256 Dart_Isolate isolate = 1256 Dart_Isolate isolate =
1257 Dart_CreateIsolate(NULL, NULL, NULL, NULL, NULL, isolate_data, &error); 1257 Dart_CreateIsolate(NULL, NULL, NULL, NULL, NULL, isolate_data, &error);
1258 if (isolate == NULL) { 1258 if (isolate == NULL) {
1259 Log::PrintErr("Error: %s", error); 1259 Log::PrintErr("Error: %s", error);
1260 free(error); 1260 free(error);
1261 exit(kErrorExitCode); 1261 exit(kErrorExitCode);
1262 } 1262 }
1263 1263
1264 Dart_Handle result; 1264 Dart_Handle result;
1265 Dart_Handle library; 1265 Dart_Handle library;
(...skipping 27 matching lines...) Expand all
1293 result = DartUtils::SetupPackageRoot(commandline_package_root, 1293 result = DartUtils::SetupPackageRoot(commandline_package_root,
1294 commandline_packages_file); 1294 commandline_packages_file);
1295 CHECK_RESULT(result); 1295 CHECK_RESULT(result);
1296 1296
1297 UriResolverIsolateScope::isolate = isolate; 1297 UriResolverIsolateScope::isolate = isolate;
1298 Dart_ExitScope(); 1298 Dart_ExitScope();
1299 Dart_ExitIsolate(); 1299 Dart_ExitIsolate();
1300 1300
1301 // Now we create an isolate into which we load all the code that needs to 1301 // Now we create an isolate into which we load all the code that needs to
1302 // be in the snapshot. 1302 // be in the snapshot.
1303 isolate_data = new IsolateData(NULL, NULL, NULL); 1303 isolate_data = new IsolateData(NULL, NULL, NULL, NULL);
1304 const uint8_t* kernel = NULL; 1304 const uint8_t* kernel = NULL;
1305 intptr_t kernel_length = 0; 1305 intptr_t kernel_length = 0;
1306 const bool is_kernel_file = 1306 const bool is_kernel_file =
1307 TryReadKernel(app_script_name, &kernel, &kernel_length); 1307 TryReadKernel(app_script_name, &kernel, &kernel_length);
1308 1308
1309 void* kernel_program = NULL; 1309 void* kernel_program = NULL;
1310 if (is_kernel_file) { 1310 if (is_kernel_file) {
1311 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length); 1311 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length);
1312 free(const_cast<uint8_t*>(kernel)); 1312 free(const_cast<uint8_t*>(kernel));
1313 } 1313 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 EventHandler::Stop(); 1383 EventHandler::Stop();
1384 return 0; 1384 return 0;
1385 } 1385 }
1386 1386
1387 } // namespace bin 1387 } // namespace bin
1388 } // namespace dart 1388 } // namespace dart
1389 1389
1390 int main(int argc, char** argv) { 1390 int main(int argc, char** argv) {
1391 return dart::bin::main(argc, argv); 1391 return dart::bin::main(argc, argv);
1392 } 1392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698