Revision: 20982
Author: [email protected]
Date: Fri Apr 25 13:35:03 2014 UTC
Log: ObjectHashTable's key and WeakHashTable's key types are now
Handle<Object> instead of Object*.
[email protected]
Review URL: https://codereview.chromium.org/257853003
http://code.google.com/p/v8/source/detail?r=20982
Modified:
/branches/bleeding_edge/src/mark-compact.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/test/cctest/test-dictionary.cc
=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Fri Apr 25 11:00:37 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.cc Fri Apr 25 13:35:03 2014 UTC
@@ -3670,7 +3670,7 @@
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.
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Fri Apr 25 13:21:16 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Fri Apr 25 13:35:03 2014 UTC
@@ -6683,47 +6683,54 @@
}
-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);
@@ -6731,8 +6738,8 @@
template <int entrysize>
-MaybeObject* WeakHashTableShape<entrysize>::AsObject(Heap* heap,
- Object* key) {
+Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate,
+ Handle<Object> key)
{
return key;
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Apr 25 13:21:16 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Fri Apr 25 13:35:03 2014 UTC
@@ -14855,9 +14855,11 @@
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> >;
@@ -16137,6 +16139,21 @@
}
+// 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) {
@@ -16147,7 +16164,7 @@
// 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()) {
@@ -16163,7 +16180,7 @@
}
// 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);
@@ -16191,13 +16208,28 @@
if (entry == kNotFound) return GetHeap()->the_hole_value();
return get(EntryToValueIndex(entry));
}
+
+
+// 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);
@@ -16205,9 +16237,9 @@
}
// 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;
}
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Apr 25 13:21:16 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Fri Apr 25 13:35:03 2014 UTC
@@ -3667,8 +3667,7 @@
// 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);
}
@@ -3676,8 +3675,7 @@
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);
}
@@ -4237,13 +4235,14 @@
};
-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;
};
@@ -4253,9 +4252,9 @@
// 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());
@@ -4271,6 +4270,10 @@
// 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,
@@ -4469,13 +4472,12 @@
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;
};
@@ -4486,7 +4488,9 @@
// 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());
@@ -4497,6 +4501,10 @@
// 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,
=======================================
--- /branches/bleeding_edge/test/cctest/test-dictionary.cc Fri Apr 25
13:06:21 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-dictionary.cc Fri Apr 25
13:35:03 2014 UTC
@@ -140,7 +140,7 @@
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));
}
@@ -153,7 +153,7 @@
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));
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.