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
7#ifndef V8_SNAPSHOT_H_
8#define V8_SNAPSHOT_H_
9
10namespace v8 {
11namespace internal {
12
13class Snapshot {
14 public:
15  // Initialize the Isolate from the internal snapshot. Returns false if no
16  // snapshot could be found.
17  static bool Initialize(Isolate* isolate);
18
19  static bool HaveASnapshotToStartFrom();
20
21  // Create a new context using the internal partial snapshot.
22  static Handle<Context> NewContextFromSnapshot(Isolate* isolate);
23
24  // These methods support COMPRESS_STARTUP_DATA_BZ2.
25  static const byte* data() { return data_; }
26  static int size() { return size_; }
27  static int raw_size() { return raw_size_; }
28  static void set_raw_data(const byte* raw_data) {
29    raw_data_ = raw_data;
30  }
31  static const byte* context_data() { return context_data_; }
32  static int context_size() { return context_size_; }
33  static int context_raw_size() { return context_raw_size_; }
34  static void set_context_raw_data(
35      const byte* context_raw_data) {
36    context_raw_data_ = context_raw_data;
37  }
38
39 private:
40  static const byte data_[];
41  static const byte* raw_data_;
42  static const byte context_data_[];
43  static const byte* context_raw_data_;
44  static const int new_space_used_;
45  static const int pointer_space_used_;
46  static const int data_space_used_;
47  static const int code_space_used_;
48  static const int map_space_used_;
49  static const int cell_space_used_;
50  static const int property_cell_space_used_;
51  static const int context_new_space_used_;
52  static const int context_pointer_space_used_;
53  static const int context_data_space_used_;
54  static const int context_code_space_used_;
55  static const int context_map_space_used_;
56  static const int context_cell_space_used_;
57  static const int context_property_cell_space_used_;
58  static const int size_;
59  static const int raw_size_;
60  static const int context_size_;
61  static const int context_raw_size_;
62
63  static void ReserveSpaceForLinkedInSnapshot(Deserializer* deserializer);
64
65  DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
66};
67
68#ifdef V8_USE_EXTERNAL_STARTUP_DATA
69void SetSnapshotFromFile(StartupData* snapshot_blob);
70#endif
71
72} }  // namespace v8::internal
73
74#endif  // V8_SNAPSHOT_H_
75