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

Unified Diff: src/elements.cc

Issue 1179933002: Revert of Remove GetAttributes from the mix to avoid another virtual dispatch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/lookup-inl.h » ('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 8cfb01b525c17a0de35438c0e2cae498d00fd78f..2734823852896d9379bcd870f10c32cb263de373 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -583,10 +583,15 @@
ElementsAccessorSubclass::ValidateImpl(holder);
}
+ static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
+ Handle<FixedArrayBase> backing_store) {
+ return ElementsAccessorSubclass::GetAttributesImpl(
+ *holder, key, *backing_store) != ABSENT;
+ }
+
virtual bool HasElement(Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> backing_store) final {
- return ElementsAccessorSubclass::GetIndexForKeyImpl(*holder, *backing_store,
- key) != kMaxUInt32;
+ return ElementsAccessorSubclass::HasElementImpl(holder, key, backing_store);
}
virtual Handle<Object> Get(Handle<JSObject> holder, uint32_t key,
@@ -626,6 +631,20 @@
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,
+ backing_store);
+ }
+
+ static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
+ FixedArrayBase* backing_store) {
+ if (key >= ElementsAccessorSubclass::GetCapacityImpl(obj, backing_store)) {
+ return ABSENT;
+ }
+ return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT : NONE;
}
virtual MaybeHandle<AccessorPair> GetAccessorPair(
@@ -823,21 +842,14 @@
return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index);
}
- static uint32_t GetIndexForKeyImpl(JSObject* holder,
- FixedArrayBase* backing_store,
+ static uint32_t GetIndexForKeyImpl(FixedArrayBase* backing_store,
uint32_t key) {
- return key < ElementsAccessorSubclass::GetCapacityImpl(holder,
- backing_store) &&
- !BackingStore::cast(backing_store)->is_the_hole(key)
- ? key
- : kMaxUInt32;
- }
-
- virtual uint32_t GetIndexForKey(JSObject* holder,
- FixedArrayBase* backing_store,
+ return key;
+ }
+
+ virtual uint32_t GetIndexForKey(FixedArrayBase* backing_store,
uint32_t key) final {
- return ElementsAccessorSubclass::GetIndexForKeyImpl(holder, backing_store,
- key);
+ return ElementsAccessorSubclass::GetIndexForKeyImpl(backing_store, key);
}
static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store,
@@ -980,6 +992,16 @@
virtual void Delete(Handle<JSObject> obj, uint32_t key,
LanguageMode language_mode) final {
DeleteCommon(obj, key, language_mode);
+ }
+
+ static bool HasElementImpl(
+ Handle<JSObject> holder,
+ uint32_t key,
+ Handle<FixedArrayBase> backing_store) {
+ if (key >= static_cast<uint32_t>(backing_store->length())) {
+ return false;
+ }
+ return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key);
}
static bool HasIndexImpl(FixedArrayBase* backing_store, uint32_t index) {
@@ -1271,6 +1293,13 @@
}
}
+ static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
+ FixedArrayBase* backing_store) {
+ 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);
@@ -1290,12 +1319,10 @@
// External arrays always ignore deletes.
}
- static uint32_t GetIndexForKeyImpl(JSObject* holder,
- FixedArrayBase* backing_store,
- uint32_t key) {
- return key < AccessorClass::GetCapacityImpl(holder, backing_store)
- ? key
- : kMaxUInt32;
+ static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
+ Handle<FixedArrayBase> backing_store) {
+ uint32_t capacity = AccessorClass::GetCapacityImpl(*holder, *backing_store);
+ return key < capacity;
}
static uint32_t GetCapacityImpl(JSObject* holder,
@@ -1458,6 +1485,17 @@
return value;
}
+ static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
+ FixedArrayBase* backing_store) {
+ SeededNumberDictionary* dictionary =
+ SeededNumberDictionary::cast(backing_store);
+ int entry = dictionary->FindEntry(key);
+ if (entry != SeededNumberDictionary::kNotFound) {
+ return dictionary->DetailsAt(entry).attributes();
+ }
+ return ABSENT;
+ }
+
static MaybeHandle<AccessorPair> GetAccessorPairImpl(
Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) {
Handle<SeededNumberDictionary> backing_store =
@@ -1471,6 +1509,13 @@
return MaybeHandle<AccessorPair>();
}
+ static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
+ Handle<FixedArrayBase> store) {
+ Handle<SeededNumberDictionary> backing_store =
+ Handle<SeededNumberDictionary>::cast(store);
+ return backing_store->FindEntry(key) != SeededNumberDictionary::kNotFound;
+ }
+
static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) {
DisallowHeapAllocation no_gc;
SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
@@ -1485,14 +1530,14 @@
return Smi::cast(key)->value();
}
- static uint32_t GetIndexForKeyImpl(JSObject* holder, FixedArrayBase* store,
- uint32_t key) {
+ static uint32_t GetIndexForKeyImpl(FixedArrayBase* store, uint32_t key) {
DisallowHeapAllocation no_gc;
SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
int entry = dict->FindEntry(key);
- return entry == SeededNumberDictionary::kNotFound
- ? kMaxUInt32
- : static_cast<uint32_t>(entry);
+ if (entry == SeededNumberDictionary::kNotFound) {
+ return kMaxUInt32;
+ }
+ return static_cast<uint32_t>(entry);
}
static PropertyDetails GetDetailsImpl(FixedArrayBase* backing_store,
@@ -1563,6 +1608,20 @@
->Set(obj, key, arguments, value);
}
+ static PropertyAttributes GetAttributesImpl(JSObject* obj, uint32_t key,
+ FixedArrayBase* backing_store) {
+ FixedArray* parameter_map = FixedArray::cast(backing_store);
+ Object* probe = GetParameterMapArg(parameter_map, key);
+ if (!probe->IsTheHole()) {
+ return NONE;
+ } else {
+ // If not aliased, check the arguments.
+ FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
+ return ElementsAccessor::ForArray(arguments)
+ ->GetAttributes(obj, key, arguments);
+ }
+ }
+
static MaybeHandle<AccessorPair> GetAccessorPairImpl(
Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) {
Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters);
@@ -1647,17 +1706,16 @@
return ForArray(arguments)->GetKeyForIndex(arguments, index - length);
}
- static uint32_t GetIndexForKeyImpl(JSObject* holder,
- FixedArrayBase* parameters, uint32_t key) {
+ static uint32_t GetIndexForKeyImpl(FixedArrayBase* parameters, uint32_t key) {
FixedArray* parameter_map = FixedArray::cast(parameters);
Object* probe = GetParameterMapArg(parameter_map, key);
if (!probe->IsTheHole()) return key;
+ uint32_t length = parameter_map->length() - 2;
FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
- uint32_t index = ElementsAccessor::ForArray(arguments)
- ->GetIndexForKey(holder, arguments, key);
- if (index == kMaxUInt32) return index;
- return (parameter_map->length() - 2) + index;
+ return length +
+ ElementsAccessor::ForArray(arguments)
+ ->GetIndexForKey(arguments, key);
}
static PropertyDetails GetDetailsImpl(FixedArrayBase* parameters,
« no previous file with comments | « src/elements.h ('k') | src/lookup-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698