LCOV - code coverage report
Current view: top level - src/objects - property-array-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 31 31 100.0 %
Date: 2019-02-19 Functions: 8 8 100.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_OBJECTS_PROPERTY_ARRAY_INL_H_
       6             : #define V8_OBJECTS_PROPERTY_ARRAY_INL_H_
       7             : 
       8             : #include "src/objects/property-array.h"
       9             : 
      10             : #include "src/heap/heap-write-barrier-inl.h"
      11             : #include "src/objects-inl.h"
      12             : #include "src/objects/heap-object-inl.h"
      13             : #include "src/objects/smi-inl.h"
      14             : 
      15             : // Has to be the last include (doesn't have include guards):
      16             : #include "src/objects/object-macros.h"
      17             : 
      18             : namespace v8 {
      19             : namespace internal {
      20             : 
      21   374482743 : OBJECT_CONSTRUCTORS_IMPL(PropertyArray, HeapObject)
      22   192576962 : CAST_ACCESSOR(PropertyArray)
      23             : 
      24   207657084 : Object PropertyArray::get(int index) const {
      25             :   DCHECK_LT(static_cast<unsigned>(index),
      26             :             static_cast<unsigned>(this->length()));
      27   415314168 :   return RELAXED_READ_FIELD(*this, OffsetOfElementAt(index));
      28             : }
      29             : 
      30    98864393 : void PropertyArray::set(int index, Object value) {
      31             :   DCHECK(IsPropertyArray());
      32             :   DCHECK_LT(static_cast<unsigned>(index),
      33             :             static_cast<unsigned>(this->length()));
      34             :   int offset = OffsetOfElementAt(index);
      35    98864393 :   RELAXED_WRITE_FIELD(*this, offset, value);
      36   197728795 :   WRITE_BARRIER(*this, offset, value);
      37    98864401 : }
      38             : 
      39   124774973 : void PropertyArray::set(int index, Object value, WriteBarrierMode mode) {
      40             :   DCHECK_LT(static_cast<unsigned>(index),
      41             :             static_cast<unsigned>(this->length()));
      42             :   int offset = OffsetOfElementAt(index);
      43   124774973 :   RELAXED_WRITE_FIELD(*this, offset, value);
      44   169543917 :   CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode);
      45   124774973 : }
      46             : 
      47             : ObjectSlot PropertyArray::data_start() { return RawField(kHeaderSize); }
      48             : 
      49             : int PropertyArray::length() const {
      50    36374792 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      51    18187396 :   int value = Smi::ToInt(value_obj);
      52             :   return LengthField::decode(value);
      53             : }
      54             : 
      55          56 : void PropertyArray::initialize_length(int len) {
      56             :   DCHECK_LT(static_cast<unsigned>(len),
      57             :             static_cast<unsigned>(LengthField::kMax));
      58    10598672 :   WRITE_FIELD(*this, kLengthAndHashOffset, Smi::FromInt(len));
      59          56 : }
      60             : 
      61    43619227 : int PropertyArray::synchronized_length() const {
      62    87238454 :   Object value_obj = ACQUIRE_READ_FIELD(*this, kLengthAndHashOffset);
      63    43619227 :   int value = Smi::ToInt(value_obj);
      64    43613877 :   return LengthField::decode(value);
      65             : }
      66             : 
      67    15686800 : int PropertyArray::Hash() const {
      68    31373600 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      69    15686800 :   int value = Smi::ToInt(value_obj);
      70    31373600 :   return HashField::decode(value);
      71             : }
      72             : 
      73         156 : void PropertyArray::SetHash(int hash) {
      74         312 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      75         156 :   int value = Smi::ToInt(value_obj);
      76         312 :   value = HashField::update(value, hash);
      77         156 :   WRITE_FIELD(*this, kLengthAndHashOffset, Smi::FromInt(value));
      78         156 : }
      79             : 
      80             : }  // namespace internal
      81             : }  // namespace v8
      82             : 
      83             : #include "src/objects/object-macros-undef.h"
      84             : 
      85             : #endif  // V8_OBJECTS_PROPERTY_ARRAY_INL_H_

Generated by: LCOV version 1.10