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

Unified Diff: src/mksnapshot.cc

Issue 328693003: Revert "Support external startup data in V8." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix brace. Created 6 years, 6 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 | « src/heap.cc ('k') | src/natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mksnapshot.cc
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index 91baeba2a34e55af9a23980f76f27fa4a172fccc..d4262c4cea1351af3c3f003487d1daa0f079810d 100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -48,81 +48,33 @@ class SnapshotWriter {
: fp_(GetFileDescriptorOrDie(snapshot_file))
, raw_file_(NULL)
, raw_context_file_(NULL)
- , startup_blob_file_(NULL)
- , compressor_(NULL) {
+ , compressor_(NULL)
+ , omit_(false) {
}
~SnapshotWriter() {
fclose(fp_);
if (raw_file_) fclose(raw_file_);
if (raw_context_file_) fclose(raw_context_file_);
- if (startup_blob_file_) fclose(startup_blob_file_);
}
void SetCompressor(Compressor* compressor) {
compressor_ = compressor;
}
+ void SetOmit(bool omit) {
+ omit_ = omit;
+ }
+
void SetRawFiles(const char* raw_file, const char* raw_context_file) {
raw_file_ = GetFileDescriptorOrDie(raw_file);
raw_context_file_ = GetFileDescriptorOrDie(raw_context_file);
}
- void SetStartupBlobFile(const char* startup_blob_file) {
- if (startup_blob_file != NULL)
- startup_blob_file_ = GetFileDescriptorOrDie(startup_blob_file);
- }
-
void WriteSnapshot(const i::List<char>& snapshot_data,
const i::Serializer& serializer,
const i::List<char>& context_snapshot_data,
const i::Serializer& context_serializer) const {
- WriteSnapshotFile(snapshot_data, serializer,
- context_snapshot_data, context_serializer);
- MaybeWriteStartupBlob(snapshot_data, serializer,
- context_snapshot_data, context_serializer);
- }
-
- private:
- void MaybeWriteStartupBlob(const i::List<char>& snapshot_data,
- const i::Serializer& serializer,
- const i::List<char>& context_snapshot_data,
- const i::Serializer& context_serializer) const {
- if (!startup_blob_file_)
- return;
-
- i::List<char> startup_blob;
- ListSnapshotSink sink(&startup_blob);
-
- int spaces[] = {
- i::NEW_SPACE, i::OLD_POINTER_SPACE, i::OLD_DATA_SPACE, i::CODE_SPACE,
- i::MAP_SPACE, i::CELL_SPACE, i::PROPERTY_CELL_SPACE
- };
-
- i::byte* snapshot_bytes = reinterpret_cast<i::byte*>(snapshot_data.begin());
- sink.PutBlob(snapshot_bytes, snapshot_data.length(), "snapshot");
- for (size_t i = 0; i < ARRAY_SIZE(spaces); ++i)
- sink.PutInt(serializer.CurrentAllocationAddress(spaces[i]), "spaces");
-
- i::byte* context_bytes =
- reinterpret_cast<i::byte*>(context_snapshot_data.begin());
- sink.PutBlob(context_bytes, context_snapshot_data.length(), "context");
- for (size_t i = 0; i < ARRAY_SIZE(spaces); ++i)
- sink.PutInt(context_serializer.CurrentAllocationAddress(spaces[i]),
- "spaces");
-
- size_t written = fwrite(startup_blob.begin(), 1, startup_blob.length(),
- startup_blob_file_);
- if (written != (size_t)startup_blob.length()) {
- i::PrintF("Writing snapshot file failed.. Aborting.\n");
- exit(1);
- }
- }
-
- void WriteSnapshotFile(const i::List<char>& snapshot_data,
- const i::Serializer& serializer,
- const i::List<char>& context_snapshot_data,
- const i::Serializer& context_serializer) const {
WriteFilePrefix();
WriteData("", snapshot_data, raw_file_);
WriteData("context_", context_snapshot_data, raw_context_file_);
@@ -131,6 +83,7 @@ class SnapshotWriter {
WriteFileSuffix();
}
+ private:
void WriteFilePrefix() const {
fprintf(fp_, "// Autogenerated snapshot file. Do not edit.\n\n");
fprintf(fp_, "#include \"src/v8.h\"\n");
@@ -184,12 +137,13 @@ class SnapshotWriter {
const i::List<char>& source_data,
const i::List<char>* data_to_be_written) const {
fprintf(fp_, "const byte Snapshot::%sdata_[] = {\n", prefix);
- WriteSnapshotData(data_to_be_written);
+ if (!omit_)
+ WriteSnapshotData(data_to_be_written);
fprintf(fp_, "};\n");
fprintf(fp_, "const int Snapshot::%ssize_ = %d;\n", prefix,
data_to_be_written->length());
- if (data_to_be_written == &source_data) {
+ if (data_to_be_written == &source_data && !omit_) {
fprintf(fp_, "const byte* Snapshot::%sraw_data_ = Snapshot::%sdata_;\n",
prefix, prefix);
fprintf(fp_, "const int Snapshot::%sraw_size_ = Snapshot::%ssize_;\n",
@@ -242,8 +196,8 @@ class SnapshotWriter {
FILE* fp_;
FILE* raw_file_;
FILE* raw_context_file_;
- FILE* startup_blob_file_;
Compressor* compressor_;
+ bool omit_;
};
@@ -427,10 +381,9 @@ int main(int argc, char** argv) {
{
SnapshotWriter writer(argv[1]);
+ writer.SetOmit(i::FLAG_omit);
if (i::FLAG_raw_file && i::FLAG_raw_context_file)
writer.SetRawFiles(i::FLAG_raw_file, i::FLAG_raw_context_file);
- if (i::FLAG_startup_blob)
- writer.SetStartupBlobFile(i::FLAG_startup_blob);
#ifdef COMPRESS_STARTUP_DATA_BZ2
BZip2Compressor bzip2;
writer.SetCompressor(&bzip2);
« no previous file with comments | « src/heap.cc ('k') | src/natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698