Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: src/elements.cc

Issue 1172683003: Use the LookupIterator for SetElement and friends (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/elements.h ('k') | src/harmony-array.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index cf55a202b4689f6b57598abfd0ebef6fc6d2450f..2734823852896d9379bcd870f10c32cb263de373 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -618,6 +618,21 @@ class ElementsAccessorBase : public ElementsAccessor {
}
}
+ virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key,
+ Handle<FixedArrayBase> backing_store,
+ Handle<Object> value) final {
+ return ElementsAccessorSubclass::SetImpl(holder, key, backing_store, value);
+ }
+
+ static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key,
+ Handle<FixedArrayBase> backing_store,
+ Handle<Object> value) {
+ CHECK(key <
+ ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store));
+ return BackingStore::SetValue(
+ obj, Handle<BackingStore>::cast(backing_store), key, value);
+ }
+
virtual PropertyAttributes GetAttributes(
JSObject* holder, uint32_t key, FixedArrayBase* backing_store) final {
return ElementsAccessorSubclass::GetAttributesImpl(holder, key,
@@ -1280,8 +1295,14 @@ class TypedElementsAccessor
static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
FixedArrayBase* backing_store) {
- return key < AccessorClass::GetCapacityImpl(obj, backing_store) ? NONE
- : ABSENT;
+ return key < AccessorClass::GetCapacityImpl(obj, backing_store)
+ ? DONT_DELETE
+ : ABSENT;
+ }
+
+ static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store,
+ uint32_t index) {
+ return PropertyDetails(DONT_DELETE, DATA, 0, PropertyCellType::kNoCell);
}
MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
@@ -1453,6 +1474,17 @@ class DictionaryElementsAccessor
return isolate->factory()->the_hole_value();
}
+ static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key,
+ Handle<FixedArrayBase> store,
+ Handle<Object> value) {
+ Handle<SeededNumberDictionary> backing_store =
+ Handle<SeededNumberDictionary>::cast(store);
+ int entry = backing_store->FindEntry(key);
+ DCHECK_NE(SeededNumberDictionary::kNotFound, entry);
+ backing_store->ValueAtPut(entry, *value);
+ return value;
+ }
+
static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
FixedArrayBase* backing_store) {
SeededNumberDictionary* dictionary =
@@ -1559,6 +1591,23 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
}
}
+ static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key,
+ Handle<FixedArrayBase> store,
+ Handle<Object> value) {
+ Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store);
+ Object* probe = GetParameterMapArg(*parameter_map, key);
+ 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);
+ return value;
+ }
+ Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
+ return ElementsAccessor::ForArray(arguments)
+ ->Set(obj, key, arguments, value);
+ }
+
static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
FixedArrayBase* backing_store) {
FixedArray* parameter_map = FixedArray::cast(backing_store);
« no previous file with comments | « src/elements.h ('k') | src/harmony-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698