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

Side by Side Diff: src/heap.cc

Issue 9269004: Fix keyed lookup cache to have 2 entried per bucket instead (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6497 matching lines...) Expand 10 before | Expand all | Expand 10 after
6508 6508
6509 int KeyedLookupCache::Hash(Map* map, String* name) { 6509 int KeyedLookupCache::Hash(Map* map, String* name) {
6510 // Uses only lower 32 bits if pointers are larger. 6510 // Uses only lower 32 bits if pointers are larger.
6511 uintptr_t addr_hash = 6511 uintptr_t addr_hash =
6512 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> kMapHashShift; 6512 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> kMapHashShift;
6513 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); 6513 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask);
6514 } 6514 }
6515 6515
6516 6516
6517 int KeyedLookupCache::Lookup(Map* map, String* name) { 6517 int KeyedLookupCache::Lookup(Map* map, String* name) {
6518 int index = Hash(map, name); 6518 int index = (Hash(map, name) & kHashMask);
6519 Key& key = keys_[index]; 6519 Key& key = keys_[index];
6520 if ((key.map == map) && key.name->Equals(name)) { 6520 if ((key.map == map) && key.name->Equals(name)) {
6521 return field_offsets_[index]; 6521 return field_offsets_[index];
6522 } 6522 }
6523 ASSERT(kEntriesPerBucket == 2); // There are two entries to check.
6524 // First entry in the bucket missed, check the second.
6525 Key& key2 = keys_[index + 1];
6526 if ((key2.map == map) && key2.name->Equals(name)) {
6527 return field_offsets_[index + 1];
6528 }
6523 return kNotFound; 6529 return kNotFound;
6524 } 6530 }
6525 6531
6526 6532
6527 void KeyedLookupCache::Update(Map* map, String* name, int field_offset) { 6533 void KeyedLookupCache::Update(Map* map, String* name, int field_offset) {
6528 String* symbol; 6534 String* symbol;
6529 if (HEAP->LookupSymbolIfExists(name, &symbol)) { 6535 if (HEAP->LookupSymbolIfExists(name, &symbol)) {
6530 int index = Hash(map, symbol); 6536 int index = (Hash(map, symbol) & kHashMask);
6531 Key& key = keys_[index]; 6537 Key& key = keys_[index];
6538 Key& key2 = keys_[index + 1]; // Second entry in the bucket.
6539 // Demote the first entry to the second in the bucket.
6540 key2.map = key.map;
6541 key2.name = key.name;
6542 field_offsets_[index + 1] = field_offsets_[index];
6543 // Write the new first entry.
6532 key.map = map; 6544 key.map = map;
6533 key.name = symbol; 6545 key.name = symbol;
6534 field_offsets_[index] = field_offset; 6546 field_offsets_[index] = field_offset;
6535 } 6547 }
6536 } 6548 }
6537 6549
6538 6550
6539 void KeyedLookupCache::Clear() { 6551 void KeyedLookupCache::Clear() {
6540 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; 6552 for (int index = 0; index < kLength; index++) keys_[index].map = NULL;
6541 } 6553 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
6656 isolate_->heap()->store_buffer()->Compact(); 6668 isolate_->heap()->store_buffer()->Compact();
6657 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6669 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6658 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6670 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6659 next = chunk->next_chunk(); 6671 next = chunk->next_chunk();
6660 isolate_->memory_allocator()->Free(chunk); 6672 isolate_->memory_allocator()->Free(chunk);
6661 } 6673 }
6662 chunks_queued_for_free_ = NULL; 6674 chunks_queued_for_free_ = NULL;
6663 } 6675 }
6664 6676
6665 } } // namespace v8::internal 6677 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698