Commit f4dc0ee8 authored by ishell@chromium.org's avatar ishell@chromium.org

Revert "Reland "HashTable::Shrink() handlified and derived template parameter...

Revert "Reland "HashTable::Shrink() handlified and derived template parameter added to HashTable hierarchy.""

This reverts r20724.

TBR=jarin@chromium.org

Review URL: https://codereview.chromium.org/237043002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20726 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 92d2c696
...@@ -2882,8 +2882,8 @@ DescriptorArray::WhitenessWitness::~WhitenessWitness() { ...@@ -2882,8 +2882,8 @@ DescriptorArray::WhitenessWitness::~WhitenessWitness() {
} }
template<typename Derived, typename Shape, typename Key> template<typename Shape, typename Key>
int HashTable<Derived, Shape, Key>::ComputeCapacity(int at_least_space_for) { int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) {
const int kMinCapacity = 32; const int kMinCapacity = 32;
int capacity = RoundUpToPowerOf2(at_least_space_for * 2); int capacity = RoundUpToPowerOf2(at_least_space_for * 2);
if (capacity < kMinCapacity) { if (capacity < kMinCapacity) {
...@@ -2893,17 +2893,17 @@ int HashTable<Derived, Shape, Key>::ComputeCapacity(int at_least_space_for) { ...@@ -2893,17 +2893,17 @@ int HashTable<Derived, Shape, Key>::ComputeCapacity(int at_least_space_for) {
} }
template<typename Derived, typename Shape, typename Key> template<typename Shape, typename Key>
int HashTable<Derived, Shape, Key>::FindEntry(Key key) { int HashTable<Shape, Key>::FindEntry(Key key) {
return FindEntry(GetIsolate(), key); return FindEntry(GetIsolate(), key);
} }
// Find entry for key otherwise return kNotFound. // Find entry for key otherwise return kNotFound.
template<typename Derived, typename Shape, typename Key> template<typename Shape, typename Key>
int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) {
uint32_t capacity = Capacity(); uint32_t capacity = Capacity();
uint32_t entry = FirstProbe(HashTable::Hash(key), capacity); uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity);
uint32_t count = 1; uint32_t count = 1;
// EnsureCapacity will guarantee the hash table is never full. // EnsureCapacity will guarantee the hash table is never full.
while (true) { while (true) {
...@@ -3028,9 +3028,8 @@ FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) { ...@@ -3028,9 +3028,8 @@ FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
#undef MAKE_STRUCT_CAST #undef MAKE_STRUCT_CAST
template <typename Derived, typename Shape, typename Key> template <typename Shape, typename Key>
HashTable<Derived, Shape, Key>* HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
HashTable<Derived, Shape, Key>::cast(Object* obj) {
ASSERT(obj->IsHashTable()); ASSERT(obj->IsHashTable());
return reinterpret_cast<HashTable*>(obj); return reinterpret_cast<HashTable*>(obj);
} }
...@@ -6672,23 +6671,23 @@ bool AccessorPair::prohibits_overwriting() { ...@@ -6672,23 +6671,23 @@ bool AccessorPair::prohibits_overwriting() {
} }
template<typename Derived, typename Shape, typename Key> template<typename Shape, typename Key>
void Dictionary<Derived, Shape, Key>::SetEntry(int entry, void Dictionary<Shape, Key>::SetEntry(int entry,
Object* key, Object* key,
Object* value) { Object* value) {
SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
} }
template<typename Derived, typename Shape, typename Key> template<typename Shape, typename Key>
void Dictionary<Derived, Shape, Key>::SetEntry(int entry, void Dictionary<Shape, Key>::SetEntry(int entry,
Object* key, Object* key,
Object* value, Object* value,
PropertyDetails details) { PropertyDetails details) {
ASSERT(!key->IsName() || ASSERT(!key->IsName() ||
details.IsDeleted() || details.IsDeleted() ||
details.dictionary_index() > 0); details.dictionary_index() > 0);
int index = DerivedHashTable::EntryToIndex(entry); int index = HashTable<Shape, Key>::EntryToIndex(entry);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc);
FixedArray::set(index, key, mode); FixedArray::set(index, key, mode);
...@@ -6774,12 +6773,6 @@ MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) { ...@@ -6774,12 +6773,6 @@ MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) {
} }
Handle<ObjectHashTable> ObjectHashTable::Shrink(
Handle<ObjectHashTable> table, Handle<Object> key) {
return HashTable_::Shrink(table, *key);
}
template <int entrysize> template <int entrysize>
bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) {
return key->SameValue(other); return key->SameValue(other);
......
This diff is collapsed.
...@@ -3656,7 +3656,7 @@ class BaseShape { ...@@ -3656,7 +3656,7 @@ class BaseShape {
} }
}; };
template<typename Derived, typename Shape, typename Key> template<typename Shape, typename Key>
class HashTable: public FixedArray { class HashTable: public FixedArray {
public: public:
// Wrapper methods // Wrapper methods
...@@ -3709,20 +3709,12 @@ class HashTable: public FixedArray { ...@@ -3709,20 +3709,12 @@ class HashTable: public FixedArray {
} }
// Returns a new HashTable object. Might return Failure. // Returns a new HashTable object. Might return Failure.
// TODO(ishell): this will be eventually replaced by New().
MUST_USE_RESULT static MaybeObject* Allocate( MUST_USE_RESULT static MaybeObject* Allocate(
Heap* heap, Heap* heap,
int at_least_space_for, int at_least_space_for,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY, MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
// Returns a new HashTable object.
static Handle<Derived> New(
Isolate* isolate,
int at_least_space_for,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
PretenureFlag pretenure = NOT_TENURED);
// Computes the required capacity for a table holding the given // Computes the required capacity for a table holding the given
// number of elements. May be more than HashTable::kMaxCapacity. // number of elements. May be more than HashTable::kMaxCapacity.
static int ComputeCapacity(int at_least_space_for); static int ComputeCapacity(int at_least_space_for);
...@@ -3832,10 +3824,10 @@ class HashTable: public FixedArray { ...@@ -3832,10 +3824,10 @@ class HashTable: public FixedArray {
void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode);
// Rehashes this hash-table into the new table. // Rehashes this hash-table into the new table.
void Rehash(Derived* new_table, Key key); MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key);
// Attempt to shrink hash table after removal of key. // Attempt to shrink hash table after removal of key.
static Handle<Derived> Shrink(Handle<Derived> table, Key key); MUST_USE_RESULT MaybeObject* Shrink(Key key);
// Ensure enough space for n additional elements. // Ensure enough space for n additional elements.
MUST_USE_RESULT MaybeObject* EnsureCapacity( MUST_USE_RESULT MaybeObject* EnsureCapacity(
...@@ -3888,9 +3880,7 @@ class SeqOneByteString; ...@@ -3888,9 +3880,7 @@ class SeqOneByteString;
// //
// No special elements in the prefix and the element size is 1 // No special elements in the prefix and the element size is 1
// because only the string itself (the key) needs to be stored. // because only the string itself (the key) needs to be stored.
class StringTable: public HashTable<StringTable, class StringTable: public HashTable<StringTableShape, HashTableKey*> {
StringTableShape,
HashTableKey*> {
public: public:
// Find string in the string table. If it is not there yet, it is // Find string in the string table. If it is not there yet, it is
// added. The return value is the string table which might have // added. The return value is the string table which might have
...@@ -3942,7 +3932,7 @@ class MapCacheShape : public BaseShape<HashTableKey*> { ...@@ -3942,7 +3932,7 @@ class MapCacheShape : public BaseShape<HashTableKey*> {
// //
// Maps keys that are a fixed array of unique names to a map. // Maps keys that are a fixed array of unique names to a map.
// Used for canonicalize maps for object literals. // Used for canonicalize maps for object literals.
class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> { class MapCache: public HashTable<MapCacheShape, HashTableKey*> {
public: public:
// Find cached value for a name key, otherwise return null. // Find cached value for a name key, otherwise return null.
Object* Lookup(FixedArray* key); Object* Lookup(FixedArray* key);
...@@ -3954,36 +3944,33 @@ class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> { ...@@ -3954,36 +3944,33 @@ class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> {
}; };
template <typename Derived, typename Shape, typename Key> template <typename Shape, typename Key>
class Dictionary: public HashTable<Derived, Shape, Key> { class Dictionary: public HashTable<Shape, Key> {
protected:
typedef HashTable<Derived, Shape, Key> DerivedHashTable;
public: public:
static inline Dictionary* cast(Object* obj) { static inline Dictionary<Shape, Key>* cast(Object* obj) {
return reinterpret_cast<Dictionary*>(obj); return reinterpret_cast<Dictionary<Shape, Key>*>(obj);
} }
// Returns the value at entry. // Returns the value at entry.
Object* ValueAt(int entry) { Object* ValueAt(int entry) {
return this->get(DerivedHashTable::EntryToIndex(entry) + 1); return this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 1);
} }
// Set the value for entry. // Set the value for entry.
void ValueAtPut(int entry, Object* value) { void ValueAtPut(int entry, Object* value) {
this->set(DerivedHashTable::EntryToIndex(entry) + 1, value); this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 1, value);
} }
// Returns the property details for the property at entry. // Returns the property details for the property at entry.
PropertyDetails DetailsAt(int entry) { PropertyDetails DetailsAt(int entry) {
ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). ASSERT(entry >= 0); // Not found is -1, which is not caught by get().
return PropertyDetails( return PropertyDetails(
Smi::cast(this->get(DerivedHashTable::EntryToIndex(entry) + 2))); Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2)));
} }
// Set the details for entry. // Set the details for entry.
void DetailsAtPut(int entry, PropertyDetails value) { void DetailsAtPut(int entry, PropertyDetails value) {
this->set(DerivedHashTable::EntryToIndex(entry) + 2, value.AsSmi()); this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 2, value.AsSmi());
} }
// Sorting support // Sorting support
...@@ -3993,14 +3980,16 @@ class Dictionary: public HashTable<Derived, Shape, Key> { ...@@ -3993,14 +3980,16 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
Object* DeleteProperty(int entry, JSObject::DeleteMode mode); Object* DeleteProperty(int entry, JSObject::DeleteMode mode);
// TODO(ishell): Temporary wrapper until handlified. // TODO(ishell): Temporary wrapper until handlified.
static Handle<Object> DeleteProperty( static Handle<Object> DeleteProperty(
Handle<Dictionary> dictionary, Handle<Dictionary<Shape, Key> > dictionary,
int entry, int entry,
JSObject::DeleteMode mode); JSObject::DeleteMode mode);
// Attempt to shrink the dictionary after deletion of key. // Attempt to shrink the dictionary after deletion of key.
static inline Handle<Derived> Shrink(Handle<Derived> dictionary, Key key) { MUST_USE_RESULT MaybeObject* Shrink(Key key);
return DerivedHashTable::Shrink(dictionary, key); // TODO(ishell): Temporary wrapper until handlified.
} MUST_USE_RESULT static Handle<FixedArray> Shrink(
Handle<Dictionary<Shape, Key> > dictionary,
Key key);
// Returns the number of elements in the dictionary filtering out properties // Returns the number of elements in the dictionary filtering out properties
// with the specified attributes. // with the specified attributes.
...@@ -4070,7 +4059,8 @@ class Dictionary: public HashTable<Derived, Shape, Key> { ...@@ -4070,7 +4059,8 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
// Generate new enumeration indices to avoid enumeration index overflow. // Generate new enumeration indices to avoid enumeration index overflow.
MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices();
static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; static const int kMaxNumberKeyIndex =
HashTable<Shape, Key>::kPrefixStartIndex;
static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
}; };
...@@ -4088,9 +4078,7 @@ class NameDictionaryShape : public BaseShape<Name*> { ...@@ -4088,9 +4078,7 @@ class NameDictionaryShape : public BaseShape<Name*> {
}; };
class NameDictionary: public Dictionary<NameDictionary, class NameDictionary: public Dictionary<NameDictionaryShape, Name*> {
NameDictionaryShape,
Name*> {
public: public:
static inline NameDictionary* cast(Object* obj) { static inline NameDictionary* cast(Object* obj) {
ASSERT(obj->IsDictionary()); ASSERT(obj->IsDictionary());
...@@ -4140,9 +4128,7 @@ class UnseededNumberDictionaryShape : public NumberDictionaryShape { ...@@ -4140,9 +4128,7 @@ class UnseededNumberDictionaryShape : public NumberDictionaryShape {
class SeededNumberDictionary class SeededNumberDictionary
: public Dictionary<SeededNumberDictionary, : public Dictionary<SeededNumberDictionaryShape, uint32_t> {
SeededNumberDictionaryShape,
uint32_t> {
public: public:
static SeededNumberDictionary* cast(Object* obj) { static SeededNumberDictionary* cast(Object* obj) {
ASSERT(obj->IsDictionary()); ASSERT(obj->IsDictionary());
...@@ -4195,9 +4181,7 @@ class SeededNumberDictionary ...@@ -4195,9 +4181,7 @@ class SeededNumberDictionary
class UnseededNumberDictionary class UnseededNumberDictionary
: public Dictionary<UnseededNumberDictionary, : public Dictionary<UnseededNumberDictionaryShape, uint32_t> {
UnseededNumberDictionaryShape,
uint32_t> {
public: public:
static UnseededNumberDictionary* cast(Object* obj) { static UnseededNumberDictionary* cast(Object* obj) {
ASSERT(obj->IsDictionary()); ASSERT(obj->IsDictionary());
...@@ -4233,10 +4217,7 @@ class ObjectHashTableShape : public BaseShape<Object*> { ...@@ -4233,10 +4217,7 @@ class ObjectHashTableShape : public BaseShape<Object*> {
// ObjectHashTable maps keys that are arbitrary objects to object values by // ObjectHashTable maps keys that are arbitrary objects to object values by
// using the identity hash of the key for hashing purposes. // using the identity hash of the key for hashing purposes.
class ObjectHashTable: public HashTable<ObjectHashTable, class ObjectHashTable: public HashTable<ObjectHashTableShape, Object*> {
ObjectHashTableShape,
Object*> {
typedef HashTable<ObjectHashTable, ObjectHashTableShape, Object*> HashTable_;
public: public:
static inline ObjectHashTable* cast(Object* obj) { static inline ObjectHashTable* cast(Object* obj) {
ASSERT(obj->IsHashTable()); ASSERT(obj->IsHashTable());
...@@ -4250,7 +4231,7 @@ class ObjectHashTable: public HashTable<ObjectHashTable, ...@@ -4250,7 +4231,7 @@ class ObjectHashTable: public HashTable<ObjectHashTable,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
// Attempt to shrink hash table after removal of key. // Attempt to shrink hash table after removal of key.
static inline Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table, static Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table,
Handle<Object> key); Handle<Object> key);
// Looks up the value associated with the given key. The hole value is // Looks up the value associated with the given key. The hole value is
...@@ -4449,9 +4430,7 @@ class WeakHashTableShape : public BaseShape<Object*> { ...@@ -4449,9 +4430,7 @@ class WeakHashTableShape : public BaseShape<Object*> {
// WeakHashTable maps keys that are arbitrary objects to object values. // WeakHashTable maps keys that are arbitrary objects to object values.
// It is used for the global weak hash table that maps objects // It is used for the global weak hash table that maps objects
// embedded in optimized code to dependent code lists. // embedded in optimized code to dependent code lists.
class WeakHashTable: public HashTable<WeakHashTable, class WeakHashTable: public HashTable<WeakHashTableShape<2>, Object*> {
WeakHashTableShape<2>,
Object*> {
public: public:
static inline WeakHashTable* cast(Object* obj) { static inline WeakHashTable* cast(Object* obj) {
ASSERT(obj->IsHashTable()); ASSERT(obj->IsHashTable());
...@@ -8221,8 +8200,7 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> { ...@@ -8221,8 +8200,7 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> {
}; };
class CompilationCacheTable: public HashTable<CompilationCacheTable, class CompilationCacheTable: public HashTable<CompilationCacheShape,
CompilationCacheShape,
HashTableKey*> { HashTableKey*> {
public: public:
// Find cached value for a string key, otherwise return null. // Find cached value for a string key, otherwise return null.
...@@ -8323,8 +8301,7 @@ class CodeCacheHashTableShape : public BaseShape<HashTableKey*> { ...@@ -8323,8 +8301,7 @@ class CodeCacheHashTableShape : public BaseShape<HashTableKey*> {
}; };
class CodeCacheHashTable: public HashTable<CodeCacheHashTable, class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
CodeCacheHashTableShape,
HashTableKey*> { HashTableKey*> {
public: public:
Object* Lookup(Name* name, Code::Flags flags); Object* Lookup(Name* name, Code::Flags flags);
...@@ -8374,9 +8351,7 @@ class PolymorphicCodeCache: public Struct { ...@@ -8374,9 +8351,7 @@ class PolymorphicCodeCache: public Struct {
class PolymorphicCodeCacheHashTable class PolymorphicCodeCacheHashTable
: public HashTable<PolymorphicCodeCacheHashTable, : public HashTable<CodeCacheHashTableShape, HashTableKey*> {
CodeCacheHashTableShape,
HashTableKey*> {
public: public:
Object* Lookup(MapHandleList* maps, int code_kind); Object* Lookup(MapHandleList* maps, int code_kind);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment