LCOV - code coverage report
Current view: top level - src/snapshot - builtin-serializer-allocator.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 7 17 41.2 %
Date: 2017-10-20 Functions: 2 3 66.7 %

          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             : #include "src/snapshot/builtin-serializer-allocator.h"
       6             : 
       7             : #include "src/heap/heap-inl.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : 
      12      112861 : SerializerReference BuiltinSerializerAllocator::Allocate(AllocationSpace space,
      13             :                                                          uint32_t size) {
      14             :   DCHECK_EQ(space, CODE_SPACE);
      15             :   DCHECK_GT(size, 0);
      16             : 
      17             :   // Builtin serialization & deserialization does not use the reservation
      18             :   // system.  Instead of worrying about chunk indices and offsets, we simply
      19             :   // need to generate unique offsets here.
      20             : 
      21             :   const uint32_t virtual_chunk_index = 0;
      22             :   const auto ref = SerializerReference::BackReference(
      23      112861 :       CODE_SPACE, virtual_chunk_index, virtual_chunk_offset_);
      24             : 
      25      112861 :   virtual_chunk_size_ += size;
      26      112861 :   virtual_chunk_offset_ += kObjectAlignment;  // Needs to be aligned.
      27             : 
      28      112861 :   return ref;
      29             : }
      30             : 
      31             : #ifdef DEBUG
      32             : bool BuiltinSerializerAllocator::BackReferenceIsAlreadyAllocated(
      33             :     SerializerReference reference) const {
      34             :   DCHECK(reference.is_back_reference());
      35             :   AllocationSpace space = reference.space();
      36             :   DCHECK_EQ(space, CODE_SPACE);
      37             :   DCHECK_EQ(reference.chunk_index(), 0);
      38             :   return reference.chunk_offset() < virtual_chunk_offset_;
      39             : }
      40             : #endif  // DEBUG
      41             : 
      42             : std::vector<SerializedData::Reservation>
      43         161 : BuiltinSerializerAllocator::EncodeReservations() const {
      44         161 :   return {};
      45             : }
      46             : 
      47           0 : void BuiltinSerializerAllocator::OutputStatistics() {
      48             :   DCHECK(FLAG_serialization_statistics);
      49             : 
      50           0 :   PrintF("  Spaces (bytes):\n");
      51             : 
      52             :   STATIC_ASSERT(NEW_SPACE == 0);
      53           0 :   for (int space = 0; space < kNumberOfSpaces; space++) {
      54           0 :     PrintF("%16s", AllocationSpaceName(static_cast<AllocationSpace>(space)));
      55             :   }
      56           0 :   PrintF("\n");
      57             : 
      58             :   STATIC_ASSERT(NEW_SPACE == 0);
      59           0 :   for (int space = 0; space < kNumberOfSpaces; space++) {
      60           0 :     uint32_t space_size = (space == CODE_SPACE) ? virtual_chunk_size_ : 0;
      61           0 :     PrintF("%16d", space_size);
      62             :   }
      63           0 :   PrintF("\n");
      64           0 : }
      65             : 
      66             : }  // namespace internal
      67             : }  // namespace v8

Generated by: LCOV version 1.10