Index: src/snapshot-common.cc |
diff --git a/src/snapshot-common.cc b/src/snapshot-common.cc |
index 80463542665ff7e2ed23947731fed7684da17d7a..f06f38a19983665b1f233251a3a0692169601688 100644 |
--- a/src/snapshot-common.cc |
+++ b/src/snapshot-common.cc |
@@ -14,56 +14,34 @@ |
namespace v8 { |
namespace internal { |
-bool Snapshot::HaveASnapshotToStartFrom() { |
- return SnapshotBlob().data != NULL; |
+ |
+bool Snapshot::Initialize(Isolate* isolate) { |
+ if (size_ > 0) { |
+ base::ElapsedTimer timer; |
+ if (FLAG_profile_deserialization) timer.Start(); |
+ |
+ SnapshotData snapshot_data(data_, 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; |
+ } |
+ return false; |
} |
-const Vector<const byte> Snapshot::StartupSnapshot() { |
- DCHECK(HaveASnapshotToStartFrom()); |
- const v8::StartupData blob = SnapshotBlob(); |
- SnapshotByteSource source(blob.data, blob.raw_size); |
- const byte* data; |
- int length; |
- bool success = source.GetBlob(&data, &length); |
- CHECK(success); |
- return Vector<const byte>(data, length); |
-} |
- |
- |
-const Vector<const byte> Snapshot::ContextSnapshot() { |
- DCHECK(HaveASnapshotToStartFrom()); |
- const v8::StartupData blob = SnapshotBlob(); |
- SnapshotByteSource source(blob.data, blob.raw_size); |
- const byte* data; |
- int length; |
- bool success = source.GetBlob(&data, &length); |
- success &= source.GetBlob(&data, &length); |
- CHECK(success); |
- return Vector<const byte>(data, length); |
-} |
- |
- |
-bool Snapshot::Initialize(Isolate* isolate) { |
- if (!HaveASnapshotToStartFrom()) return false; |
- base::ElapsedTimer timer; |
- if (FLAG_profile_deserialization) timer.Start(); |
- |
- SnapshotData snapshot_data(StartupSnapshot()); |
- 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; |
+bool Snapshot::HaveASnapshotToStartFrom() { |
+ return size_ != 0; |
} |
Handle<Context> Snapshot::NewContextFromSnapshot(Isolate* isolate) { |
- if (!HaveASnapshotToStartFrom()) return Handle<Context>(); |
+ if (context_size_ == 0) return Handle<Context>(); |
- SnapshotData snapshot_data(ContextSnapshot()); |
+ SnapshotData snapshot_data(context_data_, context_size_); |
Deserializer deserializer(&snapshot_data); |
Object* root; |
deserializer.DeserializePartial(isolate, &root); |
@@ -71,4 +49,15 @@ |
return Handle<Context>(Context::cast(root)); |
} |
+ |
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA |
+// Dummy implementations of Set*FromFile(..) APIs. |
+// |
+// These are meant for use with snapshot-external.cc. Should this file |
+// be compiled with those options we just supply these dummy implementations |
+// below. This happens when compiling the mksnapshot utility. |
+void SetNativesFromFile(StartupData* data) { CHECK(false); } |
+void SetSnapshotFromFile(StartupData* data) { CHECK(false); } |
+#endif // V8_USE_EXTERNAL_STARTUP_DATA |
+ |
} } // namespace v8::internal |