partial-serializer.h 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
// 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"
#include "src/snapshot/serializer.h"

namespace v8 {
namespace internal {

14 15
class StartupSerializer;

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

  ~PartialSerializer() override;

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

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

28 29 30 31 32 33
 private:
  void SerializeObject(HeapObject* o, HowToCode how_to_code,
                       WhereToPoint where_to_point, int skip) override;

  bool ShouldBeInThePartialSnapshotCache(HeapObject* o);

34
  void SerializeEmbedderFields();
35

36
  void CheckRehashability(HeapObject* obj);
37

38
  StartupSerializer* startup_serializer_;
39
  std::vector<JSObject*> embedder_field_holders_;
40
  v8::SerializeEmbedderFieldsCallback serialize_embedder_fields_;
41 42 43
  // Indicates whether we only serialized hash tables that we can rehash.
  // TODO(yangguo): generalize rehashing, and remove this flag.
  bool can_be_rehashed_;
44
  Context* context_;
45 46 47 48 49 50 51
  DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_SNAPSHOT_PARTIAL_SERIALIZER_H_