Dictionary::AtPut() handlified.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20935 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ishell@chromium.org 2014-04-24 10:47:13 +00:00
parent c0ff5354d2
commit 34e59aa239
3 changed files with 47 additions and 31 deletions

View File

@ -6672,6 +6672,13 @@ MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Name* key) {
}
Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, Name* key) {
ASSERT(key->IsUniqueName());
// TODO(ishell): Convert Name* to Handle<Name> to avoid re-wrapping here.
return handle(key, isolate);
}
bool ObjectHashTableShape::IsMatch(Object* key, Object* other) {
return key->SameValue(other);
}

View File

@ -14902,13 +14902,13 @@ template Handle<NameDictionary>
Dictionary<NameDictionary, NameDictionaryShape, Name*>::
New(Isolate* isolate, int n, PretenureFlag pretenure);
template MaybeObject*
template Handle<SeededNumberDictionary>
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
AtPut(uint32_t, Object*);
AtPut(Handle<SeededNumberDictionary>, uint32_t, Handle<Object>);
template MaybeObject*
template Handle<UnseededNumberDictionary>
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
AtPut(uint32_t, Object*);
AtPut(Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>);
template Object*
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
@ -15943,29 +15943,25 @@ Object* Dictionary<Derived, Shape, Key>::DeleteProperty(
template<typename Derived, typename Shape, typename Key>
MaybeObject* Dictionary<Derived, Shape, Key>::AtPut(Key key, Object* value) {
int entry = this->FindEntry(key);
Handle<Derived> Dictionary<Derived, Shape, Key>::AtPut(
Handle<Derived> dictionary, Key key, Handle<Object> value) {
int entry = dictionary->FindEntry(key);
// If the entry is present set the value;
if (entry != Dictionary::kNotFound) {
ValueAtPut(entry, value);
return this;
dictionary->ValueAtPut(entry, *value);
return dictionary;
}
// Check whether the dictionary should be extended.
Object* obj;
{ MaybeObject* maybe_obj = EnsureCapacity(1, key);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
dictionary = EnsureCapacity(dictionary, 1, key);
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);
// TODO(ishell): Figure out if it is necessary to call AsHandle() here.
USE(k);
PropertyDetails details = PropertyDetails(NONE, NORMAL, 0);
return Dictionary::cast(obj)->AddEntry(
key, value, details, Dictionary::Hash(key));
return AddEntry(dictionary, key, value, details, dictionary->Hash(key));
}
@ -15988,6 +15984,19 @@ MaybeObject* Dictionary<Derived, Shape, Key>::Add(
// Add a key, value pair to the dictionary.
template<typename Derived, typename Shape, typename Key>
Handle<Derived> 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,
@ -16069,10 +16078,7 @@ Handle<SeededNumberDictionary> SeededNumberDictionary::AtNumberPut(
uint32_t key,
Handle<Object> value) {
dictionary->UpdateMaxNumberKey(key);
CALL_HEAP_FUNCTION(
dictionary->GetIsolate(),
dictionary->AtPut(key, *value),
SeededNumberDictionary);
return AtPut(dictionary, key, value);
}
@ -16080,10 +16086,7 @@ Handle<UnseededNumberDictionary> UnseededNumberDictionary::AtNumberPut(
Handle<UnseededNumberDictionary> dictionary,
uint32_t key,
Handle<Object> value) {
CALL_HEAP_FUNCTION(
dictionary->GetIsolate(),
dictionary->AtPut(key, *value),
UnseededNumberDictionary);
return AtPut(dictionary, key, value);
}

View File

@ -4095,13 +4095,22 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
protected:
// Generic at put operation.
MUST_USE_RESULT MaybeObject* AtPut(Key key, Object* value);
MUST_USE_RESULT static Handle<Derived> AtPut(
Handle<Derived> dictionary,
Key key,
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(
Handle<Derived> dictionary,
Key key,
Handle<Object> value,
PropertyDetails details,
uint32_t hash);
// Generate new enumeration indices to avoid enumeration index overflow.
MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices();
@ -4117,6 +4126,7 @@ class NameDictionaryShape : public BaseShape<Name*> {
static inline uint32_t HashForObject(Name* key, Object* object);
MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
Name* key);
static inline Handle<Object> AsHandle(Isolate* isolate, Name* key);
static const int kPrefixSize = 2;
static const int kEntrySize = 3;
static const bool kIsEnumerable = true;
@ -4211,10 +4221,6 @@ class SeededNumberDictionary
Handle<Object> value,
PropertyDetails details);
MUST_USE_RESULT MaybeObject* Set(uint32_t key,
Object* value,
PropertyDetails details);
void UpdateMaxNumberKey(uint32_t key);
// If slow elements are required we will never go back to fast-case