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

Generated by: LCOV version 1.10