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

Unified Diff: src/snapshot/snapshot.h

Issue 1751863002: [serializer] split up src/snapshot/serialize.* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 10 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/snapshot/snapshot.h
diff --git a/src/snapshot/snapshot.h b/src/snapshot/snapshot.h
index d99f118bff2708cd79a7ea31c229505ad4959d7b..c648d7595e2e25daa54ab7519a6d1c255ff568c4 100644
--- a/src/snapshot/snapshot.h
+++ b/src/snapshot/snapshot.h
@@ -5,7 +5,8 @@
#ifndef V8_SNAPSHOT_SNAPSHOT_H_
#define V8_SNAPSHOT_SNAPSHOT_H_
-#include "src/snapshot/serialize.h"
+#include "src/snapshot/partial-serializer.h"
+#include "src/snapshot/startup-serializer.h"
namespace v8 {
namespace internal {
@@ -88,6 +89,41 @@ class Snapshot : public AllStatic {
void SetSnapshotFromFile(StartupData* snapshot_blob);
#endif
+// Wrapper around reservation sizes and the serialization payload.
+class SnapshotData : public SerializedData {
+ public:
+ // Used when producing.
+ explicit SnapshotData(const Serializer& ser);
+
+ // Used when consuming.
+ explicit SnapshotData(const Vector<const byte> snapshot)
+ : SerializedData(const_cast<byte*>(snapshot.begin()), snapshot.length()) {
+ CHECK(IsSane());
+ }
+
+ Vector<const Reservation> Reservations() const;
+ Vector<const byte> Payload() const;
+
+ Vector<const byte> RawData() const {
+ return Vector<const byte>(data_, size_);
+ }
+
+ private:
+ bool IsSane();
+
+ // The data header consists of uint32_t-sized entries:
+ // [0] magic number and external reference count
+ // [1] version hash
+ // [2] number of reservation size entries
+ // [3] payload length
+ // ... reservations
+ // ... serialized payload
+ static const int kCheckSumOffset = kMagicNumberOffset + kInt32Size;
+ static const int kNumReservationsOffset = kCheckSumOffset + kInt32Size;
+ static const int kPayloadLengthOffset = kNumReservationsOffset + kInt32Size;
+ static const int kHeaderSize = kPayloadLengthOffset + kInt32Size;
+};
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698