Commit 7c1a0e81 authored by ishell@chromium.org's avatar ishell@chromium.org

*NumberDictionary::Set() handlified.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20927 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ec613e22
...@@ -6643,6 +6643,10 @@ MaybeObject* NumberDictionaryShape::AsObject(Heap* heap, uint32_t key) { ...@@ -6643,6 +6643,10 @@ MaybeObject* NumberDictionaryShape::AsObject(Heap* heap, uint32_t key) {
return heap->NumberFromUint32(key); return heap->NumberFromUint32(key);
} }
Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) {
return isolate->factory()->NewNumberFromUint(key);
}
bool NameDictionaryShape::IsMatch(Name* key, Object* other) { bool NameDictionaryShape::IsMatch(Name* key, Object* other) {
// We know that all entries in a hash table had their hash keys created. // We know that all entries in a hash table had their hash keys created.
......
...@@ -16063,6 +16063,16 @@ MaybeObject* UnseededNumberDictionary::AddNumberEntry(uint32_t key, ...@@ -16063,6 +16063,16 @@ MaybeObject* UnseededNumberDictionary::AddNumberEntry(uint32_t key,
} }
Handle<UnseededNumberDictionary> UnseededNumberDictionary::AddNumberEntry(
Handle<UnseededNumberDictionary> dictionary,
uint32_t key,
Handle<Object> value) {
CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
dictionary->AddNumberEntry(key, *value),
UnseededNumberDictionary);
}
MaybeObject* SeededNumberDictionary::AtNumberPut(uint32_t key, Object* value) { MaybeObject* SeededNumberDictionary::AtNumberPut(uint32_t key, Object* value) {
UpdateMaxNumberKey(key); UpdateMaxNumberKey(key);
return AtPut(key, value); return AtPut(key, value);
...@@ -16077,53 +16087,34 @@ MaybeObject* UnseededNumberDictionary::AtNumberPut(uint32_t key, ...@@ -16077,53 +16087,34 @@ MaybeObject* UnseededNumberDictionary::AtNumberPut(uint32_t key,
Handle<SeededNumberDictionary> SeededNumberDictionary::Set( Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
Handle<SeededNumberDictionary> dictionary, Handle<SeededNumberDictionary> dictionary,
uint32_t index, uint32_t key,
Handle<Object> value, Handle<Object> value,
PropertyDetails details) { PropertyDetails details) {
CALL_HEAP_FUNCTION(dictionary->GetIsolate(), int entry = dictionary->FindEntry(key);
dictionary->Set(index, *value, details), if (entry == kNotFound) {
SeededNumberDictionary); return AddNumberEntry(dictionary, key, value, details);
} }
Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set(
Handle<UnseededNumberDictionary> dictionary,
uint32_t index,
Handle<Object> value) {
CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
dictionary->Set(index, *value),
UnseededNumberDictionary);
}
MaybeObject* SeededNumberDictionary::Set(uint32_t key,
Object* value,
PropertyDetails details) {
int entry = FindEntry(key);
if (entry == kNotFound) return AddNumberEntry(key, value, details);
// Preserve enumeration index. // Preserve enumeration index.
details = PropertyDetails(details.attributes(), details = PropertyDetails(details.attributes(),
details.type(), details.type(),
DetailsAt(entry).dictionary_index()); dictionary->DetailsAt(entry).dictionary_index());
MaybeObject* maybe_object_key = Handle<Object> object_key =
SeededNumberDictionaryShape::AsObject(GetHeap(), key); SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
Object* object_key; dictionary->SetEntry(entry, *object_key, *value, details);
if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; return dictionary;
SetEntry(entry, object_key, value, details);
return this;
} }
MaybeObject* UnseededNumberDictionary::Set(uint32_t key, Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set(
Object* value) { Handle<UnseededNumberDictionary> dictionary,
int entry = FindEntry(key); uint32_t key,
if (entry == kNotFound) return AddNumberEntry(key, value); Handle<Object> value) {
MaybeObject* maybe_object_key = int entry = dictionary->FindEntry(key);
UnseededNumberDictionaryShape::AsObject(GetHeap(), key); if (entry == kNotFound) return AddNumberEntry(dictionary, key, value);
Object* object_key; Handle<Object> object_key =
if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
SetEntry(entry, object_key, value); dictionary->SetEntry(entry, *object_key, *value);
return this; return dictionary;
} }
......
...@@ -4152,8 +4152,10 @@ class NameDictionary: public Dictionary<NameDictionary, ...@@ -4152,8 +4152,10 @@ class NameDictionary: public Dictionary<NameDictionary,
class NumberDictionaryShape : public BaseShape<uint32_t> { class NumberDictionaryShape : public BaseShape<uint32_t> {
public: public:
static inline bool IsMatch(uint32_t key, Object* other); static inline bool IsMatch(uint32_t key, Object* other);
// TODO(ishell): This should be eventually replaced with AsHandle().
MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
uint32_t key); uint32_t key);
static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key);
static const int kEntrySize = 3; static const int kEntrySize = 3;
static const bool kIsEnumerable = false; static const bool kIsEnumerable = false;
}; };
...@@ -4205,7 +4207,7 @@ class SeededNumberDictionary ...@@ -4205,7 +4207,7 @@ class SeededNumberDictionary
// Return the updated dictionary. // Return the updated dictionary.
MUST_USE_RESULT static Handle<SeededNumberDictionary> Set( MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
Handle<SeededNumberDictionary> dictionary, Handle<SeededNumberDictionary> dictionary,
uint32_t index, uint32_t key,
Handle<Object> value, Handle<Object> value,
PropertyDetails details); PropertyDetails details);
...@@ -4248,15 +4250,17 @@ class UnseededNumberDictionary ...@@ -4248,15 +4250,17 @@ class UnseededNumberDictionary
// Type specific at put (default NONE attributes is used when adding). // Type specific at put (default NONE attributes is used when adding).
MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value); MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value);
MUST_USE_RESULT static Handle<UnseededNumberDictionary> AddNumberEntry(
Handle<UnseededNumberDictionary> dictionary,
uint32_t key,
Handle<Object> value);
// Set an existing entry or add a new one if needed. // Set an existing entry or add a new one if needed.
// Return the updated dictionary. // Return the updated dictionary.
MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set( MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
Handle<UnseededNumberDictionary> dictionary, Handle<UnseededNumberDictionary> dictionary,
uint32_t index, uint32_t key,
Handle<Object> value); Handle<Object> value);
MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value);
}; };
......
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