1 // Copyright 2016 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_PARTIAL_SERIALIZER_H_
6 #define V8_SNAPSHOT_PARTIAL_SERIALIZER_H_
7 
8 #include "src/address-map.h"
9 #include "src/snapshot/serializer.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 class StartupSerializer;
15 
16 class PartialSerializer : public Serializer<> {
17  public:
18   PartialSerializer(Isolate* isolate, StartupSerializer* startup_serializer,
19                     v8::SerializeEmbedderFieldsCallback callback);
20 
21   ~PartialSerializer() override;
22 
23   // Serialize the objects reachable from a single object pointer.
24   void Serialize(Context** o, bool include_global_proxy);
25 
can_be_rehashed()26   bool can_be_rehashed() const { return can_be_rehashed_; }
27 
28  private:
29   void SerializeObject(HeapObject* o, HowToCode how_to_code,
30                        WhereToPoint where_to_point, int skip) override;
31 
32   bool ShouldBeInThePartialSnapshotCache(HeapObject* o);
33 
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   // Indicates whether we only serialized hash tables that we can rehash.
42   // TODO(yangguo): generalize rehashing, and remove this flag.
43   bool can_be_rehashed_;
44   Context* context_;
45   DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
46 };
47 
48 }  // namespace internal
49 }  // namespace v8
50 
51 #endif  // V8_SNAPSHOT_PARTIAL_SERIALIZER_H_
52