Index: src/snapshot-external.cc |
diff --git a/src/snapshot-external.cc b/src/snapshot-external.cc |
index 17f3d718975155432fd606d1c4ed19360d591b23..c232b2eadaf0bd44c9ef1e80395411ef33c8c38e 100644 |
--- a/src/snapshot-external.cc |
+++ b/src/snapshot-external.cc |
@@ -10,70 +10,32 @@ |
#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; |
+#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::HaveASnapshotToStartFrom() { |
- return snapshot_impl_ != NULL; |
-} |
- |
- |
-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; |
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); |
+ external_startup_blob = snapshot_blob; |
+ |
+ // Validate snapshot blob. |
+ DCHECK(!Snapshot::StartupSnapshot().is_empty()); |
+ DCHECK(!Snapshot::ContextSnapshot().is_empty()); |
+} |
+ |
- 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); |
+const v8::StartupData Snapshot::SnapshotBlob() { |
+ return *external_startup_blob; |
} |
} } // namespace v8::internal |