Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: src/lookup-inl.h

Issue 2316503004: KeyedLookupCache and DescriptorLookupCache -> lookup-cache{-inl.h,.cc,.h} (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/lookup-cache-inl.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.h"
6
7 namespace v8 {
8 namespace internal {
9
10 // static
11 int DescriptorLookupCache::Hash(Object* source, Name* name) {
12 DCHECK(name->IsUniqueName());
13 // Uses only lower 32 bits if pointers are larger.
14 uint32_t source_hash =
15 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) >>
16 kPointerSizeLog2;
17 uint32_t name_hash = name->hash_field();
18 return (source_hash ^ name_hash) % kLength;
19 }
20
21 int DescriptorLookupCache::Lookup(Map* source, Name* name) {
22 int index = Hash(source, name);
23 Key& key = keys_[index];
24 if ((key.source == source) && (key.name == name)) return results_[index];
25 return kAbsent;
26 }
27
28 void DescriptorLookupCache::Update(Map* source, Name* name, int result) {
29 DCHECK(result != kAbsent);
30 int index = Hash(source, name);
31 Key& key = keys_[index];
32 key.source = source;
33 key.name = name;
34 results_[index] = result;
35 }
36
37 } // namespace internal
38 } // namespace v8
OLDNEW
« no previous file with comments | « src/lookup-cache-inl.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698