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

Side by Side Diff: src/snapshot.h

Issue 1041743002: Serializer: move to a subfolder and clean up includes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: removed OWNERS Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/serialize.cc ('k') | src/snapshot-common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/isolate.h"
6 #include "src/serialize.h"
7
8 #ifndef V8_SNAPSHOT_H_
9 #define V8_SNAPSHOT_H_
10
11 namespace v8 {
12 namespace internal {
13
14 class Snapshot : public AllStatic {
15 public:
16 class Metadata {
17 public:
18 explicit Metadata(uint32_t data = 0) : data_(data) {}
19 bool embeds_script() { return EmbedsScriptBits::decode(data_); }
20 void set_embeds_script(bool v) {
21 data_ = EmbedsScriptBits::update(data_, v);
22 }
23
24 uint32_t& RawValue() { return data_; }
25
26 private:
27 class EmbedsScriptBits : public BitField<bool, 0, 1> {};
28 uint32_t data_;
29 };
30
31 // Initialize the Isolate from the internal snapshot. Returns false if no
32 // snapshot could be found.
33 static bool Initialize(Isolate* isolate);
34 // Create a new context using the internal partial snapshot.
35 static MaybeHandle<Context> NewContextFromSnapshot(
36 Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
37 Handle<FixedArray>* outdated_contexts_out);
38
39 static bool HaveASnapshotToStartFrom(Isolate* isolate) {
40 // Do not use snapshots if the isolate is used to create snapshots.
41 return isolate->snapshot_blob() != NULL;
42 }
43
44 static bool EmbedsScript(Isolate* isolate);
45
46 static uint32_t SizeOfFirstPage(Isolate* isolate, AllocationSpace space);
47
48
49 // To be implemented by the snapshot source.
50 static const v8::StartupData* DefaultSnapshotBlob();
51
52 static v8::StartupData CreateSnapshotBlob(
53 const StartupSerializer& startup_ser,
54 const PartialSerializer& context_ser, Snapshot::Metadata metadata);
55
56 #ifdef DEBUG
57 static bool SnapshotIsValid(v8::StartupData* snapshot_blob);
58 #endif // DEBUG
59
60 private:
61 static Vector<const byte> ExtractStartupData(const v8::StartupData* data);
62 static Vector<const byte> ExtractContextData(const v8::StartupData* data);
63 static Metadata ExtractMetadata(const v8::StartupData* data);
64
65 // Snapshot blob layout:
66 // [0] metadata
67 // [1 - 6] pre-calculated first page sizes for paged spaces
68 // [7] serialized start up data length
69 // ... serialized start up data
70 // ... serialized context data
71
72 static const int kNumPagedSpaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1;
73
74 static const int kMetadataOffset = 0;
75 static const int kFirstPageSizesOffset = kMetadataOffset + kInt32Size;
76 static const int kStartupLengthOffset =
77 kFirstPageSizesOffset + kNumPagedSpaces * kInt32Size;
78 static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size;
79
80 static int ContextOffset(int startup_length) {
81 return kStartupDataOffset + startup_length;
82 }
83
84 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
85 };
86
87 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
88 void SetSnapshotFromFile(StartupData* snapshot_blob);
89 #endif
90
91 } } // namespace v8::internal
92
93 #endif // V8_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | src/snapshot-common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698