LCOV - code coverage report
Current view: top level - src/objects - property-array-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 18 18 100.0 %
Date: 2019-04-17 Functions: 3 3 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             : OBJECT_CONSTRUCTORS_IMPL(PropertyArray, HeapObject)
      22             : CAST_ACCESSOR(PropertyArray)
      23             : 
      24             : Object PropertyArray::get(int index) const {
      25             :   DCHECK_LT(static_cast<unsigned>(index),
      26             :             static_cast<unsigned>(this->length()));
      27   204920754 :   return RELAXED_READ_FIELD(*this, OffsetOfElementAt(index));
      28             : }
      29             : 
      30    96921081 : 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    96921081 :   RELAXED_WRITE_FIELD(*this, offset, value);
      36    96921081 :   WRITE_BARRIER(*this, offset, value);
      37    96921085 : }
      38             : 
      39   124421301 : 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   124421301 :   RELAXED_WRITE_FIELD(*this, offset, value);
      44   144582381 :   CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode);
      45   124421301 : }
      46             : 
      47             : ObjectSlot PropertyArray::data_start() { return RawField(kHeaderSize); }
      48             : 
      49             : int PropertyArray::length() const {
      50    17179766 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      51             :   int value = Smi::ToInt(value_obj);
      52             :   return LengthField::decode(value);
      53             : }
      54             : 
      55             : void PropertyArray::initialize_length(int len) {
      56             :   DCHECK_LT(static_cast<unsigned>(len),
      57             :             static_cast<unsigned>(LengthField::kMax));
      58     9725592 :   WRITE_FIELD(*this, kLengthAndHashOffset, Smi::FromInt(len));
      59             : }
      60             : 
      61             : int PropertyArray::synchronized_length() const {
      62    42141790 :   Object value_obj = ACQUIRE_READ_FIELD(*this, kLengthAndHashOffset);
      63             :   int value = Smi::ToInt(value_obj);
      64             :   return LengthField::decode(value);
      65             : }
      66             : 
      67             : int PropertyArray::Hash() const {
      68    15919483 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      69             :   int value = Smi::ToInt(value_obj);
      70    15919483 :   return HashField::decode(value);
      71             : }
      72             : 
      73         156 : void PropertyArray::SetHash(int hash) {
      74         156 :   Object value_obj = READ_FIELD(*this, kLengthAndHashOffset);
      75             :   int value = Smi::ToInt(value_obj);
      76         312 :   value = HashField::update(value, hash);
      77             :   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