LCOV - code coverage report
Current view: top level - src/objects - property-array-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 29 29 100.0 %
Date: 2019-01-20 Functions: 7 7 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/heap-object-inl.h"
      12             : #include "src/objects/smi-inl.h"
      13             : 
      14             : // Has to be the last include (doesn't have include guards):
      15             : #include "src/objects/object-macros.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : 
      20   269410060 : OBJECT_CONSTRUCTORS_IMPL(PropertyArray, HeapObject)
      21   134705045 : CAST_ACCESSOR(PropertyArray)
      22             : 
      23   104912876 : Object PropertyArray::get(int index) const {
      24             :   DCHECK_LT(static_cast<unsigned>(index),
      25             :             static_cast<unsigned>(this->length()));
      26   209825752 :   return RELAXED_READ_FIELD(*this, OffsetOfElementAt(index));
      27             : }
      28             : 
      29    62775775 : void PropertyArray::set(int index, Object value) {
      30             :   DCHECK(IsPropertyArray());
      31             :   DCHECK_LT(static_cast<unsigned>(index),
      32             :             static_cast<unsigned>(this->length()));
      33             :   int offset = OffsetOfElementAt(index);
      34    62775775 :   RELAXED_WRITE_FIELD(*this, offset, value);
      35   125551549 :   WRITE_BARRIER(*this, offset, value);
      36    62775774 : }
      37             : 
      38    56730812 : void PropertyArray::set(int index, Object value, WriteBarrierMode mode) {
      39             :   DCHECK_LT(static_cast<unsigned>(index),
      40             :             static_cast<unsigned>(this->length()));
      41             :   int offset = OffsetOfElementAt(index);
      42    56730812 :   RELAXED_WRITE_FIELD(*this, offset, value);
      43    85012272 :   CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode);
      44    56730812 : }
      45             : 
      46             : ObjectSlot PropertyArray::data_start() { return RawField(kHeaderSize); }
      47             : 
      48             : int PropertyArray::length() const {
      49    33770620 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      50    16885310 :   int value = Smi::ToInt(value_obj);
      51             :   return LengthField::decode(value);
      52             : }
      53             : 
      54             : void PropertyArray::initialize_length(int len) {
      55             :   DCHECK_LT(static_cast<unsigned>(len),
      56             :             static_cast<unsigned>(LengthField::kMax));
      57     6923706 :   WRITE_FIELD(*this, kLengthAndHashOffset, Smi::FromInt(len));
      58             : }
      59             : 
      60    28886938 : int PropertyArray::synchronized_length() const {
      61    57773876 :   Object value_obj = ACQUIRE_READ_FIELD(*this, kLengthAndHashOffset);
      62    28886938 :   int value = Smi::ToInt(value_obj);
      63    28880800 :   return LengthField::decode(value);
      64             : }
      65             : 
      66    11235968 : int PropertyArray::Hash() const {
      67    22471936 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      68    11235968 :   int value = Smi::ToInt(value_obj);
      69    22471936 :   return HashField::decode(value);
      70             : }
      71             : 
      72         147 : void PropertyArray::SetHash(int hash) {
      73         294 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      74         147 :   int value = Smi::ToInt(value_obj);
      75         294 :   value = HashField::update(value, hash);
      76         147 :   WRITE_FIELD(*this, kLengthAndHashOffset, Smi::FromInt(value));
      77         147 : }
      78             : 
      79             : }  // namespace internal
      80             : }  // namespace v8
      81             : 
      82             : #include "src/objects/object-macros-undef.h"
      83             : 
      84             : #endif  // V8_OBJECTS_PROPERTY_ARRAY_INL_H_

Generated by: LCOV version 1.10