Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 9ed3a661e8f852195f0a64de157b3f8b3a26d4ae..3bfe1d1df48a0e0bda80a5d9113e45da92abfb9f 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -983,19 +983,18 @@ MaybeHandle<JSObject> JSObject::New(Handle<JSFunction> constructor, |
return result; |
} |
- |
-Handle<FixedArray> JSObject::EnsureWritableFastElements( |
- Handle<JSObject> object) { |
+void JSObject::EnsureWritableFastElements(Handle<JSObject> object) { |
DCHECK(object->HasFastSmiOrObjectElements() || |
object->HasFastStringWrapperElements()); |
- Isolate* isolate = object->GetIsolate(); |
- Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate); |
- if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems; |
+ FixedArray* raw_elems = FixedArray::cast(object->elements()); |
+ Heap* heap = object->GetHeap(); |
+ if (raw_elems->map() != heap->fixed_cow_array_map()) return; |
+ Isolate* isolate = heap->isolate(); |
+ Handle<FixedArray> elems(raw_elems, isolate); |
Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap( |
elems, isolate->factory()->fixed_array_map()); |
object->set_elements(*writable_elems); |
isolate->counters()->cow_arrays_converted()->Increment(); |
- return writable_elems; |
} |
@@ -16228,10 +16227,16 @@ bool Map::IsValidElementsTransition(ElementsKind from_kind, |
bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { |
- LookupIterator it(array, array->GetIsolate()->factory()->length_string(), |
+ 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(); |
+ } |
+ |
+ LookupIterator it(array, isolate->factory()->length_string(), |
LookupIterator::OWN_SKIP_INTERCEPTOR); |
- CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); |
- CHECK(it.IsFound()); |
CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
return it.IsReadOnly(); |
} |