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

Unified Diff: src/snapshot/snapshot.h

Issue 2055203002: [snapshot] support multiple contexts in the same snapshot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@sinkmember
Patch Set: fix test. again. Created 4 years, 6 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
« no previous file with comments | « src/snapshot/partial-serializer.cc ('k') | src/snapshot/snapshot-common.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/snapshot.h
diff --git a/src/snapshot/snapshot.h b/src/snapshot/snapshot.h
index 479265c4d2471f14746afb07710a31ed067582ff..e332967eeebd37403688e8fd69444ad2ff57fcd2 100644
--- a/src/snapshot/snapshot.h
+++ b/src/snapshot/snapshot.h
@@ -16,6 +16,41 @@ class Isolate;
class PartialSerializer;
class StartupSerializer;
+// Wrapper around reservation sizes and the serialization payload.
+class SnapshotData : public SerializedData {
+ public:
+ // Used when producing.
+ explicit SnapshotData(const Serializer* serializer);
+
+ // 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;
+};
+
class Snapshot : public AllStatic {
public:
// Initialize the Isolate from the internal snapshot. Returns false if no
@@ -23,7 +58,8 @@ class Snapshot : public AllStatic {
static bool Initialize(Isolate* isolate);
// Create a new context using the internal partial snapshot.
static MaybeHandle<Context> NewContextFromSnapshot(
- Isolate* isolate, Handle<JSGlobalProxy> global_proxy);
+ Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
+ size_t context_index);
static bool HaveASnapshotToStartFrom(Isolate* isolate);
@@ -36,32 +72,44 @@ class Snapshot : public AllStatic {
static const v8::StartupData* DefaultSnapshotBlob();
static v8::StartupData CreateSnapshotBlob(
- const StartupSerializer* startup_serializer,
- const PartialSerializer* context_serializer);
+ const SnapshotData* startup_snapshot,
+ const List<SnapshotData*>* context_snapshots);
#ifdef DEBUG
static bool SnapshotIsValid(v8::StartupData* snapshot_blob);
#endif // DEBUG
private:
+ static int ExtractNumContexts(const v8::StartupData* data);
static Vector<const byte> ExtractStartupData(const v8::StartupData* data);
- static Vector<const byte> ExtractContextData(const v8::StartupData* data);
+ static Vector<const byte> ExtractContextData(const v8::StartupData* data,
+ int index);
// Snapshot blob layout:
// [0 - 5] pre-calculated first page sizes for paged spaces
- // [6] serialized start up data length
- // ... serialized start up data
- // ... serialized context data
+ // [6] number of contexts N
+ // [7] offset to context 0
+ // [8] offset to context 1
+ // ...
+ // ... offset to context N - 1
+ // ... startup snapshot data
+ // ... context 0 snapshot data
+ // ... context 1 snapshot data
static const int kNumPagedSpaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1;
static const int kFirstPageSizesOffset = 0;
- static const int kStartupLengthOffset =
+ static const int kNumberOfContextsOffset =
kFirstPageSizesOffset + kNumPagedSpaces * kInt32Size;
- static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size;
+ static const int kFirstContextOffsetOffset =
+ kNumberOfContextsOffset + kInt32Size;
+
+ static int StartupSnapshotOffset(int num_contexts) {
+ return kFirstContextOffsetOffset + num_contexts * kInt32Size;
+ }
- static int ContextOffset(int startup_length) {
- return kStartupDataOffset + startup_length;
+ static int ContextSnapshotOffsetOffset(int index) {
+ return kFirstContextOffsetOffset + index * kInt32Size;
}
DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
@@ -71,41 +119,6 @@ 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* serializer);
-
- // 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
« no previous file with comments | « src/snapshot/partial-serializer.cc ('k') | src/snapshot/snapshot-common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698