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

Unified Diff: src/heap/heap-inl.h

Issue 1704353002: [runtime] Force internalize names used before lookup in in DescriptorArray and TransitionArray (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/json-parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap-inl.h
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h
index a87d347c1dd700c1e477e6149e4f9e79097748c6..57e6cc4c935d41e4fd130cff4a62d82b1745a2fa 100644
--- a/src/heap/heap-inl.h
+++ b/src/heap/heap-inl.h
@@ -622,9 +622,18 @@ void Heap::ExternalStringTable::ShrinkNewStrings(int position) {
#endif
}
+// static
+int DescriptorLookupCache::Hash(Object* source, Name* name) {
+ DCHECK(name->IsUniqueName());
+ // Uses only lower 32 bits if pointers are larger.
+ uint32_t source_hash =
+ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(source)) >>
+ kPointerSizeLog2;
+ uint32_t name_hash = name->hash_field();
+ return (source_hash ^ name_hash) % kLength;
+}
int DescriptorLookupCache::Lookup(Map* source, Name* name) {
- if (!name->IsUniqueName()) return kAbsent;
int index = Hash(source, name);
Key& key = keys_[index];
if ((key.source == source) && (key.name == name)) return results_[index];
@@ -634,13 +643,11 @@ int DescriptorLookupCache::Lookup(Map* source, Name* name) {
void DescriptorLookupCache::Update(Map* source, Name* name, int result) {
DCHECK(result != kAbsent);
- if (name->IsUniqueName()) {
- int index = Hash(source, name);
- Key& key = keys_[index];
- key.source = source;
- key.name = name;
- results_[index] = result;
- }
+ int index = Hash(source, name);
+ Key& key = keys_[index];
+ key.source = source;
+ key.name = name;
+ results_[index] = result;
}
« no previous file with comments | « src/heap/heap.cc ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698