WeakHashTable* table =
WeakHashTable::cast(heap_->weak_object_to_code_table());
table->Iterate(&updating_visitor);
- table->Rehash(heap_->undefined_value());
+ table->Rehash(heap_->isolate()->factory()->undefined_value());
}
// Update pointers from external string table.
}
-bool ObjectHashTableShape::IsMatch(Object* key, Object* other) {
+bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
return key->SameValue(other);
}
-uint32_t ObjectHashTableShape::Hash(Object* key) {
+uint32_t ObjectHashTableShape::Hash(Handle<Object> key) {
return Smi::cast(key->GetHash())->value();
}
-uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) {
+uint32_t ObjectHashTableShape::HashForObject(Handle<Object> key,
+ Object* other) {
return Smi::cast(other->GetHash())->value();
}
-MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) {
+MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Handle<Object> key) {
+ return *key;
+}
+
+
+Handle<Object> ObjectHashTableShape::AsHandle(Isolate* isolate,
+ Handle<Object> key) {
return key;
}
Handle<ObjectHashTable> ObjectHashTable::Shrink(
Handle<ObjectHashTable> table, Handle<Object> key) {
- return DerivedHashTable::Shrink(table, *key);
+ return DerivedHashTable::Shrink(table, key);
}
template <int entrysize>
-bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) {
+bool WeakHashTableShape<entrysize>::IsMatch(Handle<Object> key, Object* other) {
return key->SameValue(other);
}
template <int entrysize>
-uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) {
- intptr_t hash = reinterpret_cast<intptr_t>(key);
+uint32_t WeakHashTableShape<entrysize>::Hash(Handle<Object> key) {
+ intptr_t hash = reinterpret_cast<intptr_t>(*key);
return (uint32_t)(hash & 0xFFFFFFFF);
}
template <int entrysize>
-uint32_t WeakHashTableShape<entrysize>::HashForObject(Object* key,
+uint32_t WeakHashTableShape<entrysize>::HashForObject(Handle<Object> key,
Object* other) {
intptr_t hash = reinterpret_cast<intptr_t>(other);
return (uint32_t)(hash & 0xFFFFFFFF);
template <int entrysize>
-MaybeObject* WeakHashTableShape<entrysize>::AsObject(Heap* heap,
- Object* key) {
+Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate,
+ Handle<Object> key) {
return key;
}
template class HashTable<MapCache, MapCacheShape, HashTableKey*>;
-template class HashTable<ObjectHashTable, ObjectHashTableShape, Object*>;
+template class HashTable<ObjectHashTable,
+ ObjectHashTableShape,
+ Handle<Object> >;
-template class HashTable<WeakHashTable, WeakHashTableShape<2>, Object*>;
+template class HashTable<WeakHashTable, WeakHashTableShape<2>, Handle<Object> >;
template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >;
}
+// TODO(ishell): Try to remove this when FindEntry(Object* key) is removed
+int ObjectHashTable::FindEntry(Handle<Object> key) {
+ return DerivedHashTable::FindEntry(key);
+}
+
+
+// TODO(ishell): Remove this when all the callers are handlified.
+int ObjectHashTable::FindEntry(Object* key) {
+ DisallowHeapAllocation no_allocation;
+ Isolate* isolate = GetIsolate();
+ HandleScope scope(isolate);
+ return FindEntry(handle(key, isolate));
+}
+
+
Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
Handle<Object> key,
Handle<Object> value) {
// Make sure the key object has an identity hash code.
Handle<Object> hash = Object::GetOrCreateHash(key, isolate);
- int entry = table->FindEntry(*key);
+ int entry = table->FindEntry(key);
// Check whether to perform removal operation.
if (value->IsTheHole()) {
}
// Check whether the hash table should be extended.
- table = EnsureCapacity(table, 1, *key);
+ table = EnsureCapacity(table, 1, key);
table->AddEntry(table->FindInsertionEntry(Handle<Smi>::cast(hash)->value()),
*key,
*value);
}
+// TODO(ishell): Try to remove this when FindEntry(Object* key) is removed
+int WeakHashTable::FindEntry(Handle<Object> key) {
+ return DerivedHashTable::FindEntry(key);
+}
+
+
+// TODO(ishell): Remove this when all the callers are handlified.
+int WeakHashTable::FindEntry(Object* key) {
+ DisallowHeapAllocation no_allocation;
+ Isolate* isolate = GetIsolate();
+ HandleScope scope(isolate);
+ return FindEntry(handle(key, isolate));
+}
+
+
Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table,
Handle<Object> key,
Handle<Object> value) {
ASSERT(table->IsKey(*key));
- int entry = table->FindEntry(*key);
+ int entry = table->FindEntry(key);
// Key is already in table, just overwrite value.
if (entry != kNotFound) {
table->set(EntryToValueIndex(entry), *value);
}
// Check whether the hash table should be extended.
- table = EnsureCapacity(table, 1, *key, TENURED);
+ table = EnsureCapacity(table, 1, key, TENURED);
- table->AddEntry(table->FindInsertionEntry(table->Hash(*key)), key, value);
+ table->AddEntry(table->FindInsertionEntry(table->Hash(key)), key, value);
return table;
}
// Wrapper methods
inline uint32_t Hash(Key key) {
if (Shape::UsesSeed) {
- return Shape::SeededHash(key,
- GetHeap()->HashSeed());
+ return Shape::SeededHash(key, GetHeap()->HashSeed());
} else {
return Shape::Hash(key);
}
inline uint32_t HashForObject(Key key, Object* object) {
if (Shape::UsesSeed) {
- return Shape::SeededHashForObject(key,
- GetHeap()->HashSeed(), object);
+ return Shape::SeededHashForObject(key, GetHeap()->HashSeed(), object);
} else {
return Shape::HashForObject(key, object);
}
};
-class ObjectHashTableShape : public BaseShape<Object*> {
+class ObjectHashTableShape : public BaseShape<Handle<Object> > {
public:
- static inline bool IsMatch(Object* key, Object* other);
- static inline uint32_t Hash(Object* key);
- static inline uint32_t HashForObject(Object* key, Object* object);
+ static inline bool IsMatch(Handle<Object> key, Object* other);
+ static inline uint32_t Hash(Handle<Object> key);
+ static inline uint32_t HashForObject(Handle<Object> key, Object* object);
MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
- Object* key);
+ Handle<Object> key);
+ static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key);
static const int kPrefixSize = 0;
static const int kEntrySize = 2;
};
// using the identity hash of the key for hashing purposes.
class ObjectHashTable: public HashTable<ObjectHashTable,
ObjectHashTableShape,
- Object*> {
+ Handle<Object> > {
typedef HashTable<
- ObjectHashTable, ObjectHashTableShape, Object*> DerivedHashTable;
+ ObjectHashTable, ObjectHashTableShape, Handle<Object> > DerivedHashTable;
public:
static inline ObjectHashTable* cast(Object* obj) {
ASSERT(obj->IsHashTable());
// returned in case the key is not present.
Object* Lookup(Object* key);
+ int FindEntry(Handle<Object> key);
+ // TODO(ishell): Remove this when all the callers are handlified.
+ int FindEntry(Object* key);
+
// Adds (or overwrites) the value associated with the given key. Mapping a
// key to the hole value causes removal of the whole entry.
static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
template <int entrysize>
-class WeakHashTableShape : public BaseShape<Object*> {
+class WeakHashTableShape : public BaseShape<Handle<Object> > {
public:
- static inline bool IsMatch(Object* key, Object* other);
- static inline uint32_t Hash(Object* key);
- static inline uint32_t HashForObject(Object* key, Object* object);
- MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
- Object* key);
+ static inline bool IsMatch(Handle<Object> key, Object* other);
+ static inline uint32_t Hash(Handle<Object> key);
+ static inline uint32_t HashForObject(Handle<Object> key, Object* object);
+ static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key);
static const int kPrefixSize = 0;
static const int kEntrySize = entrysize;
};
// embedded in optimized code to dependent code lists.
class WeakHashTable: public HashTable<WeakHashTable,
WeakHashTableShape<2>,
- Object*> {
+ Handle<Object> > {
+ typedef HashTable<
+ WeakHashTable, WeakHashTableShape<2>, Handle<Object> > DerivedHashTable;
public:
static inline WeakHashTable* cast(Object* obj) {
ASSERT(obj->IsHashTable());
// returned in case the key is not present.
Object* Lookup(Object* key);
+ int FindEntry(Handle<Object> key);
+ // TODO(ishell): Remove this when all the callers are handlified.
+ int FindEntry(Object* key);
+
// Adds (or overwrites) the value associated with the given key. Mapping a
// key to the hole value causes removal of the whole entry.
MUST_USE_RESULT static Handle<WeakHashTable> Put(Handle<WeakHashTable> table,
for (int i = 0; i < capacity - 1; i++) {
t->insert(i, i * i, i);
}
- t->Rehash(Smi::FromInt(0));
+ t->Rehash(handle(Smi::FromInt(0), isolate));
for (int i = 0; i < capacity - 1; i++) {
CHECK_EQ(i, t->lookup(i * i));
}
for (int i = 0; i < capacity / 2; i++) {
t->insert(i, i * i, i);
}
- t->Rehash(Smi::FromInt(0));
+ t->Rehash(handle(Smi::FromInt(0), isolate));
for (int i = 0; i < capacity / 2; i++) {
CHECK_EQ(i, t->lookup(i * i));
}