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: BuiltinSerializerAllocator(Serializer<BuiltinSerializerAllocator> * serializer)18 BuiltinSerializerAllocator( 19 Serializer<BuiltinSerializerAllocator>* serializer) {} 20 21 SerializerReference Allocate(AllocationSpace space, uint32_t size); AllocateMap()22 SerializerReference AllocateMap() { UNREACHABLE(); } AllocateLargeObject(uint32_t size)23 SerializerReference AllocateLargeObject(uint32_t size) { UNREACHABLE(); } AllocateOffHeapBackingStore()24 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 uint32_t allocated_bytes_ = 0; 42 uint32_t next_builtin_reference_index_ = 0; 43 44 DISALLOW_COPY_AND_ASSIGN(BuiltinSerializerAllocator) 45 }; 46 47 } // namespace internal 48 } // namespace v8 49 50 #endif // V8_SNAPSHOT_BUILTIN_SERIALIZER_ALLOCATOR_H_ 51