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

Unified Diff: samples/shell.cc

Issue 6901090: Add support for startup data (snapshot) compression. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: The version I'll commit Created 9 years, 8 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 | « samples/process.cc ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index 51053aa0e56233553dc0da8571da67f03a23615d..3640fa013982b96fb2dae1b1d6a6b09cff7e735c 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -28,6 +28,9 @@
#include <v8.h>
#include <v8-testing.h>
#include <assert.h>
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+#include <bzlib.h>
+#endif
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
@@ -299,6 +302,31 @@ int main(int argc, char* argv[]) {
}
}
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+ ASSERT_EQ(v8::StartupData::kBZip2,
+ v8::V8::GetCompressedStartupDataAlgorithm());
+ int compressed_data_count = v8::V8::GetCompressedStartupDataCount();
+ v8::StartupData* compressed_data = new v8::StartupData[compressed_data_count];
+ v8::V8::GetCompressedStartupData(compressed_data);
+ for (int i = 0; i < compressed_data_count; ++i) {
+ char* decompressed = new char[compressed_data[i].raw_size];
+ unsigned int decompressed_size = compressed_data[i].raw_size;
+ int result =
+ BZ2_bzBuffToBuffDecompress(decompressed,
+ &decompressed_size,
+ const_cast<char*>(compressed_data[i].data),
+ compressed_data[i].compressed_size,
+ 0, 1);
+ if (result != BZ_OK) {
+ fprintf(stderr, "bzip error code: %d\n", result);
+ exit(1);
+ }
+ compressed_data[i].data = decompressed;
+ compressed_data[i].raw_size = decompressed_size;
+ }
+ v8::V8::SetDecompressedStartupData(compressed_data);
+#endif // COMPRESS_STARTUP_DATA_BZ2
+
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
int result = 0;
if (FLAG_stress_opt || FLAG_stress_deopt) {
@@ -319,6 +347,14 @@ int main(int argc, char* argv[]) {
result = RunMain(argc, argv);
}
v8::V8::Dispose();
+
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+ for (int i = 0; i < compressed_data_count; ++i) {
+ delete[] compressed_data[i].data;
+ }
+ delete[] compressed_data;
+#endif // COMPRESS_STARTUP_DATA_BZ2
+
return result;
}
« no previous file with comments | « samples/process.cc ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698