LCOV - code coverage report
Current view: top level - src - ptr-compr-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 8 10 80.0 %
Date: 2019-03-21 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2018 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_PTR_COMPR_INL_H_
       6             : #define V8_PTR_COMPR_INL_H_
       7             : 
       8             : 
       9             : #include "include/v8-internal.h"
      10             : #include "src/ptr-compr.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : 
      15             : #if V8_TARGET_ARCH_64_BIT
      16             : // Compresses full-pointer representation of a tagged value to on-heap
      17             : // representation.
      18             : V8_INLINE Tagged_t CompressTagged(Address tagged) {
      19  2611160504 :   return static_cast<Tagged_t>(static_cast<uint32_t>(tagged));
      20             : }
      21             : 
      22             : // Calculates isolate root value from any on-heap address.
      23             : V8_INLINE Address GetRootFromOnHeapAddress(Address addr) {
      24 55286207425 :   return RoundDown(addr + kPtrComprIsolateRootBias,
      25    51629019 :                    kPtrComprIsolateRootAlignment);
      26             : }
      27             : 
      28             : // Decompresses weak or strong heap object pointer or forwarding pointer,
      29             : // preserving both weak- and smi- tags.
      30             : V8_INLINE Address DecompressTaggedPointer(Address on_heap_addr,
      31             :                                           Tagged_t raw_value) {
      32             :   // Current compression scheme requires |raw_value| to be sign-extended
      33             :   // from int32_t to intptr_t.
      34           0 :   intptr_t value = static_cast<intptr_t>(static_cast<int32_t>(raw_value));
      35           0 :   Address root = GetRootFromOnHeapAddress(on_heap_addr);
      36 24268735462 :   return root + static_cast<Address>(value);
      37             : }
      38             : 
      39             : // Decompresses any tagged value, preserving both weak- and smi- tags.
      40             : V8_INLINE Address DecompressTaggedAny(Address on_heap_addr,
      41             :                                       Tagged_t raw_value) {
      42             :   // Current compression scheme requires |raw_value| to be sign-extended
      43             :   // from int32_t to intptr_t.
      44    51629019 :   intptr_t value = static_cast<intptr_t>(static_cast<int32_t>(raw_value));
      45             :   if (kUseBranchlessPtrDecompression) {
      46             :     // |root_mask| is 0 if the |value| was a smi or -1 otherwise.
      47 31623312027 :     Address root_mask = static_cast<Address>(-(value & kSmiTagMask));
      48 31623716912 :     Address root_or_zero = root_mask & GetRootFromOnHeapAddress(on_heap_addr);
      49 31623716912 :     return root_or_zero + static_cast<Address>(value);
      50             :   } else {
      51             :     return HAS_SMI_TAG(value) ? static_cast<Address>(value)
      52             :                               : (GetRootFromOnHeapAddress(on_heap_addr) +
      53             :                                  static_cast<Address>(value));
      54             :   }
      55             : }
      56             : 
      57             : #ifdef V8_COMPRESS_POINTERS
      58             : 
      59             : STATIC_ASSERT(kPtrComprHeapReservationSize ==
      60             :               Internals::kPtrComprHeapReservationSize);
      61             : STATIC_ASSERT(kPtrComprIsolateRootBias == Internals::kPtrComprIsolateRootBias);
      62             : STATIC_ASSERT(kPtrComprIsolateRootAlignment ==
      63             :               Internals::kPtrComprIsolateRootAlignment);
      64             : 
      65             : #endif  // V8_COMPRESS_POINTERS
      66             : 
      67             : #else
      68             : 
      69             : V8_INLINE Tagged_t CompressTagged(Address tagged) { UNREACHABLE(); }
      70             : 
      71             : #endif  // V8_TARGET_ARCH_64_BIT
      72             : }  // namespace internal
      73             : }  // namespace v8
      74             : 
      75             : #endif  // V8_PTR_COMPR_INL_H_

Generated by: LCOV version 1.10