template<typename Derived, typename Shape, typename Key>
void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
- Object* key,
- Object* value) {
+ Handle<Object> key,
+ Handle<Object> value) {
SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
}
template<typename Derived, typename Shape, typename Key>
void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
- Object* key,
- Object* value,
+ Handle<Object> key,
+ Handle<Object> value,
PropertyDetails details) {
ASSERT(!key->IsName() ||
details.IsDeleted() ||
int index = DerivedHashTable::EntryToIndex(entry);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc);
- FixedArray::set(index, key, mode);
- FixedArray::set(index+1, value, mode);
+ FixedArray::set(index, *key, mode);
+ FixedArray::set(index+1, *value, mode);
FixedArray::set(index+2, details.AsSmi());
}
Handle<ObjectHashTable> ObjectHashTable::Shrink(
Handle<ObjectHashTable> table, Handle<Object> key) {
- return HashTable_::Shrink(table, *key);
+ return DerivedHashTable::Shrink(table, *key);
}
// Please note we have to update the property details.
property_dictionary->DetailsAtPut(entry, details);
} else {
- property_dictionary->SetEntry(entry, *name, *value, details);
+ property_dictionary->SetEntry(entry, name, value, details);
}
}
int index = dict->NextEnumerationIndex();
PropertyDetails details = PropertyDetails(attributes, NORMAL, index);
dict->SetNextEnumerationIndex(index + 1);
- dict->SetEntry(entry, *name, *cell, details);
+ dict->SetEntry(entry, name, cell, details);
return;
}
Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value);
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>);
-template MaybeObject*
-Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
- AddEntry(uint32_t, Object*, PropertyDetails, uint32_t);
-
-template MaybeObject*
-Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
- AddEntry(uint32_t, Object*, PropertyDetails, uint32_t);
-
-template MaybeObject*
-Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::AddEntry(
- Handle<Name>, Object*, PropertyDetails, uint32_t);
-
template
int Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
NumberOfEnumElements();
if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) {
return factory->false_value();
}
+
dictionary->SetEntry(
- entry, *factory->the_hole_value(), *factory->the_hole_value());
+ entry, factory->the_hole_value(), factory->the_hole_value());
dictionary->ElementRemoved();
return factory->true_value();
}
USE(k);
PropertyDetails details = PropertyDetails(NONE, NORMAL, 0);
- return AddEntry(dictionary, key, value, details, dictionary->Hash(key));
+ AddEntry(dictionary, key, value, details, dictionary->Hash(key));
+ return dictionary;
}
// Check whether the dictionary should be extended.
dictionary = EnsureCapacity(dictionary, 1, key);
- return AddEntry(dictionary, key, value, details, dictionary->Hash(key));
+ AddEntry(dictionary, key, value, details, dictionary->Hash(key));
+ return dictionary;
}
// Add a key, value pair to the dictionary.
template<typename Derived, typename Shape, typename Key>
-Handle<Derived> Dictionary<Derived, Shape, Key>::AddEntry(
+void Dictionary<Derived, Shape, Key>::AddEntry(
Handle<Derived> dictionary,
Key key,
Handle<Object> value,
PropertyDetails details,
uint32_t hash) {
- CALL_HEAP_FUNCTION(
- dictionary->GetIsolate(),
- dictionary->AddEntry(key, *value, details, hash),
- Derived);
-}
-
-template<typename Derived, typename Shape, typename Key>
-MaybeObject* Dictionary<Derived, Shape, Key>::AddEntry(
- Key key,
- Object* value,
- PropertyDetails details,
- uint32_t hash) {
// Compute the key object.
- Object* k;
- { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key);
- if (!maybe_k->ToObject(&k)) return maybe_k;
- }
+ Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key);
- uint32_t entry = Dictionary::FindInsertionEntry(hash);
+ uint32_t entry = dictionary->FindInsertionEntry(hash);
// Insert element at empty or deleted entry
if (!details.IsDeleted() &&
details.dictionary_index() == 0 &&
Shape::kIsEnumerable) {
// Assign an enumeration index to the property and update
// SetNextEnumerationIndex.
- int index = NextEnumerationIndex();
+ int index = dictionary->NextEnumerationIndex();
details = PropertyDetails(details.attributes(), details.type(), index);
- SetNextEnumerationIndex(index + 1);
+ dictionary->SetNextEnumerationIndex(index + 1);
}
- SetEntry(entry, k, value, details);
- ASSERT((Dictionary::KeyAt(entry)->IsNumber() ||
- Dictionary::KeyAt(entry)->IsName()));
- DerivedHashTable::ElementAdded();
- return this;
+ dictionary->SetEntry(entry, k, value, details);
+ ASSERT((dictionary->KeyAt(entry)->IsNumber() ||
+ dictionary->KeyAt(entry)->IsName()));
+ dictionary->ElementAdded();
}
dictionary->DetailsAt(entry).dictionary_index());
Handle<Object> object_key =
SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
- dictionary->SetEntry(entry, *object_key, *value, details);
+ dictionary->SetEntry(entry, object_key, value, details);
return dictionary;
}
if (entry == kNotFound) return AddNumberEntry(dictionary, key, value);
Handle<Object> object_key =
UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
- dictionary->SetEntry(entry, *object_key, *value);
+ dictionary->SetEntry(entry, object_key, value);
return dictionary;
}
}
// Attempt to shrink hash table after removal of key.
- static Handle<Derived> Shrink(Handle<Derived> table, Key key);
+ MUST_USE_RESULT static Handle<Derived> Shrink(Handle<Derived> table, Key key);
// Ensure enough space for n additional elements.
MUST_USE_RESULT static Handle<Derived> EnsureCapacity(
JSObject::DeleteMode mode);
// Attempt to shrink the dictionary after deletion of key.
- static inline Handle<Derived> Shrink(Handle<Derived> dictionary, Key key) {
+ MUST_USE_RESULT static inline Handle<Derived> Shrink(
+ Handle<Derived> dictionary,
+ Key key) {
return DerivedHashTable::Shrink(dictionary, key);
}
// Sets the entry to (key, value) pair.
inline void SetEntry(int entry,
- Object* key,
- Object* value);
+ Handle<Object> key,
+ Handle<Object> value);
inline void SetEntry(int entry,
- Object* key,
- Object* value,
+ Handle<Object> key,
+ Handle<Object> value,
PropertyDetails details);
MUST_USE_RESULT static Handle<Derived> Add(
Handle<Object> value);
// Add entry to dictionary.
- MUST_USE_RESULT MaybeObject* AddEntry(Key key,
- Object* value,
- PropertyDetails details,
- uint32_t hash);
- MUST_USE_RESULT static Handle<Derived> AddEntry(
+ static void AddEntry(
Handle<Derived> dictionary,
Key key,
Handle<Object> value,
class ObjectHashTable: public HashTable<ObjectHashTable,
ObjectHashTableShape,
Object*> {
- typedef HashTable<ObjectHashTable, ObjectHashTableShape, Object*> HashTable_;
+ typedef HashTable<
+ ObjectHashTable, ObjectHashTableShape, Object*> DerivedHashTable;
public:
static inline ObjectHashTable* cast(Object* obj) {
ASSERT(obj->IsHashTable());
}
// Attempt to shrink hash table after removal of key.
- static inline Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table,
- Handle<Object> key);
+ MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink(
+ Handle<ObjectHashTable> table,
+ Handle<Object> key);
// Looks up the value associated with the given key. The hole value is
// returned in case the key is not present.