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

Unified Diff: src/snapshot-common.cc

Issue 787033002: Use same blob format for internal and external snapshots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments 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.h ('k') | src/snapshot-empty.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot-common.cc
diff --git a/src/snapshot-common.cc b/src/snapshot-common.cc
index f06f38a19983665b1f233251a3a0692169601688..80463542665ff7e2ed23947731fed7684da17d7a 100644
--- a/src/snapshot-common.cc
+++ b/src/snapshot-common.cc
@@ -14,34 +14,56 @@
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);
}
-bool Snapshot::HaveASnapshotToStartFrom() {
- return size_ != 0;
+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;
}
Handle<Context> Snapshot::NewContextFromSnapshot(Isolate* isolate) {
- if (context_size_ == 0) return Handle<Context>();
+ if (!HaveASnapshotToStartFrom()) return Handle<Context>();
- SnapshotData snapshot_data(context_data_, context_size_);
+ SnapshotData snapshot_data(ContextSnapshot());
Deserializer deserializer(&snapshot_data);
Object* root;
deserializer.DeserializePartial(isolate, &root);
@@ -49,15 +71,4 @@ Handle<Context> Snapshot::NewContextFromSnapshot(Isolate* isolate) {
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
« no previous file with comments | « src/snapshot.h ('k') | src/snapshot-empty.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698