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 #include "src/isolate.h" | 5 #include "src/isolate.h" |
| 6 #include "src/serialize.h" |
6 | 7 |
7 #ifndef V8_SNAPSHOT_H_ | 8 #ifndef V8_SNAPSHOT_H_ |
8 #define V8_SNAPSHOT_H_ | 9 #define V8_SNAPSHOT_H_ |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 | 13 |
13 class Snapshot : public AllStatic { | 14 class Snapshot : public AllStatic { |
14 public: | 15 public: |
15 class Metadata { | 16 class Metadata { |
(...skipping 16 matching lines...) Expand all Loading... |
32 static bool Initialize(Isolate* isolate); | 33 static bool Initialize(Isolate* isolate); |
33 // Create a new context using the internal partial snapshot. | 34 // Create a new context using the internal partial snapshot. |
34 static MaybeHandle<Context> NewContextFromSnapshot( | 35 static MaybeHandle<Context> NewContextFromSnapshot( |
35 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, | 36 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, |
36 Handle<FixedArray>* outdated_contexts_out); | 37 Handle<FixedArray>* outdated_contexts_out); |
37 | 38 |
38 static bool HaveASnapshotToStartFrom(); | 39 static bool HaveASnapshotToStartFrom(); |
39 | 40 |
40 static bool EmbedsScript(); | 41 static bool EmbedsScript(); |
41 | 42 |
| 43 static uint32_t SizeOfFirstPage(AllocationSpace space); |
| 44 |
42 // To be implemented by the snapshot source. | 45 // To be implemented by the snapshot source. |
43 static const v8::StartupData SnapshotBlob(); | 46 static const v8::StartupData SnapshotBlob(); |
44 | 47 |
45 static v8::StartupData CreateSnapshotBlob( | 48 static v8::StartupData CreateSnapshotBlob( |
46 const Vector<const byte> startup_data, | 49 const StartupSerializer& startup_ser, |
47 const Vector<const byte> context_data, Metadata metadata); | 50 const PartialSerializer& context_ser, Snapshot::Metadata metadata); |
48 | 51 |
49 #ifdef DEBUG | 52 #ifdef DEBUG |
50 static bool SnapshotIsValid(v8::StartupData* snapshot_blob); | 53 static bool SnapshotIsValid(v8::StartupData* snapshot_blob); |
51 #endif // DEBUG | 54 #endif // DEBUG |
52 | 55 |
53 private: | 56 private: |
54 static Vector<const byte> ExtractStartupData(const v8::StartupData* data); | 57 static Vector<const byte> ExtractStartupData(const v8::StartupData* data); |
55 static Vector<const byte> ExtractContextData(const v8::StartupData* data); | 58 static Vector<const byte> ExtractContextData(const v8::StartupData* data); |
56 static Metadata ExtractMetadata(const v8::StartupData* data); | 59 static Metadata ExtractMetadata(const v8::StartupData* data); |
57 | 60 |
| 61 // Snapshot blob layout: |
| 62 // [0] metadata |
| 63 // [1 - 6] pre-calculated first page sizes for paged spaces |
| 64 // [7] serialized start up data length |
| 65 // ... serialized start up data |
| 66 // ... serialized context data |
| 67 |
| 68 static const int kNumPagedSpaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1; |
| 69 |
58 static const int kMetadataOffset = 0; | 70 static const int kMetadataOffset = 0; |
59 static const int kStartupLengthOffset = kMetadataOffset + kInt32Size; | 71 static const int kFirstPageSizesOffset = kMetadataOffset + kInt32Size; |
| 72 static const int kStartupLengthOffset = |
| 73 kFirstPageSizesOffset + kNumPagedSpaces * kInt32Size; |
60 static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size; | 74 static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size; |
61 | 75 |
62 static int ContextOffset(int startup_length) { | 76 static int ContextOffset(int startup_length) { |
63 return kStartupDataOffset + startup_length; | 77 return kStartupDataOffset + startup_length; |
64 } | 78 } |
65 | 79 |
66 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); | 80 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); |
67 }; | 81 }; |
68 | 82 |
69 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 83 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
70 void SetSnapshotFromFile(StartupData* snapshot_blob); | 84 void SetSnapshotFromFile(StartupData* snapshot_blob); |
71 #endif | 85 #endif |
72 | 86 |
73 } } // namespace v8::internal | 87 } } // namespace v8::internal |
74 | 88 |
75 #endif // V8_SNAPSHOT_H_ | 89 #endif // V8_SNAPSHOT_H_ |
OLD | NEW |