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

Unified Diff: src/api.cc

Issue 6901090: Add support for startup data (snapshot) compression. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index e6833530041b9794dbd0c63f34e5c6e26d33d0e9..203da5cc901cfd99d99d45a2d1966f9b6eecc550 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -311,6 +311,64 @@ static inline i::Isolate* EnterIsolateIfNeeded() {
}
+enum CompressedStartupDataItems {
+ kSnapshot = 0,
+ kSnapshotContext,
+ kCompressedStartupDataCount
+};
+
+int V8::GetCompressedStartupDataCount() {
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+ return kCompressedStartupDataCount;
+#else
+ return 0;
+#endif
+}
+
+
+void V8::GetCompressedStartupData(StartupData* compressed_data) {
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+ compressed_data->id = kSnapshot;
+ compressed_data->data = reinterpret_cast<const char*>(i::Snapshot::data());
+ compressed_data->compressed_size = i::Snapshot::size();
+ compressed_data->decompressed_size = i::Snapshot::decompressed_size();
+
+ ++compressed_data;
+ compressed_data->id = kSnapshotContext;
+ compressed_data->data =
+ reinterpret_cast<const char*>(i::Snapshot::context_data());
+ compressed_data->compressed_size = i::Snapshot::context_size();
+ compressed_data->decompressed_size = i::Snapshot::context_decompressed_size();
+#endif
+}
+
+
+void V8::SetDecompressedStartupData(StartupData* decompressed_data) {
+#ifdef COMPRESS_STARTUP_DATA_BZ2
+ for (int i = 0;
+ i < GetCompressedStartupDataCount();
+ ++i, ++decompressed_data) {
+ switch (decompressed_data->id) {
+ case kSnapshot:
+ ASSERT(i::Snapshot::decompressed_size() ==
+ decompressed_data->decompressed_size);
+ i::Snapshot::set_decompressed_data(
+ reinterpret_cast<const i::byte*>(decompressed_data->data));
+ break;
+ case kSnapshotContext:
+ ASSERT(i::Snapshot::context_decompressed_size() ==
+ decompressed_data->decompressed_size);
+ i::Snapshot::set_context_decompressed_data(
+ reinterpret_cast<const i::byte*>(decompressed_data->data));
+ break;
+ default:
+ UNREACHABLE();
+ }
+ }
+#endif
+}
+
+
void V8::SetFatalErrorHandler(FatalErrorCallback that) {
i::Isolate* isolate = EnterIsolateIfNeeded();
isolate->set_exception_behavior(that);

Powered by Google App Engine
This is Rietveld 408576698