LCOV - code coverage report
Current view: top level - src/objects - name-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 34 34 100.0 %
Date: 2017-10-20 Functions: 14 14 100.0 %

          Line data    Source code
       1             : // Copyright 2017 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_NAME_INL_H_
       6             : #define V8_OBJECTS_NAME_INL_H_
       7             : 
       8             : #include "src/objects/name.h"
       9             : 
      10             : #include "src/heap/heap-inl.h"
      11             : 
      12             : // Has to be the last include (doesn't have include guards):
      13             : #include "src/objects/object-macros.h"
      14             : 
      15             : namespace v8 {
      16             : namespace internal {
      17             : 
      18             : CAST_ACCESSOR(Name)
      19             : CAST_ACCESSOR(Symbol)
      20             : 
      21      220783 : ACCESSORS(Symbol, name, Object, kNameOffset)
      22    32031875 : SMI_ACCESSORS(Symbol, flags, kFlagsOffset)
      23       16822 : BOOL_ACCESSORS(Symbol, flags, is_private, kPrivateBit)
      24         186 : BOOL_ACCESSORS(Symbol, flags, is_well_known_symbol, kWellKnownSymbolBit)
      25         102 : BOOL_ACCESSORS(Symbol, flags, is_public, kPublicBit)
      26          62 : BOOL_ACCESSORS(Symbol, flags, is_interesting_symbol, kInterestingSymbolBit)
      27             : 
      28   323506293 : TYPE_CHECKER(Symbol, SYMBOL_TYPE)
      29             : 
      30      506651 : bool Name::IsUniqueName() const {
      31             :   uint32_t type = map()->instance_type();
      32   187917963 :   return (type & (kIsNotStringMask | kIsNotInternalizedMask)) !=
      33      506651 :          (kStringTag | kNotInternalizedTag);
      34             : }
      35             : 
      36             : uint32_t Name::hash_field() {
      37  1715993077 :   return READ_UINT32_FIELD(this, kHashFieldOffset);
      38             : }
      39             : 
      40             : void Name::set_hash_field(uint32_t value) {
      41   288160477 :   WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
      42             : #if V8_HOST_ARCH_64_BIT
      43             : #if V8_TARGET_LITTLE_ENDIAN
      44   288160477 :   WRITE_UINT32_FIELD(this, kHashFieldSlot + kIntSize, 0);
      45             : #else
      46             :   WRITE_UINT32_FIELD(this, kHashFieldSlot, 0);
      47             : #endif
      48             : #endif
      49             : }
      50             : 
      51       79661 : bool Name::Equals(Name* other) {
      52       79661 :   if (other == this) return true;
      53      122341 :   if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
      54       62687 :       this->IsSymbol() || other->IsSymbol()) {
      55             :     return false;
      56             :   }
      57          10 :   return String::cast(this)->SlowEquals(String::cast(other));
      58             : }
      59             : 
      60      106167 : bool Name::Equals(Handle<Name> one, Handle<Name> two) {
      61      106167 :   if (one.is_identical_to(two)) return true;
      62       17502 :   if ((one->IsInternalizedString() && two->IsInternalizedString()) ||
      63        8771 :       one->IsSymbol() || two->IsSymbol()) {
      64             :     return false;
      65             :   }
      66             :   return String::SlowEquals(Handle<String>::cast(one),
      67          20 :                             Handle<String>::cast(two));
      68             : }
      69             : 
      70             : bool Name::IsHashFieldComputed(uint32_t field) {
      71  1271617168 :   return (field & kHashNotComputedMask) == 0;
      72             : }
      73             : 
      74             : bool Name::HasHashCode() { return IsHashFieldComputed(hash_field()); }
      75             : 
      76    21209855 : uint32_t Name::Hash() {
      77             :   // Fast case: has hash code already been computed?
      78             :   uint32_t field = hash_field();
      79  1153944710 :   if (IsHashFieldComputed(field)) return field >> kHashShift;
      80             :   // Slow case: compute hash code and set it. Has to be a string.
      81    63848360 :   return String::cast(this)->ComputeAndSetHash();
      82             : }
      83             : 
      84    17969346 : bool Name::IsInterestingSymbol() const {
      85    19208823 :   return IsSymbol() && Symbol::cast(this)->is_interesting_symbol();
      86             : }
      87             : 
      88   225281964 : bool Name::IsPrivate() {
      89   255976703 :   return this->IsSymbol() && Symbol::cast(this)->is_private();
      90             : }
      91             : 
      92   102378971 : bool Name::AsArrayIndex(uint32_t* index) {
      93   102378971 :   return IsString() && String::cast(this)->AsArrayIndex(index);
      94             : }
      95             : 
      96             : // static
      97             : bool Name::ContainsCachedArrayIndex(uint32_t hash) {
      98       47085 :   return (hash & Name::kDoesNotContainCachedArrayIndexMask) == 0;
      99             : }
     100             : 
     101             : }  // namespace internal
     102             : }  // namespace v8
     103             : 
     104             : #include "src/objects/object-macros-undef.h"
     105             : 
     106             : #endif  // V8_OBJECTS_NAME_INL_H_

Generated by: LCOV version 1.10