Reviewers: Igor Sheludko,
Message:
ptal
Description:
Use entry rather than index in ElementsAccessor::Set
BUG=v8:4137,v8:4177
LOG=n
Please review this at https://codereview.chromium.org/1232463005/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+22, -22 lines):
M src/elements.h
M src/elements.cc
M src/lookup.cc
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index
e830d7c46500524ce32a8f0b213fc16214d5094d..da9cf795a4c38875f8787ab925bce7c6571e0364
100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -574,14 +574,14 @@ class ElementsAccessorBase : public ElementsAccessor {
}
}
- virtual void Set(FixedArrayBase* backing_store, uint32_t index,
+ virtual void Set(FixedArrayBase* backing_store, uint32_t entry,
Object* value) final {
- ElementsAccessorSubclass::SetImpl(backing_store, index, value);
+ ElementsAccessorSubclass::SetImpl(backing_store, entry, value);
}
- static void SetImpl(FixedArrayBase* backing_store, uint32_t index,
+ static void SetImpl(FixedArrayBase* backing_store, uint32_t entry,
Object* value) {
- BackingStore::cast(backing_store)->SetValue(index, value);
+ BackingStore::cast(backing_store)->SetValue(entry, value);
}
virtual void Reconfigure(Handle<JSObject> object,
@@ -599,14 +599,14 @@ class ElementsAccessorBase : public ElementsAccessor {
UNREACHABLE();
}
- virtual void Add(Handle<JSObject> object, uint32_t entry,
+ virtual void Add(Handle<JSObject> object, uint32_t index,
Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) final {
- ElementsAccessorSubclass::AddImpl(object, entry, value, attributes,
+ ElementsAccessorSubclass::AddImpl(object, index, value, attributes,
new_capacity);
}
- static void AddImpl(Handle<JSObject> object, uint32_t entry,
+ static void AddImpl(Handle<JSObject> object, uint32_t index,
Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) {
UNREACHABLE();
@@ -957,10 +957,8 @@ class DictionaryElementsAccessor
return isolate->factory()->the_hole_value();
}
- static void SetImpl(FixedArrayBase* store, uint32_t index, Object*
value) {
+ static void SetImpl(FixedArrayBase* store, uint32_t entry, Object*
value) {
SeededNumberDictionary* dictionary =
SeededNumberDictionary::cast(store);
- int entry = dictionary->FindEntry(index);
- DCHECK_NE(SeededNumberDictionary::kNotFound, entry);
dictionary->ValueAtPut(entry, value);
}
@@ -977,7 +975,7 @@ class DictionaryElementsAccessor
dictionary->DetailsAtPut(entry, details);
}
- static void AddImpl(Handle<JSObject> object, uint32_t entry,
+ static void AddImpl(Handle<JSObject> object, uint32_t index,
Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) {
PropertyDetails details(attributes, DATA, 0,
PropertyCellType::kNoCell);
@@ -986,7 +984,7 @@ class DictionaryElementsAccessor
? JSObject::NormalizeElements(object)
: handle(SeededNumberDictionary::cast(object->elements()));
Handle<SeededNumberDictionary> new_dictionary =
- SeededNumberDictionary::AddNumberEntry(dictionary, entry, value,
+ SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
details);
if (attributes != NONE) new_dictionary->set_requires_slow_elements();
if (dictionary.is_identical_to(new_dictionary)) return;
@@ -1121,7 +1119,7 @@ class FastElementsAccessor
value, attributes);
}
- static void AddImpl(Handle<JSObject> object, uint32_t entry,
+ static void AddImpl(Handle<JSObject> object, uint32_t index,
Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) {
DCHECK_EQ(NONE, attributes);
@@ -1143,7 +1141,7 @@ class FastElementsAccessor
JSObject::EnsureWritableFastElements(object);
}
}
- FastElementsAccessorSubclass::SetImpl(object->elements(), entry,
*value);
+ FastElementsAccessorSubclass::SetImpl(object->elements(), index,
*value);
}
static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) {
@@ -1478,17 +1476,18 @@ class SloppyArgumentsElementsAccessor
UNREACHABLE();
}
- static void SetImpl(FixedArrayBase* store, uint32_t index, Object*
value) {
+ static void SetImpl(FixedArrayBase* store, uint32_t entry, Object*
value) {
FixedArray* parameter_map = FixedArray::cast(store);
- Object* probe = GetParameterMapArg(parameter_map, index);
- if (!probe->IsTheHole()) {
+ uint32_t length = parameter_map->length() - 2;
+ if (entry < length) {
+ Object* probe = parameter_map->get(entry + 2);
Context* context = Context::cast(parameter_map->get(0));
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, index, value);
+ ArgumentsAccessor::SetImpl(arguments, entry - length, value);
}
}
@@ -1686,7 +1685,8 @@ class FastSloppyArgumentsElementsAccessor
static_cast<uint32_t>(old_elements->length()) < new_capacity) {
GrowCapacityAndConvertImpl(object, new_capacity);
}
- SetImpl(object->elements(), index, *value);
+ FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
+ FastHoleyObjectElementsAccessor::SetImpl(arguments, index, *value);
}
static void ReconfigureImpl(Handle<JSObject> object,
Index: src/elements.h
diff --git a/src/elements.h b/src/elements.h
index
9005096a1e2b0728b2ca516f7b3e7309d72abc04..584f1b54d714774238778777b8724bf8344982e2
100644
--- a/src/elements.h
+++ b/src/elements.h
@@ -119,13 +119,13 @@ class ElementsAccessor {
static void InitializeOncePerProcess();
static void TearDown();
- virtual void Set(FixedArrayBase* backing_store, uint32_t index,
+ virtual void Set(FixedArrayBase* backing_store, uint32_t entry,
Object* value) = 0;
virtual void Reconfigure(Handle<JSObject> object,
Handle<FixedArrayBase> backing_store, uint32_t
entry,
Handle<Object> value,
PropertyAttributes attributes) = 0;
- virtual void Add(Handle<JSObject> object, uint32_t entry,
+ virtual void Add(Handle<JSObject> object, uint32_t index,
Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) = 0;
Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index
be18b3b7a182f010a177b875ab000002d4b8a31a..a52e9afa7c35aa7b4b846fdb7da5edf083a633fb
100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -414,7 +414,7 @@ void LookupIterator::WriteDataValue(Handle<Object>
value) {
Handle<JSObject> holder = GetHolder<JSObject>();
if (IsElement()) {
ElementsAccessor* accessor = holder->GetElementsAccessor();
- accessor->Set(holder->elements(), index_, *value);
+ accessor->Set(holder->elements(), number_, *value);
} else if (holder->IsGlobalObject()) {
Handle<GlobalDictionary> property_dictionary =
handle(holder->global_dictionary());
--
--
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.