blob: 25a07cdd97766eeadf00798fc8b38573a9910cad [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2006-2008 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
Ben Murdochb8a8cc12014-11-26 15:28:44 +00005#include "src/isolate.h"
Steve Block44f0eee2011-05-26 01:26:41 +01006
Steve Blocka7e24c12009-10-30 11:49:00 +00007#ifndef V8_SNAPSHOT_H_
8#define V8_SNAPSHOT_H_
9
10namespace v8 {
11namespace internal {
12
Emily Bernierd0a1eb72015-03-24 16:35:39 -040013class Snapshot : public AllStatic {
Steve Blocka7e24c12009-10-30 11:49:00 +000014 public:
Ben Murdochb8a8cc12014-11-26 15:28:44 +000015 // Initialize the Isolate from the internal snapshot. Returns false if no
16 // snapshot could be found.
17 static bool Initialize(Isolate* isolate);
Andrei Popescu31002712010-02-23 13:46:05 +000018 // Create a new context using the internal partial snapshot.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000019 static Handle<Context> NewContextFromSnapshot(Isolate* isolate);
Andrei Popescu31002712010-02-23 13:46:05 +000020
Emily Bernierd0a1eb72015-03-24 16:35:39 -040021 static bool HaveASnapshotToStartFrom();
22
23 // To be implemented by the snapshot source.
24 static const v8::StartupData SnapshotBlob();
25
26 static v8::StartupData CreateSnapshotBlob(
27 const Vector<const byte> startup_data,
28 const Vector<const byte> context_data);
29
30 static Vector<const byte> ExtractStartupData(const v8::StartupData* data);
31 static Vector<const byte> ExtractContextData(const v8::StartupData* data);
Ben Murdoch257744e2011-11-30 15:57:28 +000032
Steve Blocka7e24c12009-10-30 11:49:00 +000033 private:
Steve Blocka7e24c12009-10-30 11:49:00 +000034 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
35};
36
Ben Murdochb8a8cc12014-11-26 15:28:44 +000037#ifdef V8_USE_EXTERNAL_STARTUP_DATA
38void SetSnapshotFromFile(StartupData* snapshot_blob);
39#endif
40
Steve Blocka7e24c12009-10-30 11:49:00 +000041} } // namespace v8::internal
42
43#endif // V8_SNAPSHOT_H_