Commit f7bac43d authored by verwaest's avatar verwaest Committed by Commit bot

Simplify JSArray::HasReadOnlyLength

BUG=

Review URL: https://codereview.chromium.org/1823613002

Cr-Commit-Position: refs/heads/master@{#34956}
parent 48d082af
...@@ -16117,14 +16117,16 @@ bool Map::IsValidElementsTransition(ElementsKind from_kind, ...@@ -16117,14 +16117,16 @@ bool Map::IsValidElementsTransition(ElementsKind from_kind,
bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { bool JSArray::HasReadOnlyLength(Handle<JSArray> array) {
Isolate* isolate = array->GetIsolate(); Map* map = array->map();
// Optimistic fast path: "length" is usually the first fast property. // Fast path: "length" is the first fast property of arrays. Since it's not
DescriptorArray* descriptors = array->map()->instance_descriptors(); // configurable, it's guaranteed to be the first in the descriptor array.
if (descriptors->length() >= 1 && if (!map->is_dictionary_map()) {
descriptors->GetKey(0) == isolate->heap()->length_string()) { DCHECK(map->instance_descriptors()->GetKey(0) ==
return descriptors->GetDetails(0).IsReadOnly(); array->GetHeap()->length_string());
return map->instance_descriptors()->GetDetails(0).IsReadOnly();
} }
Isolate* isolate = array->GetIsolate();
LookupIterator it(array, isolate->factory()->length_string(), array, LookupIterator it(array, isolate->factory()->length_string(), array,
LookupIterator::OWN_SKIP_INTERCEPTOR); LookupIterator::OWN_SKIP_INTERCEPTOR);
CHECK_EQ(LookupIterator::ACCESSOR, it.state()); CHECK_EQ(LookupIterator::ACCESSOR, it.state());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment