Chromium Code Reviews| Index: samples/shell.cc |
| diff --git a/samples/shell.cc b/samples/shell.cc |
| index 51053aa0e56233553dc0da8571da67f03a23615d..1c2974b0e732f4785597faa3255fcb69c31df32e 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 |
|
Søren Thygesen Gjesse
2011/04/29 06:50:29
Should this support be added to D8 as well? The pr
mnaganov (inactive)
2011/04/29 12:07:58
I think, this doesn't make much sense for D8 eithe
|
| +#include <bzlib.h> |
| +#endif |
| #include <fcntl.h> |
| #include <string.h> |
| #include <stdio.h> |
| @@ -299,6 +302,29 @@ int main(int argc, char* argv[]) { |
| } |
| } |
| +#ifdef COMPRESS_STARTUP_DATA_BZ2 |
| + 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].decompressed_size]; |
| + unsigned int decompressed_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].decompressed_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 +345,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; |
| } |