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

          Line data    Source code
       1             : // Copyright 2016 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_LOOKUP_CACHE_INL_H_
       6             : #define V8_LOOKUP_CACHE_INL_H_
       7             : 
       8             : #include "src/lookup-cache.h"
       9             : 
      10             : #include "src/objects-inl.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : 
      15             : // static
      16             : int DescriptorLookupCache::Hash(Object* source, Name* name) {
      17             :   DCHECK(name->IsUniqueName());
      18             :   // Uses only lower 32 bits if pointers are larger.
      19             :   uint32_t source_hash =
      20   262841704 :       static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) >>
      21   262841704 :       kPointerSizeLog2;
      22             :   uint32_t name_hash = name->hash_field();
      23   262841704 :   return (source_hash ^ name_hash) % kLength;
      24             : }
      25             : 
      26   193623997 : int DescriptorLookupCache::Lookup(Map* source, Name* name) {
      27             :   int index = Hash(source, name);
      28   193623997 :   Key& key = keys_[index];
      29   193623997 :   if ((key.source == source) && (key.name == name)) return results_[index];
      30             :   return kAbsent;
      31             : }
      32             : 
      33    69217707 : void DescriptorLookupCache::Update(Map* source, Name* name, int result) {
      34             :   DCHECK_NE(result, kAbsent);
      35             :   int index = Hash(source, name);
      36    69217707 :   Key& key = keys_[index];
      37    69217707 :   key.source = source;
      38    69217707 :   key.name = name;
      39    69217707 :   results_[index] = result;
      40    69217707 : }
      41             : 
      42             : }  // namespace internal
      43             : }  // namespace v8
      44             : 
      45             : #endif  // V8_LOOKUP_CACHE_INL_H_

Generated by: LCOV version 1.10