Chromium Code Reviews| Index: src/elements.cc |
| diff --git a/src/elements.cc b/src/elements.cc |
| index 6395e8fa79b0d958f4d06e6c03b7ac2f76361741..89b292a09338e6ad510ca7e59d95ec731751c8e1 100644 |
| --- a/src/elements.cc |
| +++ b/src/elements.cc |
| @@ -123,13 +123,13 @@ ELEMENTS_LIST(ELEMENTS_TRAITS) |
| #undef ELEMENTS_TRAITS |
| -static bool HasKey(Handle<FixedArray> array, Handle<Object> key_handle) { |
| +static bool HasIndex(Handle<FixedArray> array, Handle<Object> index_handle) { |
| DisallowHeapAllocation no_gc; |
| - Object* key = *key_handle; |
| + Object* index = *index_handle; |
| int len0 = array->length(); |
| for (int i = 0; i < len0; i++) { |
| Object* element = array->get(i); |
| - if (key->KeyEquals(element)) return true; |
| + if (index->KeyEquals(element)) return true; |
| } |
| return false; |
| } |
| @@ -542,69 +542,71 @@ class ElementsAccessorBase : public ElementsAccessor { |
| ElementsAccessorSubclass::ValidateImpl(holder); |
| } |
| - virtual bool HasElement(Handle<JSObject> holder, uint32_t key, |
| + virtual bool HasElement(Handle<JSObject> holder, uint32_t index, |
| Handle<FixedArrayBase> backing_store) final { |
| - return ElementsAccessorSubclass::GetIndexForKeyImpl(*holder, *backing_store, |
| - key) != kMaxUInt32; |
| + return ElementsAccessorSubclass::GetEntryForIndexImpl( |
| + *holder, *backing_store, index) != kMaxUInt32; |
| } |
| - virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key, |
| + virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t index, |
| Handle<FixedArrayBase> backing_store) final { |
| if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && |
| FLAG_trace_js_array_abuse) { |
| - CheckArrayAbuse(holder, "elements read", key); |
| + CheckArrayAbuse(holder, "elements read", index); |
| } |
| if (IsExternalArrayElementsKind(ElementsTraits::Kind) && |
| FLAG_trace_external_array_abuse) { |
| - CheckArrayAbuse(holder, "external elements read", key); |
| + CheckArrayAbuse(holder, "external elements read", index); |
| } |
| - return ElementsAccessorSubclass::GetImpl(holder, key, backing_store); |
| + return ElementsAccessorSubclass::GetImpl(holder, index, backing_store); |
| } |
| - static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
| + static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t index, |
| Handle<FixedArrayBase> backing_store) { |
| - if (key < ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)) { |
| - return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); |
| + if (index < |
| + ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)) { |
| + return BackingStore::get(Handle<BackingStore>::cast(backing_store), |
| + index); |
| } else { |
| return backing_store->GetIsolate()->factory()->the_hole_value(); |
| } |
| } |
| - virtual void Set(FixedArrayBase* backing_store, uint32_t key, |
| + virtual void Set(FixedArrayBase* backing_store, uint32_t index, |
| Object* value) final { |
| - ElementsAccessorSubclass::SetImpl(backing_store, key, value); |
| + ElementsAccessorSubclass::SetImpl(backing_store, index, value); |
| } |
| - static void SetImpl(FixedArrayBase* backing_store, uint32_t key, |
| + static void SetImpl(FixedArrayBase* backing_store, uint32_t index, |
| Object* value) { |
| - BackingStore::cast(backing_store)->SetValue(key, value); |
| + BackingStore::cast(backing_store)->SetValue(index, value); |
| } |
| virtual void Reconfigure(Handle<JSObject> object, |
| - Handle<FixedArrayBase> store, uint32_t index, |
| + Handle<FixedArrayBase> store, uint32_t entry, |
| Handle<Object> value, |
| PropertyAttributes attributes) final { |
| - ElementsAccessorSubclass::ReconfigureImpl(object, store, index, value, |
| + ElementsAccessorSubclass::ReconfigureImpl(object, store, entry, value, |
| attributes); |
| } |
| static void ReconfigureImpl(Handle<JSObject> object, |
| - Handle<FixedArrayBase> store, uint32_t index, |
| + Handle<FixedArrayBase> store, uint32_t entry, |
| Handle<Object> value, |
| PropertyAttributes attributes) { |
| UNREACHABLE(); |
| } |
| - virtual void Add(Handle<JSObject> object, uint32_t index, |
| + virtual void Add(Handle<JSObject> object, uint32_t entry, |
| Handle<Object> value, PropertyAttributes attributes, |
| uint32_t new_capacity) final { |
| - ElementsAccessorSubclass::AddImpl(object, index, value, attributes, |
| + ElementsAccessorSubclass::AddImpl(object, entry, value, attributes, |
| new_capacity); |
| } |
| - static void AddImpl(Handle<JSObject> object, uint32_t index, |
| + static void AddImpl(Handle<JSObject> object, uint32_t entry, |
| Handle<Object> value, PropertyAttributes attributes, |
| uint32_t new_capacity) { |
| UNREACHABLE(); |
| @@ -678,8 +680,8 @@ class ElementsAccessorBase : public ElementsAccessor { |
| ElementsAccessorSubclass::GrowCapacityAndConvertImpl(object, capacity); |
| } |
| - virtual void Delete(Handle<JSObject> obj, uint32_t index) final { |
| - ElementsAccessorSubclass::DeleteImpl(obj, index); |
| + virtual void Delete(Handle<JSObject> obj, uint32_t entry) final { |
| + ElementsAccessorSubclass::DeleteImpl(obj, entry); |
| } |
| static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, |
| @@ -755,10 +757,11 @@ class ElementsAccessorBase : public ElementsAccessor { |
| // Compute how many elements are not in other. |
| uint32_t extra = 0; |
| for (uint32_t y = 0; y < len1; y++) { |
| - if (ElementsAccessorSubclass::HasIndexImpl(*from, y)) { |
| - uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(*from, y); |
| + if (ElementsAccessorSubclass::HasEntryImpl(*from, y)) { |
| + uint32_t index = |
| + ElementsAccessorSubclass::GetIndexForEntryImpl(*from, y); |
| Handle<Object> value = |
| - ElementsAccessorSubclass::GetImpl(receiver, key, from); |
| + ElementsAccessorSubclass::GetImpl(receiver, index, from); |
| DCHECK(!value->IsTheHole()); |
| DCHECK(!value->IsAccessorPair()); |
| @@ -766,7 +769,7 @@ class ElementsAccessorBase : public ElementsAccessor { |
| if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) { |
| continue; |
| } |
| - if (!HasKey(to, value)) { |
| + if (!HasIndex(to, value)) { |
| extra++; |
| } |
| } |
| @@ -788,24 +791,25 @@ class ElementsAccessorBase : public ElementsAccessor { |
| } |
| } |
| // Fill in the extra values. |
| - uint32_t index = 0; |
| + uint32_t entry = 0; |
| for (uint32_t y = 0; y < len1; y++) { |
| - if (ElementsAccessorSubclass::HasIndexImpl(*from, y)) { |
| - uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(*from, y); |
| + if (ElementsAccessorSubclass::HasEntryImpl(*from, y)) { |
| + uint32_t index = |
| + ElementsAccessorSubclass::GetIndexForEntryImpl(*from, y); |
| Handle<Object> value = |
| - ElementsAccessorSubclass::GetImpl(receiver, key, from); |
| + ElementsAccessorSubclass::GetImpl(receiver, index, from); |
| DCHECK(!value->IsAccessorPair()); |
| DCHECK(!value->IsExecutableAccessorInfo()); |
| if (filter == FixedArray::NON_SYMBOL_KEYS && value->IsSymbol()) { |
| continue; |
| } |
| - if (!value->IsTheHole() && !HasKey(to, value)) { |
| - result->set(len0 + index, *value); |
| - index++; |
| + if (!value->IsTheHole() && !HasIndex(to, value)) { |
| + result->set(len0 + entry, *value); |
| + entry++; |
| } |
| } |
| } |
| - DCHECK(extra == index); |
| + DCHECK(extra == entry); |
| return result; |
| } |
| @@ -818,49 +822,44 @@ class ElementsAccessorBase : public ElementsAccessor { |
| return ElementsAccessorSubclass::GetCapacityImpl(holder, backing_store); |
| } |
| - static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) { |
| + static bool HasEntryImpl(FixedArrayBase* backing_store, uint32_t entry) { |
| return true; |
| } |
| - virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t index) final { |
| - return ElementsAccessorSubclass::HasIndexImpl(backing_store, index); |
| - } |
| - |
| - static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, |
| - uint32_t index) { |
| - return index; |
| + virtual bool HasEntry(FixedArrayBase* backing_store, uint32_t entry) final { |
| + return ElementsAccessorSubclass::HasEntryImpl(backing_store, entry); |
| } |
| - virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
| - uint32_t index) final { |
| - return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); |
| + static uint32_t GetIndexForEntryImpl(FixedArrayBase* backing_store, |
| + uint32_t entry) { |
| + return entry; |
| } |
| - static uint32_t GetIndexForKeyImpl(JSObject* holder, |
| - FixedArrayBase* backing_store, |
| - uint32_t key) { |
| - return key < ElementsAccessorSubclass::GetCapacityImpl(holder, |
| - backing_store) && |
| - !BackingStore::cast(backing_store)->is_the_hole(key) |
| - ? key |
| + static uint32_t GetEntryForIndexImpl(JSObject* holder, |
| + FixedArrayBase* backing_store, |
| + uint32_t index) { |
| + return index < ElementsAccessorSubclass::GetCapacityImpl(holder, |
| + backing_store) && |
| + !BackingStore::cast(backing_store)->is_the_hole(index) |
| + ? index |
| : kMaxUInt32; |
| } |
| - virtual uint32_t GetIndexForKey(JSObject* holder, |
| - FixedArrayBase* backing_store, |
| - uint32_t key) final { |
| - return ElementsAccessorSubclass::GetIndexForKeyImpl(holder, backing_store, |
| - key); |
| + virtual uint32_t GetEntryForIndex(JSObject* holder, |
| + FixedArrayBase* backing_store, |
| + uint32_t index) final { |
| + return ElementsAccessorSubclass::GetEntryForIndexImpl(holder, backing_store, |
| + index); |
| } |
| static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
| - uint32_t index) { |
| + uint32_t entry) { |
| return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
| } |
| virtual PropertyDetails GetDetails(FixedArrayBase* backing_store, |
| - uint32_t index) final { |
| - return ElementsAccessorSubclass::GetDetailsImpl(backing_store, index); |
| + uint32_t entry) final { |
| + return ElementsAccessorSubclass::GetDetailsImpl(backing_store, entry); |
| } |
| private: |
| @@ -890,9 +889,9 @@ class DictionaryElementsAccessor |
| // deleted and adjust range accordingly. |
| for (int i = 0; i < capacity; i++) { |
|
Igor Sheludko
2015/07/07 11:01:42
i -> entry?
|
| DisallowHeapAllocation no_gc; |
| - Object* key = dict->KeyAt(i); |
| - if (key->IsNumber()) { |
| - uint32_t number = static_cast<uint32_t>(key->Number()); |
| + Object* index = dict->KeyAt(i); |
| + if (index->IsNumber()) { |
| + uint32_t number = static_cast<uint32_t>(index->Number()); |
| if (length <= number && number < old_length) { |
| PropertyDetails details = dict->DetailsAt(i); |
| if (!details.IsConfigurable()) length = number + 1; |
| @@ -910,9 +909,9 @@ class DictionaryElementsAccessor |
| int removed_entries = 0; |
| Handle<Object> the_hole_value = isolate->factory()->the_hole_value(); |
| for (int i = 0; i < capacity; i++) { |
|
Igor Sheludko
2015/07/07 11:01:42
i -> entry?
|
| - Object* key = dict->KeyAt(i); |
| - if (key->IsNumber()) { |
| - uint32_t number = static_cast<uint32_t>(key->Number()); |
| + Object* index = dict->KeyAt(i); |
| + if (index->IsNumber()) { |
| + uint32_t number = static_cast<uint32_t>(index->Number()); |
| if (length <= number && number < old_length) { |
| dict->SetEntry(i, the_hole_value, the_hole_value); |
| removed_entries++; |
| @@ -937,51 +936,52 @@ class DictionaryElementsAccessor |
| } |
| - static void DeleteImpl(Handle<JSObject> obj, uint32_t index) { |
| - // TODO(verwaest): Remove reliance on key in Shrink. |
| + static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
| + // TODO(verwaest): Remove reliance on index in Shrink. |
| Handle<SeededNumberDictionary> dict( |
| SeededNumberDictionary::cast(obj->elements())); |
| - uint32_t key = GetKeyForIndexImpl(*dict, index); |
| - Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, index); |
| + uint32_t index = GetIndexForEntryImpl(*dict, entry); |
| + Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
| USE(result); |
| DCHECK(result->IsTrue()); |
| - Handle<FixedArray> new_elements = SeededNumberDictionary::Shrink(dict, key); |
| + Handle<FixedArray> new_elements = |
| + SeededNumberDictionary::Shrink(dict, index); |
| obj->set_elements(*new_elements); |
| } |
| - static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
| + static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t index, |
| Handle<FixedArrayBase> store) { |
| Handle<SeededNumberDictionary> backing_store = |
| Handle<SeededNumberDictionary>::cast(store); |
| Isolate* isolate = backing_store->GetIsolate(); |
| - int entry = backing_store->FindEntry(key); |
| + int entry = backing_store->FindEntry(index); |
| if (entry != SeededNumberDictionary::kNotFound) { |
| return handle(backing_store->ValueAt(entry), isolate); |
| } |
| return isolate->factory()->the_hole_value(); |
| } |
| - static void SetImpl(FixedArrayBase* store, uint32_t key, Object* value) { |
| + static void SetImpl(FixedArrayBase* store, uint32_t index, Object* value) { |
| SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(store); |
| - int entry = dictionary->FindEntry(key); |
| + int entry = dictionary->FindEntry(index); |
| DCHECK_NE(SeededNumberDictionary::kNotFound, entry); |
| dictionary->ValueAtPut(entry, value); |
| } |
| static void ReconfigureImpl(Handle<JSObject> object, |
| - Handle<FixedArrayBase> store, uint32_t index, |
| + Handle<FixedArrayBase> store, uint32_t entry, |
| Handle<Object> value, |
| PropertyAttributes attributes) { |
| SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(*store); |
| if (attributes != NONE) dictionary->set_requires_slow_elements(); |
| - dictionary->ValueAtPut(index, *value); |
| - PropertyDetails details = dictionary->DetailsAt(index); |
| + dictionary->ValueAtPut(entry, *value); |
| + PropertyDetails details = dictionary->DetailsAt(entry); |
| details = PropertyDetails(attributes, DATA, details.dictionary_index(), |
| PropertyCellType::kNoCell); |
| - dictionary->DetailsAtPut(index, details); |
| + dictionary->DetailsAtPut(entry, details); |
| } |
| - static void AddImpl(Handle<JSObject> object, uint32_t index, |
| + static void AddImpl(Handle<JSObject> object, uint32_t entry, |
| Handle<Object> value, PropertyAttributes attributes, |
| uint32_t new_capacity) { |
| PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
| @@ -990,41 +990,41 @@ class DictionaryElementsAccessor |
| ? JSObject::NormalizeElements(object) |
| : handle(SeededNumberDictionary::cast(object->elements())); |
| Handle<SeededNumberDictionary> new_dictionary = |
| - SeededNumberDictionary::AddNumberEntry(dictionary, index, value, |
| + SeededNumberDictionary::AddNumberEntry(dictionary, entry, value, |
| details); |
| if (attributes != NONE) new_dictionary->set_requires_slow_elements(); |
| if (dictionary.is_identical_to(new_dictionary)) return; |
| object->set_elements(*new_dictionary); |
| } |
| - static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { |
| + static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) { |
| DisallowHeapAllocation no_gc; |
| SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
| - Object* key = dict->KeyAt(index); |
| - return !key->IsTheHole(); |
| + Object* index = dict->KeyAt(entry); |
| + return !index->IsTheHole(); |
| } |
| - static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { |
| + static uint32_t GetIndexForEntryImpl(FixedArrayBase* store, uint32_t entry) { |
| DisallowHeapAllocation no_gc; |
| SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
| uint32_t result = 0; |
| - CHECK(dict->KeyAt(index)->ToArrayIndex(&result)); |
| + CHECK(dict->KeyAt(entry)->ToArrayIndex(&result)); |
| return result; |
| } |
| - static uint32_t GetIndexForKeyImpl(JSObject* holder, FixedArrayBase* store, |
| - uint32_t key) { |
| + static uint32_t GetEntryForIndexImpl(JSObject* holder, FixedArrayBase* store, |
| + uint32_t index) { |
| DisallowHeapAllocation no_gc; |
| SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
| - int entry = dict->FindEntry(key); |
| + int entry = dict->FindEntry(index); |
| return entry == SeededNumberDictionary::kNotFound |
| ? kMaxUInt32 |
| : static_cast<uint32_t>(entry); |
| } |
| static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
| - uint32_t index) { |
| - return SeededNumberDictionary::cast(backing_store)->DetailsAt(index); |
| + uint32_t entry) { |
| + return SeededNumberDictionary::cast(backing_store)->DetailsAt(entry); |
| } |
| }; |
| @@ -1041,13 +1041,13 @@ class FastElementsAccessor |
| typedef typename KindTraits::BackingStore BackingStore; |
| - static void DeleteCommon(Handle<JSObject> obj, uint32_t index, |
| + static void DeleteCommon(Handle<JSObject> obj, uint32_t entry, |
| Handle<FixedArrayBase> store) { |
| DCHECK(obj->HasFastSmiOrObjectElements() || |
| obj->HasFastDoubleElements() || |
| obj->HasFastArgumentsElements()); |
| Handle<BackingStore> backing_store = Handle<BackingStore>::cast(store); |
| - backing_store->set_the_hole(index); |
| + backing_store->set_the_hole(entry); |
| // TODO(verwaest): Move this out of elements.cc. |
| // If an old space backing store is larger than a certain size and |
| @@ -1063,8 +1063,8 @@ class FastElementsAccessor |
| } else { |
| length = static_cast<uint32_t>(store->length()); |
| } |
| - if ((index > 0 && backing_store->is_the_hole(index - 1)) || |
| - (index + 1 < length && backing_store->is_the_hole(index + 1))) { |
| + if ((entry > 0 && backing_store->is_the_hole(entry - 1)) || |
| + (entry + 1 < length && backing_store->is_the_hole(entry + 1))) { |
| int num_used = 0; |
| for (int i = 0; i < backing_store->length(); ++i) { |
| if (!backing_store->is_the_hole(i)) ++num_used; |
| @@ -1078,17 +1078,17 @@ class FastElementsAccessor |
| } |
| static void ReconfigureImpl(Handle<JSObject> object, |
| - Handle<FixedArrayBase> store, uint32_t index, |
| + Handle<FixedArrayBase> store, uint32_t entry, |
| Handle<Object> value, |
| PropertyAttributes attributes) { |
| Handle<SeededNumberDictionary> dictionary = |
| JSObject::NormalizeElements(object); |
| - index = dictionary->FindEntry(index); |
| - DictionaryElementsAccessor::ReconfigureImpl(object, dictionary, index, |
| + entry = dictionary->FindEntry(entry); |
| + DictionaryElementsAccessor::ReconfigureImpl(object, dictionary, entry, |
| value, attributes); |
| } |
| - static void AddImpl(Handle<JSObject> object, uint32_t index, |
| + static void AddImpl(Handle<JSObject> object, uint32_t entry, |
| Handle<Object> value, PropertyAttributes attributes, |
| uint32_t new_capacity) { |
| DCHECK_EQ(NONE, attributes); |
| @@ -1110,10 +1110,10 @@ class FastElementsAccessor |
| JSObject::EnsureWritableFastElements(object); |
| } |
| } |
| - FastElementsAccessorSubclass::SetImpl(object->elements(), index, *value); |
| + FastElementsAccessorSubclass::SetImpl(object->elements(), entry, *value); |
| } |
| - static void DeleteImpl(Handle<JSObject> obj, uint32_t index) { |
| + static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
| ElementsKind kind = KindTraits::Kind; |
| if (IsFastPackedElementsKind(kind)) { |
| JSObject::TransitionElementsKind(obj, GetHoleyElementsKind(kind)); |
| @@ -1121,11 +1121,11 @@ class FastElementsAccessor |
| if (IsFastSmiOrObjectElementsKind(KindTraits::Kind)) { |
| JSObject::EnsureWritableFastElements(obj); |
| } |
| - DeleteCommon(obj, index, handle(obj->elements())); |
| + DeleteCommon(obj, entry, handle(obj->elements())); |
| } |
| - static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) { |
| - return !BackingStore::cast(backing_store)->is_the_hole(index); |
| + static bool HasEntryImpl(FixedArrayBase* backing_store, uint32_t entry) { |
| + return !BackingStore::cast(backing_store)->is_the_hole(entry); |
| } |
| static void ValidateContents(Handle<JSObject> holder, int length) { |
| @@ -1342,17 +1342,18 @@ class TypedElementsAccessor |
| typedef typename ElementsKindTraits<Kind>::BackingStore BackingStore; |
| typedef TypedElementsAccessor<Kind> AccessorClass; |
| - static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
| + static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t index, |
| Handle<FixedArrayBase> backing_store) { |
| - if (key < AccessorClass::GetCapacityImpl(*obj, *backing_store)) { |
| - return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); |
| + if (index < AccessorClass::GetCapacityImpl(*obj, *backing_store)) { |
| + return BackingStore::get(Handle<BackingStore>::cast(backing_store), |
| + index); |
| } else { |
| return backing_store->GetIsolate()->factory()->undefined_value(); |
| } |
| } |
| static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store, |
| - uint32_t index) { |
| + uint32_t entry) { |
| return PropertyDetails(DONT_DELETE, DATA, 0, PropertyCellType::kNoCell); |
| } |
| @@ -1362,15 +1363,15 @@ class TypedElementsAccessor |
| UNREACHABLE(); |
| } |
| - static void DeleteImpl(Handle<JSObject> obj, uint32_t index) { |
| + static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
| UNREACHABLE(); |
| } |
| - static uint32_t GetIndexForKeyImpl(JSObject* holder, |
| - FixedArrayBase* backing_store, |
| - uint32_t key) { |
| - return key < AccessorClass::GetCapacityImpl(holder, backing_store) |
| - ? key |
| + static uint32_t GetEntryForIndexImpl(JSObject* holder, |
| + FixedArrayBase* backing_store, |
| + uint32_t index) { |
| + return index < AccessorClass::GetCapacityImpl(holder, backing_store) |
| + ? index |
| : kMaxUInt32; |
| } |
| @@ -1409,30 +1410,30 @@ class SloppyArgumentsElementsAccessor |
| : ElementsAccessorBase<SloppyArgumentsElementsAccessorSubclass, |
| KindTraits>(name) {} |
| - static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
| + static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t index, |
| Handle<FixedArrayBase> parameters) { |
| Isolate* isolate = obj->GetIsolate(); |
| Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); |
| - Handle<Object> probe(GetParameterMapArg(*parameter_map, key), isolate); |
| + Handle<Object> probe(GetParameterMapArg(*parameter_map, index), isolate); |
| if (!probe->IsTheHole()) { |
| DisallowHeapAllocation no_gc; |
| Context* context = Context::cast(parameter_map->get(0)); |
| - int context_index = Handle<Smi>::cast(probe)->value(); |
| - DCHECK(!context->get(context_index)->IsTheHole()); |
| - return handle(context->get(context_index), isolate); |
| + int context_entry = Handle<Smi>::cast(probe)->value(); |
| + DCHECK(!context->get(context_entry)->IsTheHole()); |
| + return handle(context->get(context_entry), isolate); |
| } else { |
| // Object is not mapped, defer to the arguments. |
| Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)), |
| isolate); |
| - Handle<Object> result = ArgumentsAccessor::GetImpl(obj, key, arguments); |
| + Handle<Object> result = ArgumentsAccessor::GetImpl(obj, index, arguments); |
| // Elements of the arguments object in slow mode might be slow aliases. |
| if (result->IsAliasedArgumentsEntry()) { |
| DisallowHeapAllocation no_gc; |
| AliasedArgumentsEntry* entry = AliasedArgumentsEntry::cast(*result); |
| Context* context = Context::cast(parameter_map->get(0)); |
| - int context_index = entry->aliased_context_slot(); |
| - DCHECK(!context->get(context_index)->IsTheHole()); |
| - return handle(context->get(context_index), isolate); |
| + int context_entry = entry->aliased_context_slot(); |
| + DCHECK(!context->get(context_entry)->IsTheHole()); |
| + return handle(context->get(context_entry), isolate); |
| } else { |
| return result; |
| } |
| @@ -1444,17 +1445,17 @@ class SloppyArgumentsElementsAccessor |
| UNREACHABLE(); |
| } |
| - static void SetImpl(FixedArrayBase* store, uint32_t key, Object* value) { |
| + static void SetImpl(FixedArrayBase* store, uint32_t index, Object* value) { |
| FixedArray* parameter_map = FixedArray::cast(store); |
| - Object* probe = GetParameterMapArg(parameter_map, key); |
| + Object* probe = GetParameterMapArg(parameter_map, index); |
| if (!probe->IsTheHole()) { |
| Context* context = Context::cast(parameter_map->get(0)); |
| - int context_index = Smi::cast(probe)->value(); |
| - DCHECK(!context->get(context_index)->IsTheHole()); |
| - context->set(context_index, value); |
| + int context_entry = Smi::cast(probe)->value(); |
| + DCHECK(!context->get(context_entry)->IsTheHole()); |
| + context->set(context_entry, value); |
| } else { |
| FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| - ArgumentsAccessor::SetImpl(arguments, key, value); |
| + ArgumentsAccessor::SetImpl(arguments, index, value); |
| } |
| } |
| @@ -1472,70 +1473,71 @@ class SloppyArgumentsElementsAccessor |
| ArgumentsAccessor::GetCapacityImpl(holder, arguments); |
| } |
| - static bool HasIndexImpl(FixedArrayBase* parameters, uint32_t index) { |
| + static bool HasEntryImpl(FixedArrayBase* parameters, uint32_t entry) { |
| FixedArray* parameter_map = FixedArray::cast(parameters); |
| uint32_t length = parameter_map->length() - 2; |
| - if (index < length) { |
| - return !GetParameterMapArg(parameter_map, index)->IsTheHole(); |
| + if (entry < length) { |
| + return !GetParameterMapArg(parameter_map, entry)->IsTheHole(); |
| } |
| FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
| - return ArgumentsAccessor::HasIndexImpl(arguments, index - length); |
| + return ArgumentsAccessor::HasEntryImpl(arguments, entry - length); |
| } |
| - static uint32_t GetKeyForIndexImpl(FixedArrayBase* parameters, |
| - uint32_t index) { |
| + static uint32_t GetIndexForEntryImpl(FixedArrayBase* parameters, |
| + uint32_t entry) { |
| FixedArray* parameter_map = FixedArray::cast(parameters); |
| uint32_t length = parameter_map->length() - 2; |
| - if (index < length) return index; |
| + if (entry < length) return entry; |
| FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| - return ArgumentsAccessor::GetKeyForIndexImpl(arguments, index - length); |
| + return ArgumentsAccessor::GetIndexForEntryImpl(arguments, entry - length); |
| } |
| - static uint32_t GetIndexForKeyImpl(JSObject* holder, |
| - FixedArrayBase* parameters, uint32_t key) { |
| + static uint32_t GetEntryForIndexImpl(JSObject* holder, |
| + FixedArrayBase* parameters, |
| + uint32_t index) { |
| FixedArray* parameter_map = FixedArray::cast(parameters); |
| - Object* probe = GetParameterMapArg(parameter_map, key); |
| - if (!probe->IsTheHole()) return key; |
| + Object* probe = GetParameterMapArg(parameter_map, index); |
| + if (!probe->IsTheHole()) return index; |
| FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| - uint32_t index = |
| - ArgumentsAccessor::GetIndexForKeyImpl(holder, arguments, key); |
| - if (index == kMaxUInt32) return index; |
| - return (parameter_map->length() - 2) + index; |
| + uint32_t entry = |
| + ArgumentsAccessor::GetEntryForIndexImpl(holder, arguments, index); |
| + if (entry == kMaxUInt32) return entry; |
| + return (parameter_map->length() - 2) + entry; |
| } |
| static PropertyDetails GetDetailsImpl(FixedArrayBase* parameters, |
| - uint32_t index) { |
| + uint32_t entry) { |
| FixedArray* parameter_map = FixedArray::cast(parameters); |
| uint32_t length = parameter_map->length() - 2; |
| - if (index < length) { |
| + if (entry < length) { |
| return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell); |
| } |
| - index -= length; |
| + entry -= length; |
| FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| - return ArgumentsAccessor::GetDetailsImpl(arguments, index); |
| + return ArgumentsAccessor::GetDetailsImpl(arguments, entry); |
| } |
| - static Object* GetParameterMapArg(FixedArray* parameter_map, uint32_t key) { |
| + static Object* GetParameterMapArg(FixedArray* parameter_map, uint32_t index) { |
| uint32_t length = parameter_map->length() - 2; |
| - return key < length |
| - ? parameter_map->get(key + 2) |
| + return index < length |
| + ? parameter_map->get(index + 2) |
| : Object::cast(parameter_map->GetHeap()->the_hole_value()); |
| } |
| - static void DeleteImpl(Handle<JSObject> obj, uint32_t index) { |
| + static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
| FixedArray* parameter_map = FixedArray::cast(obj->elements()); |
| uint32_t length = static_cast<uint32_t>(parameter_map->length()) - 2; |
| - if (index < length) { |
| + if (entry < length) { |
| // TODO(kmillikin): We could check if this was the last aliased |
| // parameter, and revert to normal elements in that case. That |
| // would enable GC of the context. |
| - parameter_map->set_the_hole(index + 2); |
| + parameter_map->set_the_hole(entry + 2); |
| } else { |
| SloppyArgumentsElementsAccessorSubclass::DeleteFromArguments( |
| - obj, index - length); |
| + obj, entry - length); |
| } |
| } |
| }; |
| @@ -1551,20 +1553,21 @@ class SlowSloppyArgumentsElementsAccessor |
| SlowSloppyArgumentsElementsAccessor, DictionaryElementsAccessor, |
| ElementsKindTraits<SLOW_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {} |
| - static void DeleteFromArguments(Handle<JSObject> obj, uint32_t index) { |
| + static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) { |
| Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); |
| Handle<SeededNumberDictionary> dict( |
| SeededNumberDictionary::cast(parameter_map->get(1))); |
| - // TODO(verwaest): Remove reliance on key in Shrink. |
| - uint32_t key = GetKeyForIndexImpl(*dict, index); |
| - Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, index); |
| + // TODO(verwaest): Remove reliance on index in Shrink. |
| + uint32_t index = GetIndexForEntryImpl(*dict, entry); |
| + Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
| USE(result); |
| DCHECK(result->IsTrue()); |
| - Handle<FixedArray> new_elements = SeededNumberDictionary::Shrink(dict, key); |
| + Handle<FixedArray> new_elements = |
| + SeededNumberDictionary::Shrink(dict, index); |
| parameter_map->set(1, *new_elements); |
| } |
| - static void AddImpl(Handle<JSObject> object, uint32_t key, |
| + static void AddImpl(Handle<JSObject> object, uint32_t index, |
| Handle<Object> value, PropertyAttributes attributes, |
| uint32_t new_capacity) { |
| Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
| @@ -1576,7 +1579,8 @@ class SlowSloppyArgumentsElementsAccessor |
| : JSObject::NormalizeElements(object); |
| PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
| Handle<SeededNumberDictionary> new_dictionary = |
| - SeededNumberDictionary::AddNumberEntry(dictionary, key, value, details); |
| + SeededNumberDictionary::AddNumberEntry(dictionary, index, value, |
| + details); |
| if (attributes != NONE) new_dictionary->set_requires_slow_elements(); |
| if (*dictionary != *new_dictionary) { |
| FixedArray::cast(object->elements())->set(1, *new_dictionary); |
| @@ -1584,38 +1588,38 @@ class SlowSloppyArgumentsElementsAccessor |
| } |
| static void ReconfigureImpl(Handle<JSObject> object, |
| - Handle<FixedArrayBase> store, uint32_t index, |
| + Handle<FixedArrayBase> store, uint32_t entry, |
| Handle<Object> value, |
| PropertyAttributes attributes) { |
| Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store); |
| uint32_t length = parameter_map->length() - 2; |
| - if (index < length) { |
| - Object* probe = parameter_map->get(index + 2); |
| + if (entry < length) { |
| + Object* probe = parameter_map->get(entry + 2); |
| DCHECK(!probe->IsTheHole()); |
| Context* context = Context::cast(parameter_map->get(0)); |
| - int context_index = Smi::cast(probe)->value(); |
| - DCHECK(!context->get(context_index)->IsTheHole()); |
| - context->set(context_index, *value); |
| + int context_entry = Smi::cast(probe)->value(); |
| + DCHECK(!context->get(context_entry)->IsTheHole()); |
| + context->set(context_entry, *value); |
| // Redefining attributes of an aliased element destroys fast aliasing. |
| - parameter_map->set_the_hole(index + 2); |
| + parameter_map->set_the_hole(entry + 2); |
| // For elements that are still writable we re-establish slow aliasing. |
| if ((attributes & READ_ONLY) == 0) { |
| Isolate* isolate = store->GetIsolate(); |
| - value = isolate->factory()->NewAliasedArgumentsEntry(context_index); |
| + value = isolate->factory()->NewAliasedArgumentsEntry(context_entry); |
| } |
| PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
| Handle<SeededNumberDictionary> arguments( |
| SeededNumberDictionary::cast(parameter_map->get(1))); |
| - arguments = SeededNumberDictionary::AddNumberEntry(arguments, index, |
| + arguments = SeededNumberDictionary::AddNumberEntry(arguments, entry, |
| value, details); |
| parameter_map->set(1, *arguments); |
| } else { |
| Handle<FixedArrayBase> arguments( |
| FixedArrayBase::cast(parameter_map->get(1))); |
| DictionaryElementsAccessor::ReconfigureImpl( |
| - object, arguments, index - length, value, attributes); |
| + object, arguments, entry - length, value, attributes); |
| } |
| } |
| }; |
| @@ -1632,13 +1636,13 @@ class FastSloppyArgumentsElementsAccessor |
| FastHoleyObjectElementsAccessor, |
| ElementsKindTraits<FAST_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {} |
| - static void DeleteFromArguments(Handle<JSObject> obj, uint32_t index) { |
| + static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) { |
| FixedArray* parameter_map = FixedArray::cast(obj->elements()); |
| Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
| - FastHoleyObjectElementsAccessor::DeleteCommon(obj, index, arguments); |
| + FastHoleyObjectElementsAccessor::DeleteCommon(obj, entry, arguments); |
| } |
| - static void AddImpl(Handle<JSObject> object, uint32_t key, |
| + static void AddImpl(Handle<JSObject> object, uint32_t index, |
| Handle<Object> value, PropertyAttributes attributes, |
| uint32_t new_capacity) { |
| DCHECK_EQ(NONE, attributes); |
| @@ -1649,21 +1653,21 @@ class FastSloppyArgumentsElementsAccessor |
| static_cast<uint32_t>(old_elements->length()) < new_capacity) { |
| GrowCapacityAndConvertImpl(object, new_capacity); |
| } |
| - SetImpl(object->elements(), key, *value); |
| + SetImpl(object->elements(), index, *value); |
| } |
| static void ReconfigureImpl(Handle<JSObject> object, |
| - Handle<FixedArrayBase> store, uint32_t index, |
| + Handle<FixedArrayBase> store, uint32_t entry, |
| Handle<Object> value, |
| PropertyAttributes attributes) { |
| Handle<SeededNumberDictionary> dictionary = |
| JSObject::NormalizeElements(object); |
| FixedArray::cast(*store)->set(1, *dictionary); |
| uint32_t length = static_cast<uint32_t>(store->length()) - 2; |
| - if (index >= length) { |
| - index = dictionary->FindEntry(index - length) + length; |
| + if (entry >= length) { |
| + entry = dictionary->FindEntry(entry - length) + length; |
| } |
| - SlowSloppyArgumentsElementsAccessor::ReconfigureImpl(object, store, index, |
| + SlowSloppyArgumentsElementsAccessor::ReconfigureImpl(object, store, entry, |
| value, attributes); |
| } |
| @@ -1749,7 +1753,7 @@ void ElementsAccessorBase<ElementsAccessorSubclass, ElementsKindTraits>:: |
| } // namespace |
| -void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
| +void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t index, |
| bool allow_appending) { |
| DisallowHeapAllocation no_allocation; |
| Object* raw_length = NULL; |
| @@ -1768,10 +1772,10 @@ void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key, |
| int32_t int32_length = DoubleToInt32(n); |
| uint32_t compare_length = static_cast<uint32_t>(int32_length); |
| if (allow_appending) compare_length++; |
| - if (key >= compare_length) { |
| + if (index >= compare_length) { |
| PrintF("[OOB %s %s (%s length = %d, element accessed = %d) in ", |
| elements_type, op, elements_type, static_cast<int>(int32_length), |
| - static_cast<int>(key)); |
| + static_cast<int>(index)); |
| TraceTopFrame(obj->GetIsolate()); |
| PrintF("]\n"); |
| } |
| @@ -1844,8 +1848,8 @@ MaybeHandle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, |
| case FAST_HOLEY_SMI_ELEMENTS: |
| case FAST_SMI_ELEMENTS: { |
| Handle<FixedArray> smi_elms = Handle<FixedArray>::cast(elms); |
| - for (int index = 0; index < number_of_elements; index++) { |
| - smi_elms->set(index, (*args)[index], SKIP_WRITE_BARRIER); |
| + for (int entry = 0; entry < number_of_elements; entry++) { |
| + smi_elms->set(entry, (*args)[entry], SKIP_WRITE_BARRIER); |
| } |
| break; |
| } |
| @@ -1854,8 +1858,8 @@ MaybeHandle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, |
| DisallowHeapAllocation no_gc; |
| WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); |
| Handle<FixedArray> object_elms = Handle<FixedArray>::cast(elms); |
| - for (int index = 0; index < number_of_elements; index++) { |
| - object_elms->set(index, (*args)[index], mode); |
| + for (int entry = 0; entry < number_of_elements; entry++) { |
| + object_elms->set(entry, (*args)[entry], mode); |
| } |
| break; |
| } |
| @@ -1863,8 +1867,8 @@ MaybeHandle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, |
| case FAST_DOUBLE_ELEMENTS: { |
| Handle<FixedDoubleArray> double_elms = |
| Handle<FixedDoubleArray>::cast(elms); |
| - for (int index = 0; index < number_of_elements; index++) { |
| - double_elms->set(index, (*args)[index]->Number()); |
| + for (int entry = 0; entry < number_of_elements; entry++) { |
| + double_elms->set(entry, (*args)[entry]->Number()); |
| } |
| break; |
| } |