partial-serializer.h 1.56 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_SNAPSHOT_PARTIAL_SERIALIZER_H_
#define V8_SNAPSHOT_PARTIAL_SERIALIZER_H_

#include "src/address-map.h"
9
#include "src/contexts.h"
10 11 12 13 14
#include "src/snapshot/serializer.h"

namespace v8 {
namespace internal {

15 16
class StartupSerializer;

17
class V8_EXPORT_PRIVATE PartialSerializer : public Serializer {
18
 public:
19
  PartialSerializer(Isolate* isolate, StartupSerializer* startup_serializer,
20
                    v8::SerializeEmbedderFieldsCallback callback);
21 22 23 24

  ~PartialSerializer() override;

  // Serialize the objects reachable from a single object pointer.
25
  void Serialize(Context* o, bool include_global_proxy);
26

27 28
  bool can_be_rehashed() const { return can_be_rehashed_; }

29
 private:
30
  void SerializeObject(HeapObject o) override;
31

32
  bool ShouldBeInThePartialSnapshotCache(HeapObject o);
33

34
  bool SerializeJSObjectWithEmbedderFields(Object obj);
35

36
  void CheckRehashability(HeapObject obj);
37

38
  StartupSerializer* startup_serializer_;
39
  v8::SerializeEmbedderFieldsCallback serialize_embedder_fields_;
40 41 42
  // Indicates whether we only serialized hash tables that we can rehash.
  // TODO(yangguo): generalize rehashing, and remove this flag.
  bool can_be_rehashed_;
43
  Context context_;
44 45 46

  // Used to store serialized data for embedder fields.
  SnapshotByteSink embedder_fields_sink_;
47 48 49 50 51 52 53
  DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_SNAPSHOT_PARTIAL_SERIALIZER_H_