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

Unified Diff: src/objects.cc

Issue 1823613002: Simplify JSArray::HasReadOnlyLength (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 5a9e91b8fb76e7eb9d1f76a9997998c95332825a..b9ae9db18cc3da9cde9bbb7d159a805d78217951 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -16116,14 +16116,16 @@ bool Map::IsValidElementsTransition(ElementsKind from_kind,
bool JSArray::HasReadOnlyLength(Handle<JSArray> array) {
- Isolate* isolate = array->GetIsolate();
- // Optimistic fast path: "length" is usually the first fast property.
- DescriptorArray* descriptors = array->map()->instance_descriptors();
- if (descriptors->length() >= 1 &&
- descriptors->GetKey(0) == isolate->heap()->length_string()) {
- return descriptors->GetDetails(0).IsReadOnly();
+ Map* map = array->map();
+ // Fast path: "length" is the first fast property of arrays. Since it's not
+ // configurable, it's guaranteed to be the first in the descriptor array.
+ if (!map->is_dictionary_map()) {
+ DCHECK(map->instance_descriptors()->GetKey(0) ==
+ array->GetHeap()->length_string());
+ return map->instance_descriptors()->GetDetails(0).IsReadOnly();
}
+ Isolate* isolate = array->GetIsolate();
LookupIterator it(array, isolate->factory()->length_string(), array,
LookupIterator::OWN_SKIP_INTERCEPTOR);
CHECK_EQ(LookupIterator::ACCESSOR, it.state());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698