LCOV - code coverage report
Current view: top level - src/objects - slots-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 21 22 95.5 %
Date: 2019-04-18 Functions: 7 8 87.5 %

          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_OBJECTS_SLOTS_INL_H_
       6             : #define V8_OBJECTS_SLOTS_INL_H_
       7             : 
       8             : #include "src/objects/slots.h"
       9             : 
      10             : #include "src/base/atomic-utils.h"
      11             : #include "src/memcopy.h"
      12             : #include "src/objects.h"
      13             : #include "src/objects/heap-object-inl.h"
      14             : #include "src/objects/maybe-object.h"
      15             : #include "src/ptr-compr-inl.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : 
      20             : //
      21             : // FullObjectSlot implementation.
      22             : //
      23             : 
      24           0 : FullObjectSlot::FullObjectSlot(Object* object)
      25   441840503 :     : SlotBase(reinterpret_cast<Address>(&object->ptr_)) {}
      26             : 
      27             : bool FullObjectSlot::contains_value(Address raw_value) const {
      28             :   return base::AsAtomicPointer::Relaxed_Load(location()) == raw_value;
      29             : }
      30             : 
      31 13359936443 : const Object FullObjectSlot::operator*() const { return Object(*location()); }
      32             : 
      33    47151764 : void FullObjectSlot::store(Object value) const { *location() = value->ptr(); }
      34             : 
      35             : Object FullObjectSlot::Acquire_Load() const {
      36             :   return Object(base::AsAtomicPointer::Acquire_Load(location()));
      37             : }
      38             : 
      39  2824593494 : Object FullObjectSlot::Relaxed_Load() const {
      40  2824593494 :   return Object(base::AsAtomicPointer::Relaxed_Load(location()));
      41             : }
      42             : 
      43    10004870 : void FullObjectSlot::Relaxed_Store(Object value) const {
      44             :   base::AsAtomicPointer::Relaxed_Store(location(), value->ptr());
      45    10004870 : }
      46             : 
      47             : void FullObjectSlot::Release_Store(Object value) const {
      48             :   base::AsAtomicPointer::Release_Store(location(), value->ptr());
      49             : }
      50             : 
      51    24850912 : Object FullObjectSlot::Release_CompareAndSwap(Object old, Object target) const {
      52             :   Address result = base::AsAtomicPointer::Release_CompareAndSwap(
      53             :       location(), old->ptr(), target->ptr());
      54    24850912 :   return Object(result);
      55             : }
      56             : 
      57             : //
      58             : // FullMaybeObjectSlot implementation.
      59             : //
      60             : 
      61     7586195 : const MaybeObject FullMaybeObjectSlot::operator*() const {
      62   882235226 :   return MaybeObject(*location());
      63             : }
      64             : 
      65             : void FullMaybeObjectSlot::store(MaybeObject value) const {
      66  2656940620 :   *location() = value.ptr();
      67             : }
      68             : 
      69   330072168 : MaybeObject FullMaybeObjectSlot::Relaxed_Load() const {
      70   330072168 :   return MaybeObject(base::AsAtomicPointer::Relaxed_Load(location()));
      71             : }
      72             : 
      73             : void FullMaybeObjectSlot::Relaxed_Store(MaybeObject value) const {
      74             :   base::AsAtomicPointer::Relaxed_Store(location(), value->ptr());
      75             : }
      76             : 
      77             : void FullMaybeObjectSlot::Release_CompareAndSwap(MaybeObject old,
      78             :                                                  MaybeObject target) const {
      79             :   base::AsAtomicPointer::Release_CompareAndSwap(location(), old.ptr(),
      80             :                                                 target.ptr());
      81             : }
      82             : 
      83             : //
      84             : // FullHeapObjectSlot implementation.
      85             : //
      86             : 
      87    54140402 : const HeapObjectReference FullHeapObjectSlot::operator*() const {
      88   178163872 :   return HeapObjectReference(*location());
      89             : }
      90             : 
      91             : void FullHeapObjectSlot::store(HeapObjectReference value) const {
      92   178121163 :   *location() = value.ptr();
      93             : }
      94             : 
      95             : HeapObject FullHeapObjectSlot::ToHeapObject() const {
      96             :   DCHECK((*location() & kHeapObjectTagMask) == kHeapObjectTag);
      97      635651 :   return HeapObject::cast(Object(*location()));
      98             : }
      99             : 
     100             : void FullHeapObjectSlot::StoreHeapObject(HeapObject value) const {
     101      139945 :   *location() = value->ptr();
     102             : }
     103             : 
     104             : //
     105             : // Utils.
     106             : //
     107             : 
     108             : // Copies tagged words from |src| to |dst|. The data spans must not overlap.
     109             : // |src| and |dst| must be kTaggedSize-aligned.
     110             : inline void CopyTagged(Address dst, const Address src, size_t num_tagged) {
     111             :   static const size_t kBlockCopyLimit = 16;
     112   175783296 :   CopyImpl<kBlockCopyLimit>(reinterpret_cast<Tagged_t*>(dst),
     113   175783296 :                             reinterpret_cast<const Tagged_t*>(src), num_tagged);
     114             : }
     115             : 
     116             : // Sets |counter| number of kTaggedSize-sized values starting at |start| slot.
     117             : inline void MemsetTagged(ObjectSlot start, Object value, size_t counter) {
     118             : #ifdef V8_COMPRESS_POINTERS
     119             :   Tagged_t raw_value = CompressTagged(value.ptr());
     120             :   STATIC_ASSERT(kTaggedSize == kInt32Size);
     121             :   MemsetInt32(start.location(), raw_value, counter);
     122             : #else
     123             :   Address raw_value = value.ptr();
     124             :   MemsetPointer(start.location(), raw_value, counter);
     125             : #endif
     126             : }
     127             : 
     128             : // Sets |counter| number of kSystemPointerSize-sized values starting at |start|
     129             : // slot.
     130             : inline void MemsetPointer(FullObjectSlot start, Object value, size_t counter) {
     131             :   MemsetPointer(start.location(), value.ptr(), counter);
     132             : }
     133             : 
     134             : }  // namespace internal
     135             : }  // namespace v8
     136             : 
     137             : #endif  // V8_OBJECTS_SLOTS_INL_H_

Generated by: LCOV version 1.10