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

Unified Diff: src/objects.cc

Issue 1716833002: [runtime] Speed up C++ version of ArrayPush (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add TODO for Toon's comment Created 4 years, 10 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/objects.h ('k') | 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 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();
}
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698