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

Unified Diff: src/objects.cc

Issue 688853007: Implement aging of maps embedded in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index ab13412f52989ecc7eb9e6510ab6d46afe0a9e73..4754c8afae2b5ff492ed1349f2054982c4dc6159 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -14211,7 +14211,10 @@ template class HashTable<ObjectHashTable,
ObjectHashTableShape,
Handle<Object> >;
-template class HashTable<WeakHashTable, WeakHashTableShape<2>, Handle<Object> >;
+template class HashTable<WeakHashTable, HeapPointerShape<2>, Handle<Object> >;
+
+template class HashTable<EmbeddedMapCache, HeapPointerShape<2>,
+ Handle<Object> >;
template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >;
@@ -15690,6 +15693,45 @@ void WeakHashTable::AddEntry(int entry,
}
+Handle<EmbeddedMapCache> EmbeddedMapCache::Put(Handle<EmbeddedMapCache> table,
+ Handle<Map> key) {
+ DCHECK(table->IsKey(*key));
+ int entry = table->FindEntry(key);
+ // Key is already in table, just overwrite value.
+ if (entry != kNotFound) {
+ table->set(EntryToValueIndex(entry), Smi::FromInt(0), SKIP_WRITE_BARRIER);
+ return table;
+ }
+
+ // Check whether the hash table should be extended.
+ table = EnsureCapacity(table, 1, key, TENURED);
+ DisallowHeapAllocation no_allocation;
+ entry = table->FindInsertionEntry(table->Hash(key));
+ table->set(EntryToIndex(entry), *key);
+ table->set(EntryToValueIndex(entry), Smi::FromInt(0), SKIP_WRITE_BARRIER);
+ table->ElementAdded();
+ return table;
+}
+
+
+void EmbeddedMapCache::Age() {
+ int capacity = Capacity();
+ for (int i = 0; i < capacity; i++) {
+ Object* value = get(EntryToValueIndex(i));
+ if (value->IsSmi()) {
+ int age = Smi::cast(value)->value();
+ if (age > kMaxAge) {
+ set_the_hole(EntryToIndex(i));
+ set_the_hole(EntryToIndex(i) + 1);
+ ElementRemoved();
+ } else {
+ set(EntryToValueIndex(i), Smi::FromInt(age + 1), SKIP_WRITE_BARRIER);
+ }
+ }
+ }
+}
+
+
template<class Derived, class Iterator, int entrysize>
Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Allocate(
Isolate* isolate, int capacity, PretenureFlag pretenure) {

Powered by Google App Engine
This is Rietveld 408576698