OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_SNAPSHOT_SNAPSHOT_H_ | 5 #ifndef V8_SNAPSHOT_SNAPSHOT_H_ |
6 #define V8_SNAPSHOT_SNAPSHOT_H_ | 6 #define V8_SNAPSHOT_SNAPSHOT_H_ |
7 | 7 |
8 #include "src/snapshot/serialize.h" | 8 #include "src/snapshot/partial-serializer.h" |
| 9 #include "src/snapshot/startup-serializer.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 | 13 |
13 // Forward declarations. | 14 // Forward declarations. |
14 class Isolate; | 15 class Isolate; |
15 class PartialSerializer; | 16 class PartialSerializer; |
16 class StartupSerializer; | 17 class StartupSerializer; |
17 | 18 |
18 class Snapshot : public AllStatic { | 19 class Snapshot : public AllStatic { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return kStartupDataOffset + startup_length; | 82 return kStartupDataOffset + startup_length; |
82 } | 83 } |
83 | 84 |
84 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); | 85 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); |
85 }; | 86 }; |
86 | 87 |
87 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 88 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
88 void SetSnapshotFromFile(StartupData* snapshot_blob); | 89 void SetSnapshotFromFile(StartupData* snapshot_blob); |
89 #endif | 90 #endif |
90 | 91 |
| 92 // Wrapper around reservation sizes and the serialization payload. |
| 93 class SnapshotData : public SerializedData { |
| 94 public: |
| 95 // Used when producing. |
| 96 explicit SnapshotData(const Serializer& ser); |
| 97 |
| 98 // Used when consuming. |
| 99 explicit SnapshotData(const Vector<const byte> snapshot) |
| 100 : SerializedData(const_cast<byte*>(snapshot.begin()), snapshot.length()) { |
| 101 CHECK(IsSane()); |
| 102 } |
| 103 |
| 104 Vector<const Reservation> Reservations() const; |
| 105 Vector<const byte> Payload() const; |
| 106 |
| 107 Vector<const byte> RawData() const { |
| 108 return Vector<const byte>(data_, size_); |
| 109 } |
| 110 |
| 111 private: |
| 112 bool IsSane(); |
| 113 |
| 114 // The data header consists of uint32_t-sized entries: |
| 115 // [0] magic number and external reference count |
| 116 // [1] version hash |
| 117 // [2] number of reservation size entries |
| 118 // [3] payload length |
| 119 // ... reservations |
| 120 // ... serialized payload |
| 121 static const int kCheckSumOffset = kMagicNumberOffset + kInt32Size; |
| 122 static const int kNumReservationsOffset = kCheckSumOffset + kInt32Size; |
| 123 static const int kPayloadLengthOffset = kNumReservationsOffset + kInt32Size; |
| 124 static const int kHeaderSize = kPayloadLengthOffset + kInt32Size; |
| 125 }; |
| 126 |
91 } // namespace internal | 127 } // namespace internal |
92 } // namespace v8 | 128 } // namespace v8 |
93 | 129 |
94 #endif // V8_SNAPSHOT_SNAPSHOT_H_ | 130 #endif // V8_SNAPSHOT_SNAPSHOT_H_ |
OLD | NEW |