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 | 6 |
7 #ifndef V8_SNAPSHOT_H_ | 7 #ifndef V8_SNAPSHOT_H_ |
8 #define V8_SNAPSHOT_H_ | 8 #define V8_SNAPSHOT_H_ |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 class Snapshot { | 13 class Snapshot { |
14 public: | 14 public: |
15 // Initialize the VM from the internal snapshot. Returns false if no snapshot | 15 // Initialize the VM from the given snapshot file. If snapshot_file is |
| 16 // NULL, use the internal snapshot instead. Returns false if no snapshot |
16 // could be found. | 17 // could be found. |
17 static bool Initialize(); | 18 static bool Initialize(const char* snapshot_file = NULL); |
18 | 19 |
19 static bool HaveASnapshotToStartFrom(); | 20 static bool HaveASnapshotToStartFrom(); |
20 | 21 |
21 // Create a new context using the internal partial snapshot. | 22 // Create a new context using the internal partial snapshot. |
22 static Handle<Context> NewContextFromSnapshot(Isolate* isolate); | 23 static Handle<Context> NewContextFromSnapshot(Isolate* isolate); |
23 | 24 |
24 // These methods support COMPRESS_STARTUP_DATA_BZ2. | 25 // Returns whether or not the snapshot is enabled. |
| 26 static bool IsEnabled() { return size_ != 0; } |
| 27 |
| 28 // Write snapshot to the given file. Returns true if snapshot was written |
| 29 // successfully. |
| 30 static bool WriteToFile(const char* snapshot_file); |
| 31 |
25 static const byte* data() { return data_; } | 32 static const byte* data() { return data_; } |
26 static int size() { return size_; } | 33 static int size() { return size_; } |
27 static int raw_size() { return raw_size_; } | 34 static int raw_size() { return raw_size_; } |
28 static void set_raw_data(const byte* raw_data) { | 35 static void set_raw_data(const byte* raw_data) { |
29 raw_data_ = raw_data; | 36 raw_data_ = raw_data; |
30 } | 37 } |
31 static const byte* context_data() { return context_data_; } | 38 static const byte* context_data() { return context_data_; } |
32 static int context_size() { return context_size_; } | 39 static int context_size() { return context_size_; } |
33 static int context_raw_size() { return context_raw_size_; } | 40 static int context_raw_size() { return context_raw_size_; } |
34 static void set_context_raw_data( | 41 static void set_context_raw_data( |
(...skipping 23 matching lines...) Expand all Loading... |
58 static const int size_; | 65 static const int size_; |
59 static const int raw_size_; | 66 static const int raw_size_; |
60 static const int context_size_; | 67 static const int context_size_; |
61 static const int context_raw_size_; | 68 static const int context_raw_size_; |
62 | 69 |
63 static void ReserveSpaceForLinkedInSnapshot(Deserializer* deserializer); | 70 static void ReserveSpaceForLinkedInSnapshot(Deserializer* deserializer); |
64 | 71 |
65 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); | 72 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); |
66 }; | 73 }; |
67 | 74 |
68 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
69 void SetSnapshotFromFile(StartupData* snapshot_blob); | |
70 #endif | |
71 | |
72 } } // namespace v8::internal | 75 } } // namespace v8::internal |
73 | 76 |
74 #endif // V8_SNAPSHOT_H_ | 77 #endif // V8_SNAPSHOT_H_ |
OLD | NEW |