Reviewers: Yang,
Message:
PTAL #2
Description:
*NumberDictionary::Set() handlified.
Please review this at https://codereview.chromium.org/249973002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+42, -43 lines):
M src/objects.h
M src/objects.cc
M src/objects-inl.h
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
141cef539fe8e92a23a47e6e92e0a3c171a27f7e..2e23167fad0d728a2dff10823f0a8f5885419e7c
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -6643,6 +6643,10 @@ MaybeObject* NumberDictionaryShape::AsObject(Heap*
heap, uint32_t 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) {
// We know that all entries in a hash table had their hash keys created.
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
eae2758914a2d69604ed3abf3df493f93ee1ab82..0ba7859b3883baa1063843db751abca196ec8875
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -16057,6 +16057,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) {
UpdateMaxNumberKey(key);
return AtPut(key, value);
@@ -16071,53 +16081,34 @@ MaybeObject*
UnseededNumberDictionary::AtNumberPut(uint32_t key,
Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
Handle<SeededNumberDictionary> dictionary,
- uint32_t index,
+ uint32_t key,
Handle<Object> value,
PropertyDetails details) {
- CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
- dictionary->Set(index, *value, details),
- SeededNumberDictionary);
-}
-
-
-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);
+ int entry = dictionary->FindEntry(key);
+ if (entry == kNotFound) {
+ return AddNumberEntry(dictionary, key, value, details);
+ }
// Preserve enumeration index.
details = PropertyDetails(details.attributes(),
details.type(),
- DetailsAt(entry).dictionary_index());
- MaybeObject* maybe_object_key =
- SeededNumberDictionaryShape::AsObject(GetHeap(), key);
- Object* object_key;
- if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
- SetEntry(entry, object_key, value, details);
- return this;
+
dictionary->DetailsAt(entry).dictionary_index());
+ Handle<Object> object_key =
+ SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
+ dictionary->SetEntry(entry, *object_key, *value, details);
+ return dictionary;
}
-MaybeObject* UnseededNumberDictionary::Set(uint32_t key,
- Object* value) {
- int entry = FindEntry(key);
- if (entry == kNotFound) return AddNumberEntry(key, value);
- MaybeObject* maybe_object_key =
- UnseededNumberDictionaryShape::AsObject(GetHeap(), key);
- Object* object_key;
- if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key;
- SetEntry(entry, object_key, value);
- return this;
+Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set(
+ Handle<UnseededNumberDictionary> dictionary,
+ uint32_t key,
+ Handle<Object> value) {
+ int entry = dictionary->FindEntry(key);
+ if (entry == kNotFound) return AddNumberEntry(dictionary, key, value);
+ Handle<Object> object_key =
+ UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(),
key);
+ dictionary->SetEntry(entry, *object_key, *value);
+ return dictionary;
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
9b2ce584568089d511438c0bc3428254ded731d3..3018fdfb48514e0e47a480570d1cbd4a8c78ad7e
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4152,8 +4152,10 @@ class NameDictionary: public
Dictionary<NameDictionary,
class NumberDictionaryShape : public BaseShape<uint32_t> {
public:
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,
uint32_t key);
+ static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key);
static const int kEntrySize = 3;
static const bool kIsEnumerable = false;
};
@@ -4205,7 +4207,7 @@ class SeededNumberDictionary
// Return the updated dictionary.
MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
Handle<SeededNumberDictionary> dictionary,
- uint32_t index,
+ uint32_t key,
Handle<Object> value,
PropertyDetails details);
@@ -4248,15 +4250,17 @@ class UnseededNumberDictionary
// 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* 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.
// Return the updated dictionary.
MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
Handle<UnseededNumberDictionary> dictionary,
- uint32_t index,
+ uint32_t key,
Handle<Object> value);
-
- MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value);
};
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.