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

Side by Side Diff: src/mksnapshot.cc

Issue 581223004: Support large objects in the serializer/deserializer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #ifdef COMPRESS_STARTUP_DATA_BZ2 7 #ifdef COMPRESS_STARTUP_DATA_BZ2
8 #include <bzlib.h> 8 #include <bzlib.h>
9 #endif 9 #endif
10 #include <signal.h> 10 #include <signal.h>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 void SetStartupBlobFile(const char* startup_blob_file) { 61 void SetStartupBlobFile(const char* startup_blob_file) {
62 if (startup_blob_file != NULL) 62 if (startup_blob_file != NULL)
63 startup_blob_file_ = GetFileDescriptorOrDie(startup_blob_file); 63 startup_blob_file_ = GetFileDescriptorOrDie(startup_blob_file);
64 } 64 }
65 65
66 void WriteSnapshot(const i::List<i::byte>& snapshot_data, 66 void WriteSnapshot(const i::List<i::byte>& snapshot_data,
67 const i::Serializer& serializer, 67 const i::Serializer& serializer,
68 const i::List<i::byte>& context_snapshot_data, 68 const i::List<i::byte>& context_snapshot_data,
69 const i::Serializer& context_serializer) const { 69 const i::Serializer& context_serializer) const {
70 // The serializer supports large objects, but we don't expect any in the
71 // the startup snapshot. If this changes, we need to write it into the
72 // snapshot file and read it for deserialization.
73 CHECK_EQ(0, serializer.large_objects_total_size());
74 CHECK_EQ(0, context_serializer.large_objects_total_size());
70 WriteSnapshotFile(snapshot_data, serializer, 75 WriteSnapshotFile(snapshot_data, serializer,
71 context_snapshot_data, context_serializer); 76 context_snapshot_data, context_serializer);
72 MaybeWriteStartupBlob(snapshot_data, serializer, 77 MaybeWriteStartupBlob(snapshot_data, serializer,
73 context_snapshot_data, context_serializer); 78 context_snapshot_data, context_serializer);
74 } 79 }
75 80
76 private: 81 private:
77 void MaybeWriteStartupBlob(const i::List<i::byte>& snapshot_data, 82 void MaybeWriteStartupBlob(const i::List<i::byte>& snapshot_data,
78 const i::Serializer& serializer, 83 const i::Serializer& serializer,
79 const i::List<i::byte>& context_snapshot_data, 84 const i::List<i::byte>& context_snapshot_data,
80 const i::Serializer& context_serializer) const { 85 const i::Serializer& context_serializer) const {
81 if (!startup_blob_file_) 86 if (!startup_blob_file_)
82 return; 87 return;
83 88
84 i::List<i::byte> startup_blob; 89 i::List<i::byte> startup_blob;
85 i::ListSnapshotSink sink(&startup_blob); 90 i::ListSnapshotSink sink(&startup_blob);
86 91
87 int spaces[] = { 92 // Large object space reservation is not necessary.
88 i::NEW_SPACE, i::OLD_POINTER_SPACE, i::OLD_DATA_SPACE, i::CODE_SPACE, 93 int spaces[] = {i::NEW_SPACE, i::OLD_POINTER_SPACE,
89 i::MAP_SPACE, i::CELL_SPACE, i::PROPERTY_CELL_SPACE 94 i::OLD_DATA_SPACE, i::CODE_SPACE,
90 }; 95 i::MAP_SPACE, i::CELL_SPACE,
96 i::PROPERTY_CELL_SPACE};
91 97
92 i::byte* snapshot_bytes = snapshot_data.begin(); 98 i::byte* snapshot_bytes = snapshot_data.begin();
93 sink.PutBlob(snapshot_bytes, snapshot_data.length(), "snapshot"); 99 sink.PutBlob(snapshot_bytes, snapshot_data.length(), "snapshot");
94 for (size_t i = 0; i < arraysize(spaces); ++i) 100 for (size_t i = 0; i < arraysize(spaces); ++i)
95 sink.PutInt(serializer.CurrentAllocationAddress(spaces[i]), "spaces"); 101 sink.PutInt(serializer.CurrentAllocationAddress(spaces[i]), "spaces");
96 102
97 i::byte* context_bytes = context_snapshot_data.begin(); 103 i::byte* context_bytes = context_snapshot_data.begin();
98 sink.PutBlob(context_bytes, context_snapshot_data.length(), "context"); 104 sink.PutBlob(context_bytes, context_snapshot_data.length(), "context");
99 for (size_t i = 0; i < arraysize(spaces); ++i) 105 for (size_t i = 0; i < arraysize(spaces); ++i)
100 sink.PutInt(context_serializer.CurrentAllocationAddress(spaces[i]), 106 sink.PutInt(context_serializer.CurrentAllocationAddress(spaces[i]),
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 writer.WriteSnapshot(snapshot_data, ser, context_data, context_ser); 435 writer.WriteSnapshot(snapshot_data, ser, context_data, context_ser);
430 } 436 }
431 } 437 }
432 438
433 isolate->Dispose(); 439 isolate->Dispose();
434 V8::Dispose(); 440 V8::Dispose();
435 V8::ShutdownPlatform(); 441 V8::ShutdownPlatform();
436 delete platform; 442 delete platform;
437 return 0; 443 return 0;
438 } 444 }
OLDNEW
« no previous file with comments | « src/heap/spaces.cc ('k') | src/serialize.h » ('j') | src/serialize.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698