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

Unified Diff: src/mksnapshot.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: Created 9 years, 7 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
Index: src/mksnapshot.cc
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index dd491166bd470b65eee30c8c8d562dffd9f8642f..73a2082d242a7d948725af419770009680e9f225 100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -136,6 +136,7 @@ class PartialSnapshotSink : public i::SnapshotByteSink {
return true;
}
int raw_size() { return raw_size_; }
+
private:
i::List<char> data_;
int raw_size_;
@@ -265,6 +266,43 @@ class BZip2Compressor : public Compressor {
private:
i::ScopedVector<char>* output_;
};
+
+class BZip2Decompressor {
+ public:
+ BZip2Decompressor()
+ : libraries(i::NewArray<char*>(i::Natives::GetBuiltinsCount())) {
+ }
+ ~BZip2Decompressor() {
+ for (int i = 0; i < i::Natives::GetBuiltinsCount(); ++i) {
+ i::DeleteArray(libraries[i]);
+ }
+ i::DeleteArray(libraries);
+ }
+ void DecompressNatives() {
+ for (int i = 0; i < i::Natives::GetBuiltinsCount(); ++i) {
Vitaly Repeshko 2011/06/06 10:08:23 Hmm, it seems annoying to repeat this code with th
mnaganov (inactive) 2011/06/06 13:40:18 Converted to API usage (as Soeren suggested), and
+ unsigned int decompressed_size = i::Natives::GetRawScriptSize(i);
+ libraries[i] = i::NewArray<char>(decompressed_size);
+ i::Vector<const i::byte> compressed = i::Natives::GetScriptSource(i);
+ int result =
+ BZ2_bzBuffToBuffDecompress(libraries[i],
+ &decompressed_size,
+ reinterpret_cast<char*>(
+ const_cast<i::byte*>(
+ compressed.start())),
+ compressed.length(),
+ 0, 1);
+ if (result != BZ_OK) {
+ fprintf(stderr, "libraries: bzip error code: %d\n", result);
+ exit(1);
+ }
+ i::Natives::SetRawScriptSource(
+ i, i::Vector<const char>(libraries[i], decompressed_size));
+ }
+ }
+
+ private:
+ char** libraries;
+};
#endif
@@ -281,6 +319,10 @@ int main(int argc, char** argv) {
i::FlagList::PrintHelp();
return !i::FLAG_help;
}
+#ifdef COMPRESS_STARTUP_DATA_BZ2
Søren Thygesen Gjesse 2011/06/06 09:22:01 Can't we use the normal V8 API here?
mnaganov (inactive) 2011/06/06 13:40:18 Done.
+ BZip2Decompressor natives_decompressor;
+ natives_decompressor.DecompressNatives();
+#endif
i::Serializer::Enable();
Persistent<Context> context = v8::Context::New();
ASSERT(!context.IsEmpty());

Powered by Google App Engine
This is Rietveld 408576698