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

Unified Diff: src/bz2-decompress.cc

Issue 7066048: Compress sources of JS libraries in addition to the snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments addressed Created 9 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
« src/bz2-decompress.h ('K') | « src/bz2-decompress.h ('k') | src/d8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bz2-decompress.cc
diff --git a/src/bz2-decompress.cc b/src/bz2-decompress.cc
new file mode 100644
index 0000000000000000000000000000000000000000..62f746897fd04c3b4fc9b40022f98827e6b78349
--- /dev/null
+++ b/src/bz2-decompress.cc
@@ -0,0 +1,77 @@
+// Copyright 2011 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+#include <bzlib.h>
+#endif
+
+#include "bz2-decompress.h"
+#include "v8.h"
+
+BZip2Decompressor::BZip2Decompressor()
+ : raw_data(new char*[v8::V8::GetCompressedStartupDataCount()]) {
+}
+
+
+BZip2Decompressor::~BZip2Decompressor() {
+ for (int i = 0; i < v8::V8::GetCompressedStartupDataCount(); ++i) {
+ delete[] raw_data[i];
+ }
+ delete[] raw_data;
+}
+
+
+int BZip2Decompressor::DecompressStartupData() {
+#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) {
+ unsigned int decompressed_size = compressed_data[i].raw_size;
+ char* decompressed = raw_data[i] = new char[decompressed_size];
+ if (compressed_data[i].compressed_size != 0) {
+ 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) return result;
+ } else {
+ ASSERT_EQ(0, decompressed_size);
+ }
+ compressed_data[i].data = decompressed;
+ compressed_data[i].raw_size = decompressed_size;
+ }
+ v8::V8::SetDecompressedStartupData(compressed_data);
+ return BZ_OK;
+#else
+ return 0;
+#endif // COMPRESS_STARTUP_DATA_BZ2
+}
« src/bz2-decompress.h ('K') | « src/bz2-decompress.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698