LCOV - code coverage report
Current view: top level - src/objects - struct-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 30 33 90.9 %
Date: 2019-02-19 Functions: 11 13 84.6 %

          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_STRUCT_INL_H_
       6             : #define V8_OBJECTS_STRUCT_INL_H_
       7             : 
       8             : #include "src/objects/struct.h"
       9             : 
      10             : #include "src/heap/heap-write-barrier-inl.h"
      11             : #include "src/objects-inl.h"
      12             : #include "src/objects/oddball.h"
      13             : #include "src/roots-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    20074545 : OBJECT_CONSTRUCTORS_IMPL(Struct, HeapObject)
      22             : // TODO(jkummerow): Fix IsTuple2() and IsTuple3() to be subclassing-aware,
      23             : // or rethink this more generally (see crbug.com/v8/8516).
      24      118451 : Tuple2::Tuple2(Address ptr) : Struct(ptr) {}
      25           0 : Tuple3::Tuple3(Address ptr) : Tuple2(ptr) {}
      26     3649106 : OBJECT_CONSTRUCTORS_IMPL(AccessorPair, Struct)
      27             : 
      28      122312 : OBJECT_CONSTRUCTORS_IMPL(ClassPositions, Struct)
      29             : 
      30     1824554 : CAST_ACCESSOR(AccessorPair)
      31     9970565 : CAST_ACCESSOR(Struct)
      32       59140 : CAST_ACCESSOR(Tuple2)
      33           0 : CAST_ACCESSOR(Tuple3)
      34             : 
      35       61156 : CAST_ACCESSOR(ClassPositions)
      36             : 
      37     9970559 : void Struct::InitializeBody(int object_size) {
      38    19941115 :   Object value = GetReadOnlyRoots().undefined_value();
      39   118369424 :   for (int offset = kHeaderSize; offset < object_size; offset += kTaggedSize) {
      40   108398868 :     WRITE_FIELD(*this, offset, value);
      41             :   }
      42     9970556 : }
      43             : 
      44      295700 : ACCESSORS(Tuple2, value1, Object, kValue1Offset)
      45      295700 : ACCESSORS(Tuple2, value2, Object, kValue2Offset)
      46           0 : ACCESSORS(Tuple3, value3, Object, kValue3Offset)
      47             : 
      48     5927487 : ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
      49     3203234 : ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
      50             : 
      51       82878 : SMI_ACCESSORS(ClassPositions, start, kStartOffset)
      52       82878 : SMI_ACCESSORS(ClassPositions, end, kEndOffset)
      53             : 
      54             : Object AccessorPair::get(AccessorComponent component) {
      55       90216 :   return component == ACCESSOR_GETTER ? getter() : setter();
      56             : }
      57             : 
      58        6307 : void AccessorPair::set(AccessorComponent component, Object value) {
      59        6307 :   if (component == ACCESSOR_GETTER) {
      60        4519 :     set_getter(value);
      61             :   } else {
      62        1788 :     set_setter(value);
      63             :   }
      64        6307 : }
      65             : 
      66      629896 : void AccessorPair::SetComponents(Object getter, Object setter) {
      67      629896 :   if (!getter->IsNull()) set_getter(getter);
      68      629896 :   if (!setter->IsNull()) set_setter(setter);
      69      629896 : }
      70             : 
      71             : bool AccessorPair::Equals(Object getter_value, Object setter_value) {
      72       33010 :   return (getter() == getter_value) && (setter() == setter_value);
      73             : }
      74             : 
      75             : }  // namespace internal
      76             : }  // namespace v8
      77             : 
      78             : #include "src/objects/object-macros-undef.h"
      79             : 
      80             : #endif  // V8_OBJECTS_STRUCT_INL_H_

Generated by: LCOV version 1.10