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

Unified Diff: src/snapshot-external.cc

Issue 791723004: Reland "Use same blob format for internal and external snapshots." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 6 years 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 | « src/snapshot-empty.cc ('k') | src/snapshot-source-sink.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot-external.cc
diff --git a/src/snapshot-external.cc b/src/snapshot-external.cc
index 17f3d718975155432fd606d1c4ed19360d591b23..6a89d42a8ece8cd476ac2f8c0bb239d4429c3996 100644
--- a/src/snapshot-external.cc
+++ b/src/snapshot-external.cc
@@ -10,70 +10,29 @@
#include "src/snapshot-source-sink.h"
#include "src/v8.h" // for V8::Initialize
-namespace v8 {
-namespace internal {
-
-
-struct SnapshotImpl {
- public:
- const byte* data;
- int size;
- const byte* context_data;
- int context_size;
-};
-
-
-static SnapshotImpl* snapshot_impl_ = NULL;
-
-
-bool Snapshot::HaveASnapshotToStartFrom() {
- return snapshot_impl_ != NULL;
-}
+#ifndef V8_USE_EXTERNAL_STARTUP_DATA
+#error snapshot-external.cc is used only for the external snapshot build.
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
-bool Snapshot::Initialize(Isolate* isolate) {
- if (!HaveASnapshotToStartFrom()) return false;
- base::ElapsedTimer timer;
- if (FLAG_profile_deserialization) timer.Start();
- SnapshotData snapshot_data(snapshot_impl_->data, snapshot_impl_->size);
- Deserializer deserializer(&snapshot_data);
- bool success = isolate->Init(&deserializer);
- if (FLAG_profile_deserialization) {
- double ms = timer.Elapsed().InMillisecondsF();
- PrintF("[Snapshot loading and deserialization took %0.3f ms]\n", ms);
- }
- return success;
-}
-
-
-Handle<Context> Snapshot::NewContextFromSnapshot(Isolate* isolate) {
- if (!HaveASnapshotToStartFrom()) return Handle<Context>();
-
- SnapshotData snapshot_data(snapshot_impl_->context_data,
- snapshot_impl_->context_size);
- Deserializer deserializer(&snapshot_data);
- Object* root;
- deserializer.DeserializePartial(isolate, &root);
- CHECK(root->IsContext());
- return Handle<Context>(Context::cast(root));
-}
+namespace v8 {
+namespace internal {
+static v8::StartupData external_startup_blob = {NULL, 0};
vogelheim 2014/12/10 11:41:58 Hmm... does this count as a static initializer, wh
void SetSnapshotFromFile(StartupData* snapshot_blob) {
DCHECK(snapshot_blob);
DCHECK(snapshot_blob->data);
DCHECK(snapshot_blob->raw_size > 0);
- DCHECK(!snapshot_impl_);
+ DCHECK(!external_startup_blob.data);
+ external_startup_blob = *snapshot_blob;
- snapshot_impl_ = new SnapshotImpl;
- SnapshotByteSource source(reinterpret_cast<const byte*>(snapshot_blob->data),
- snapshot_blob->raw_size);
- bool success = source.GetBlob(&snapshot_impl_->data,
- &snapshot_impl_->size);
- success &= source.GetBlob(&snapshot_impl_->context_data,
- &snapshot_impl_->context_size);
- DCHECK(success);
+ // Validate snapshot blob.
+ DCHECK(!Snapshot::StartupSnapshot().is_empty());
+ DCHECK(!Snapshot::ContextSnapshot().is_empty());
}
+
+const v8::StartupData Snapshot::SnapshotBlob() { return external_startup_blob; }
} } // namespace v8::internal
« no previous file with comments | « src/snapshot-empty.cc ('k') | src/snapshot-source-sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698