Revision: 20981
Author: [email protected]
Date: Fri Apr 25 13:21:16 2014 UTC
Log: Dictionary::SetEntry() and Dictionary::AddEntry() handlified.
[email protected]
Review URL: https://codereview.chromium.org/250913003
http://code.google.com/p/v8/source/detail?r=20981
Modified:
/branches/bleeding_edge/src/elements.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/src/elements.cc Tue Apr 22 07:33:20 2014 UTC
+++ /branches/bleeding_edge/src/elements.cc Fri Apr 25 13:21:16 2014 UTC
@@ -1467,7 +1467,7 @@
DisallowHeapAllocation no_gc;
// Remove elements that should be deleted.
int removed_entries = 0;
- Object* the_hole_value = isolate->heap()->the_hole_value();
+ Handle<Object> the_hole_value = isolate->factory()->the_hole_value();
for (int i = 0; i < capacity; i++) {
Object* key = dict->KeyAt(i);
if (key->IsNumber()) {
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Fri Apr 25 11:00:37 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Fri Apr 25 13:21:16 2014 UTC
@@ -6586,16 +6586,16 @@
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() ||
@@ -6603,8 +6603,8 @@
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());
}
@@ -6705,7 +6705,7 @@
Handle<ObjectHashTable> ObjectHashTable::Shrink(
Handle<ObjectHashTable> table, Handle<Object> key) {
- return HashTable_::Shrink(table, *key);
+ return DerivedHashTable::Shrink(table, *key);
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Apr 25 13:06:21 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Fri Apr 25 13:21:16 2014 UTC
@@ -692,7 +692,7 @@
// 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);
}
}
@@ -1932,7 +1932,7 @@
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);
@@ -14980,18 +14980,6 @@
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();
@@ -15840,8 +15828,9 @@
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();
}
@@ -15866,7 +15855,8 @@
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;
}
@@ -15881,52 +15871,37 @@
// 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();
}
@@ -16002,7 +15977,7 @@
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;
}
@@ -16015,7 +15990,7 @@
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;
}
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Apr 25 13:06:21 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Fri Apr 25 13:21:16 2014 UTC
@@ -3822,7 +3822,7 @@
}
// 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(
@@ -3998,7 +3998,9 @@
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);
}
@@ -4047,11 +4049,11 @@
// 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(
@@ -4068,11 +4070,7 @@
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,
@@ -4256,7 +4254,8 @@
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());
@@ -4264,8 +4263,9 @@
}
// 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.
--
--
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.