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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 2694103004: Cleanup app snapshots on isolate/vm exit. (Closed)
Patch Set: merge 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file_win.cc ('k') | runtime/bin/isolate_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index 36c521a771147f98edc1a7c359cc81f2429f3513..2ecf34a10239fb87b7d4a4fa5333861627c2b847 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -1234,7 +1234,7 @@ static Dart_Isolate CreateServiceIsolate(const char* script_uri,
void* data,
char** error) {
IsolateData* isolate_data =
- new IsolateData(script_uri, package_root, package_config);
+ new IsolateData(script_uri, package_root, package_config, NULL);
Dart_Isolate isolate = NULL;
isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, NULL,
NULL, isolate_data, error);
@@ -1330,32 +1330,37 @@ int main(int argc, char** argv) {
init_params.file_close = DartUtils::CloseFile;
init_params.entropy_source = DartUtils::EntropySource;
+ MappedMemory* mapped_vm_snapshot_data = NULL;
+ MappedMemory* mapped_isolate_snapshot_data = NULL;
if (snapshot_kind == kScript) {
File* file = File::Open(vm_snapshot_data_filename, File::kRead);
if (file == NULL) {
Log::PrintErr("Failed to open: %s\n", vm_snapshot_data_filename);
return kErrorExitCode;
}
- void* buffer = file->Map(File::kReadOnly, 0, file->Length());
- if (buffer == NULL) {
+ mapped_vm_snapshot_data = file->Map(File::kReadOnly, 0, file->Length());
+ if (mapped_vm_snapshot_data == NULL) {
Log::PrintErr("Failed to read: %s\n", vm_snapshot_data_filename);
return kErrorExitCode;
}
file->Close();
- init_params.vm_snapshot_data = reinterpret_cast<const uint8_t*>(buffer);
+ init_params.vm_snapshot_data =
+ reinterpret_cast<const uint8_t*>(mapped_vm_snapshot_data->address());
file = File::Open(isolate_snapshot_data_filename, File::kRead);
if (file == NULL) {
Log::PrintErr("Failed to open: %s\n", isolate_snapshot_data_filename);
return kErrorExitCode;
}
- buffer = file->Map(File::kReadOnly, 0, file->Length());
- if (buffer == NULL) {
+ mapped_isolate_snapshot_data =
+ file->Map(File::kReadOnly, 0, file->Length());
+ if (mapped_isolate_snapshot_data == NULL) {
Log::PrintErr("Failed to read: %s\n", isolate_snapshot_data_filename);
return kErrorExitCode;
}
file->Close();
- isolate_snapshot_data = reinterpret_cast<const uint8_t*>(buffer);
+ isolate_snapshot_data = reinterpret_cast<const uint8_t*>(
+ mapped_isolate_snapshot_data->address());
}
char* error = Dart_Initialize(&init_params);
@@ -1366,7 +1371,7 @@ int main(int argc, char** argv) {
}
IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root,
- commandline_packages_file);
+ commandline_packages_file, NULL);
Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, isolate_snapshot_data,
NULL, NULL, isolate_data, &error);
if (isolate == NULL) {
@@ -1414,7 +1419,7 @@ int main(int argc, char** argv) {
// Now we create an isolate into which we load all the code that needs to
// be in the snapshot.
- isolate_data = new IsolateData(NULL, NULL, NULL);
+ isolate_data = new IsolateData(NULL, NULL, NULL, NULL);
const uint8_t* kernel = NULL;
intptr_t kernel_length = 0;
const bool is_kernel_file =
@@ -1510,6 +1515,8 @@ int main(int argc, char** argv) {
free(error);
}
EventHandler::Stop();
+ delete mapped_vm_snapshot_data;
+ delete mapped_isolate_snapshot_data;
return 0;
}
« no previous file with comments | « runtime/bin/file_win.cc ('k') | runtime/bin/isolate_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698