LCOV - code coverage report
Current view: top level - src/snapshot - default-serializer-allocator.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2017-10-20 Functions: 1 1 100.0 %

          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_DEFAULT_SERIALIZER_ALLOCATOR_H_
       6             : #define V8_SNAPSHOT_DEFAULT_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        1460 : class DefaultSerializerAllocator final {
      17             :  public:
      18             :   DefaultSerializerAllocator(
      19             :       Serializer<DefaultSerializerAllocator>* serializer);
      20             : 
      21             :   SerializerReference Allocate(AllocationSpace space, uint32_t size);
      22             :   SerializerReference AllocateMap();
      23             :   SerializerReference AllocateLargeObject(uint32_t size);
      24             :   SerializerReference AllocateOffHeapBackingStore();
      25             : 
      26             : #ifdef DEBUG
      27             :   bool BackReferenceIsAlreadyAllocated(
      28             :       SerializerReference back_reference) const;
      29             :   bool HasNotExceededFirstPageOfEachSpace() const;
      30             : #endif
      31             : 
      32             :   std::vector<SerializedData::Reservation> EncodeReservations() const;
      33             : 
      34             :   void OutputStatistics();
      35             : 
      36             :  private:
      37             :   static constexpr int kNumberOfPreallocatedSpaces =
      38             :       SerializerDeserializer::kNumberOfPreallocatedSpaces;
      39             :   static constexpr int kNumberOfSpaces =
      40             :       SerializerDeserializer::kNumberOfSpaces;
      41             : 
      42             :   static uint32_t MaxChunkSizeInSpace(int space);
      43             : 
      44             :   // Objects from the same space are put into chunks for bulk-allocation
      45             :   // when deserializing. We have to make sure that each chunk fits into a
      46             :   // page. So we track the chunk size in pending_chunk_ of a space, but
      47             :   // when it exceeds a page, we complete the current chunk and start a new one.
      48             :   uint32_t pending_chunk_[kNumberOfPreallocatedSpaces];
      49             :   std::vector<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces];
      50             : 
      51             :   // Number of maps that we need to allocate.
      52             :   uint32_t num_maps_ = 0;
      53             : 
      54             :   // We map serialized large objects to indexes for back-referencing.
      55             :   uint32_t large_objects_total_size_ = 0;
      56             :   uint32_t seen_large_objects_index_ = 0;
      57             : 
      58             :   // Used to keep track of the off-heap backing stores used by TypedArrays/
      59             :   // ArrayBuffers. Note that the index begins at 1 and not 0, because when a
      60             :   // TypedArray has an on-heap backing store, the backing_store pointer in the
      61             :   // corresponding ArrayBuffer will be null, which makes it indistinguishable
      62             :   // from index 0.
      63             :   uint32_t seen_backing_stores_index_ = 1;
      64             : 
      65             :   // The current serializer.
      66             :   Serializer<DefaultSerializerAllocator>* const serializer_;
      67             : 
      68             :   DISALLOW_COPY_AND_ASSIGN(DefaultSerializerAllocator)
      69             : };
      70             : 
      71             : }  // namespace internal
      72             : }  // namespace v8
      73             : 
      74             : #endif  // V8_SNAPSHOT_DEFAULT_SERIALIZER_ALLOCATOR_H_

Generated by: LCOV version 1.10