| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_SNAPSHOT_STARTUP_SERIALIZER_H_ | 5 #ifndef V8_SNAPSHOT_STARTUP_SERIALIZER_H_ |
| 6 #define V8_SNAPSHOT_STARTUP_SERIALIZER_H_ | 6 #define V8_SNAPSHOT_STARTUP_SERIALIZER_H_ |
| 7 | 7 |
| 8 #include <bitset> | 8 #include <bitset> |
| 9 #include "include/v8.h" |
| 9 #include "src/snapshot/serializer.h" | 10 #include "src/snapshot/serializer.h" |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 | 14 |
| 14 class StartupSerializer : public Serializer { | 15 class StartupSerializer : public Serializer { |
| 15 public: | 16 public: |
| 16 enum FunctionCodeHandling { CLEAR_FUNCTION_CODE, KEEP_FUNCTION_CODE }; | |
| 17 | |
| 18 StartupSerializer( | 17 StartupSerializer( |
| 19 Isolate* isolate, SnapshotByteSink* sink, | 18 Isolate* isolate, SnapshotByteSink* sink, |
| 20 FunctionCodeHandling function_code_handling = CLEAR_FUNCTION_CODE); | 19 v8::SnapshotCreator::FunctionCodeHandling function_code_handling); |
| 21 ~StartupSerializer() override; | 20 ~StartupSerializer() override; |
| 22 | 21 |
| 23 // Serialize the current state of the heap. The order is: | 22 // Serialize the current state of the heap. The order is: |
| 24 // 1) Immortal immovable roots | 23 // 1) Immortal immovable roots |
| 25 // 2) Remaining strong references. | 24 // 2) Remaining strong references. |
| 26 // 3) Partial snapshot cache. | 25 // 3) Partial snapshot cache. |
| 27 // 4) Weak references (e.g. the string table). | 26 // 4) Weak references (e.g. the string table). |
| 28 void SerializeStrongReferences(); | 27 void SerializeStrongReferences(); |
| 29 void SerializeWeakReferencesAndDeferred(); | 28 void SerializeWeakReferencesAndDeferred(); |
| 30 | 29 |
| 31 private: | 30 private: |
| 32 // The StartupSerializer has to serialize the root array, which is slightly | 31 // The StartupSerializer has to serialize the root array, which is slightly |
| 33 // different. | 32 // different. |
| 34 void VisitPointers(Object** start, Object** end) override; | 33 void VisitPointers(Object** start, Object** end) override; |
| 35 void SerializeObject(HeapObject* o, HowToCode how_to_code, | 34 void SerializeObject(HeapObject* o, HowToCode how_to_code, |
| 36 WhereToPoint where_to_point, int skip) override; | 35 WhereToPoint where_to_point, int skip) override; |
| 37 void Synchronize(VisitorSynchronization::SyncTag tag) override; | 36 void Synchronize(VisitorSynchronization::SyncTag tag) override; |
| 38 | 37 |
| 39 // Some roots should not be serialized, because their actual value depends on | 38 // Some roots should not be serialized, because their actual value depends on |
| 40 // absolute addresses and they are reset after deserialization, anyway. | 39 // absolute addresses and they are reset after deserialization, anyway. |
| 41 // In the first pass over the root list, we only serialize immortal immovable | 40 // In the first pass over the root list, we only serialize immortal immovable |
| 42 // roots. In the second pass, we serialize the rest. | 41 // roots. In the second pass, we serialize the rest. |
| 43 bool RootShouldBeSkipped(int root_index); | 42 bool RootShouldBeSkipped(int root_index); |
| 44 | 43 |
| 45 FunctionCodeHandling function_code_handling_; | 44 bool clear_function_code_; |
| 46 bool serializing_builtins_; | 45 bool serializing_builtins_; |
| 47 bool serializing_immortal_immovables_roots_; | 46 bool serializing_immortal_immovables_roots_; |
| 48 std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_; | 47 std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_; |
| 49 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); | 48 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 } // namespace internal | 51 } // namespace internal |
| 53 } // namespace v8 | 52 } // namespace v8 |
| 54 | 53 |
| 55 #endif // V8_SNAPSHOT_STARTUP_SERIALIZER_H_ | 54 #endif // V8_SNAPSHOT_STARTUP_SERIALIZER_H_ |
| OLD | NEW |