LCOV - code coverage report
Current view: top level - src/objects - ordered-hash-table-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 57 62 91.9 %
Date: 2019-02-19 Functions: 24 26 92.3 %

          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_ORDERED_HASH_TABLE_INL_H_
       6             : #define V8_OBJECTS_ORDERED_HASH_TABLE_INL_H_
       7             : 
       8             : #include "src/objects/ordered-hash-table.h"
       9             : 
      10             : #include "src/heap/heap.h"
      11             : #include "src/objects-inl.h"
      12             : #include "src/objects/fixed-array-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     3951535 : CAST_ACCESSOR(OrderedNameDictionary)
      21     1296845 : CAST_ACCESSOR(SmallOrderedNameDictionary)
      22     2858204 : CAST_ACCESSOR(OrderedHashMap)
      23    13671613 : CAST_ACCESSOR(OrderedHashSet)
      24      163368 : CAST_ACCESSOR(SmallOrderedHashMap)
      25      163368 : CAST_ACCESSOR(SmallOrderedHashSet)
      26             : 
      27             : template <class Derived, int entrysize>
      28             : OrderedHashTable<Derived, entrysize>::OrderedHashTable(Address ptr)
      29             :     : FixedArray(ptr) {}
      30             : 
      31    13671613 : OrderedHashSet::OrderedHashSet(Address ptr)
      32             :     : OrderedHashTable<OrderedHashSet, 1>(ptr) {
      33             :   SLOW_DCHECK(IsOrderedHashSet());
      34    13671613 : }
      35             : 
      36     2858204 : OrderedHashMap::OrderedHashMap(Address ptr)
      37             :     : OrderedHashTable<OrderedHashMap, 2>(ptr) {
      38             :   SLOW_DCHECK(IsOrderedHashMap());
      39     2858204 : }
      40             : 
      41     3951535 : OrderedNameDictionary::OrderedNameDictionary(Address ptr)
      42             :     : OrderedHashTable<OrderedNameDictionary, 3>(ptr) {
      43             :   SLOW_DCHECK(IsOrderedNameDictionary());
      44     3951535 : }
      45             : 
      46             : template <class Derived>
      47             : SmallOrderedHashTable<Derived>::SmallOrderedHashTable(Address ptr)
      48             :     : HeapObject(ptr) {}
      49             : 
      50      326736 : OBJECT_CONSTRUCTORS_IMPL(SmallOrderedHashSet,
      51             :                          SmallOrderedHashTable<SmallOrderedHashSet>)
      52      326736 : OBJECT_CONSTRUCTORS_IMPL(SmallOrderedHashMap,
      53             :                          SmallOrderedHashTable<SmallOrderedHashMap>)
      54     2593690 : OBJECT_CONSTRUCTORS_IMPL(SmallOrderedNameDictionary,
      55             :                          SmallOrderedHashTable<SmallOrderedNameDictionary>)
      56             : 
      57          56 : RootIndex OrderedHashSet::GetMapRootIndex() {
      58          56 :   return RootIndex::kOrderedHashSetMap;
      59             : }
      60             : 
      61          56 : RootIndex OrderedHashMap::GetMapRootIndex() {
      62          56 :   return RootIndex::kOrderedHashMapMap;
      63             : }
      64             : 
      65             : RootIndex OrderedNameDictionary::GetMapRootIndex() {
      66             :   return RootIndex::kOrderedNameDictionaryMap;
      67             : }
      68             : 
      69             : RootIndex SmallOrderedNameDictionary::GetMapRootIndex() {
      70             :   return RootIndex::kSmallOrderedNameDictionaryMap;
      71             : }
      72             : 
      73           4 : RootIndex SmallOrderedHashMap::GetMapRootIndex() {
      74           4 :   return RootIndex::kSmallOrderedHashMapMap;
      75             : }
      76             : 
      77           4 : RootIndex SmallOrderedHashSet::GetMapRootIndex() {
      78           4 :   return RootIndex::kSmallOrderedHashSetMap;
      79             : }
      80             : 
      81        5395 : inline Object OrderedHashMap::ValueAt(int entry) {
      82             :   DCHECK_NE(entry, kNotFound);
      83             :   DCHECK_LT(entry, UsedCapacity());
      84       16185 :   return get(EntryToIndex(entry) + kValueOffset);
      85             : }
      86             : 
      87          35 : inline Object OrderedNameDictionary::ValueAt(int entry) {
      88             :   DCHECK_NE(entry, kNotFound);
      89             :   DCHECK_LT(entry, UsedCapacity());
      90         105 :   return get(EntryToIndex(entry) + kValueOffset);
      91             : }
      92             : 
      93             : // Set the value for entry.
      94          10 : inline void OrderedNameDictionary::ValueAtPut(int entry, Object value) {
      95             :   DCHECK_NE(entry, kNotFound);
      96             :   DCHECK_LT(entry, UsedCapacity());
      97          20 :   this->set(EntryToIndex(entry) + kValueOffset, value);
      98          10 : }
      99             : 
     100             : // Returns the property details for the property at entry.
     101          25 : inline PropertyDetails OrderedNameDictionary::DetailsAt(int entry) {
     102             :   DCHECK_NE(entry, kNotFound);
     103             :   DCHECK_LT(entry, this->UsedCapacity());
     104             :   // TODO(gsathya): Optimize the cast away.
     105             :   return PropertyDetails(
     106          75 :       Smi::cast(get(EntryToIndex(entry) + kPropertyDetailsOffset)));
     107             : }
     108             : 
     109          10 : inline void OrderedNameDictionary::DetailsAtPut(int entry,
     110             :                                                 PropertyDetails value) {
     111             :   DCHECK_NE(entry, kNotFound);
     112             :   DCHECK_LT(entry, this->UsedCapacity());
     113             :   // TODO(gsathya): Optimize the cast away.
     114          10 :   this->set(EntryToIndex(entry) + kPropertyDetailsOffset, value.AsSmi());
     115          10 : }
     116             : 
     117             : inline Object SmallOrderedNameDictionary::ValueAt(int entry) {
     118             :   return this->GetDataEntry(entry, kValueIndex);
     119             : }
     120             : 
     121             : // Set the value for entry.
     122             : inline void SmallOrderedNameDictionary::ValueAtPut(int entry, Object value) {
     123          10 :   this->SetDataEntry(entry, kValueIndex, value);
     124             : }
     125             : 
     126             : // Returns the property details for the property at entry.
     127        1295 : inline PropertyDetails SmallOrderedNameDictionary::DetailsAt(int entry) {
     128             :   // TODO(gsathya): Optimize the cast away. And store this in the data table.
     129             :   return PropertyDetails(
     130        1295 :       Smi::cast(this->GetDataEntry(entry, kPropertyDetailsIndex)));
     131             : }
     132             : 
     133             : // Set the details for entry.
     134             : inline void SmallOrderedNameDictionary::DetailsAtPut(int entry,
     135             :                                                      PropertyDetails value) {
     136             :   // TODO(gsathya): Optimize the cast away. And store this in the data table.
     137          10 :   this->SetDataEntry(entry, kPropertyDetailsIndex, value.AsSmi());
     138             : }
     139             : 
     140           5 : inline bool OrderedHashSet::Is(Handle<HeapObject> table) {
     141          10 :   return table->IsOrderedHashSet();
     142             : }
     143             : 
     144           5 : inline bool OrderedHashMap::Is(Handle<HeapObject> table) {
     145          10 :   return table->IsOrderedHashMap();
     146             : }
     147             : 
     148     2624020 : inline bool SmallOrderedHashSet::Is(Handle<HeapObject> table) {
     149     5248040 :   return table->IsSmallOrderedHashSet();
     150             : }
     151             : 
     152     2624020 : inline bool SmallOrderedHashMap::Is(Handle<HeapObject> table) {
     153     5248040 :   return table->IsSmallOrderedHashMap();
     154             : }
     155             : 
     156             : template <class Derived>
     157       51575 : void SmallOrderedHashTable<Derived>::SetDataEntry(int entry, int relative_index,
     158             :                                                   Object value) {
     159             :   DCHECK_NE(kNotFound, entry);
     160             :   int entry_offset = GetDataEntryOffset(entry, relative_index);
     161       51575 :   RELAXED_WRITE_FIELD(*this, entry_offset, value);
     162      103150 :   WRITE_BARRIER(*this, entry_offset, value);
     163       51575 : }
     164             : 
     165             : template <class Derived, class TableType>
     166           0 : Object OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
     167           0 :   TableType table = TableType::cast(this->table());
     168           0 :   int index = Smi::ToInt(this->index());
     169           0 :   Object key = table->KeyAt(index);
     170             :   DCHECK(!key->IsTheHole());
     171           0 :   return key;
     172             : }
     173             : 
     174             : inline void SmallOrderedNameDictionary::SetHash(int hash) {
     175             :   DCHECK(PropertyArray::HashField::is_valid(hash));
     176         370 :   WRITE_INT_FIELD(*this, PrefixOffset(), hash);
     177             : }
     178             : 
     179             : inline int SmallOrderedNameDictionary::Hash() {
     180        1440 :   int hash = READ_INT_FIELD(*this, PrefixOffset());
     181             :   DCHECK(PropertyArray::HashField::is_valid(hash));
     182             :   return hash;
     183             : }
     184             : 
     185             : inline void OrderedNameDictionary::SetHash(int hash) {
     186             :   DCHECK(PropertyArray::HashField::is_valid(hash));
     187             :   this->set(PrefixIndex(), Smi::FromInt(hash));
     188             : }
     189             : 
     190        5250 : inline int OrderedNameDictionary::Hash() {
     191        5250 :   Object hash_obj = this->get(PrefixIndex());
     192        5250 :   int hash = Smi::ToInt(hash_obj);
     193             :   DCHECK(PropertyArray::HashField::is_valid(hash));
     194        5250 :   return hash;
     195             : }
     196             : 
     197             : }  // namespace internal
     198             : }  // namespace v8
     199             : 
     200             : #include "src/objects/object-macros-undef.h"
     201             : 
     202             : #endif  // V8_OBJECTS_ORDERED_HASH_TABLE_INL_H_

Generated by: LCOV version 1.10