Line data Source code
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_BUILTIN_SERIALIZER_ALLOCATOR_H_
6 : #define V8_SNAPSHOT_BUILTIN_SERIALIZER_ALLOCATOR_H_
7 :
8 : #include "src/snapshot/serializer-common.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 :
13 : template <class AllocatorT>
14 : class Serializer;
15 :
16 : class BuiltinSerializerAllocator final {
17 : public:
18 : BuiltinSerializerAllocator(
19 161 : Serializer<BuiltinSerializerAllocator>* serializer) {}
20 :
21 : SerializerReference Allocate(AllocationSpace space, uint32_t size);
22 0 : SerializerReference AllocateMap() { UNREACHABLE(); }
23 0 : SerializerReference AllocateLargeObject(uint32_t size) { UNREACHABLE(); }
24 0 : SerializerReference AllocateOffHeapBackingStore() { UNREACHABLE(); }
25 :
26 : #ifdef DEBUG
27 : bool BackReferenceIsAlreadyAllocated(
28 : SerializerReference back_reference) const;
29 : #endif
30 :
31 : std::vector<SerializedData::Reservation> EncodeReservations() const;
32 :
33 : void OutputStatistics();
34 :
35 : private:
36 : static constexpr int kNumberOfPreallocatedSpaces =
37 : SerializerDeserializer::kNumberOfPreallocatedSpaces;
38 : static constexpr int kNumberOfSpaces =
39 : SerializerDeserializer::kNumberOfSpaces;
40 :
41 : // We need to track a faked offset to create back-references. The size is
42 : // kept simply to display statistics.
43 : uint32_t virtual_chunk_size_ = 0;
44 : uint32_t virtual_chunk_offset_ = 0;
45 :
46 : DISALLOW_COPY_AND_ASSIGN(BuiltinSerializerAllocator)
47 : };
48 :
49 : } // namespace internal
50 : } // namespace v8
51 :
52 : #endif // V8_SNAPSHOT_BUILTIN_SERIALIZER_ALLOCATOR_H_
|