1// Copyright 2017 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#ifndef V8_SNAPSHOT_CONTEXT_DESERIALIZER_H_
6#define V8_SNAPSHOT_CONTEXT_DESERIALIZER_H_
7
8#include "src/snapshot/deserializer.h"
9#include "src/snapshot/snapshot-data.h"
10#include "src/snapshot/snapshot.h"
11
12namespace v8 {
13namespace internal {
14
15class Context;
16class Isolate;
17
18// Deserializes the context-dependent object graph rooted at a given object.
19// The ContextDeserializer is not expected to deserialize any code objects.
20class V8_EXPORT_PRIVATE ContextDeserializer final
21    : public Deserializer<Isolate> {
22 public:
23  static MaybeHandle<Context> DeserializeContext(
24      Isolate* isolate, const SnapshotData* data, bool can_rehash,
25      Handle<JSGlobalProxy> global_proxy,
26      v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
27
28 private:
29  explicit ContextDeserializer(Isolate* isolate, const SnapshotData* data,
30                               bool can_rehash)
31      : Deserializer(isolate, data->Payload(), data->GetMagicNumber(), false,
32                     can_rehash) {}
33
34  // Deserialize a single object and the objects reachable from it.
35  MaybeHandle<Object> Deserialize(
36      Isolate* isolate, Handle<JSGlobalProxy> global_proxy,
37      v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
38
39  void DeserializeEmbedderFields(
40      v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
41
42  void SetupOffHeapArrayBufferBackingStores();
43};
44
45}  // namespace internal
46}  // namespace v8
47
48#endif  // V8_SNAPSHOT_CONTEXT_DESERIALIZER_H_
49