Index: src/runtime/runtime-array.cc |
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc |
index b72a23a48018be48d87804b44ddba917bbe02e92..a017236a540643ef08e8b0f6b64c95d4dc0752b5 100644 |
--- a/src/runtime/runtime-array.cc |
+++ b/src/runtime/runtime-array.cc |
@@ -439,6 +439,25 @@ static void CollectElementIndices(Handle<JSObject> object, uint32_t range, |
} |
+static bool IterateElementsSlow(Isolate* isolate, Handle<JSObject> receiver, |
+ uint32_t length, ArrayConcatVisitor* visitor) { |
+ for (uint32_t i = 0; i < length; ++i) { |
+ HandleScope loop_scope(isolate); |
+ Maybe<bool> maybe = JSReceiver::HasElement(receiver, i); |
+ if (!maybe.has_value) return false; |
+ if (maybe.value) { |
+ Handle<Object> element_value; |
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
+ isolate, element_value, |
+ Runtime::GetElementOrCharAt(isolate, receiver, i), false); |
+ visitor->visit(i, element_value); |
+ } |
+ } |
+ visitor->increase_index_offset(length); |
+ return true; |
+} |
+ |
+ |
/** |
* A helper function that visits elements of a JSObject in numerical |
* order. |
@@ -469,6 +488,12 @@ static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver, |
} |
} |
+ if (!(receiver->IsJSArray() || receiver->IsJSTypedArray())) { |
+ // For classes which are not known to be safe to access via elements alone, |
+ // use the slow case. |
+ return IterateElementsSlow(isolate, receiver, length, visitor); |
+ } |
+ |
switch (receiver->GetElementsKind()) { |
case FAST_SMI_ELEMENTS: |
case FAST_ELEMENTS: |