Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index d62713db4cf3ec39882ac1e717318c9253476988..97fcaebff5875553bc19e1aa33cd54bf3a61beea 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -858,23 +858,6 @@ BUILTIN(ArraySlice) { |
} |
JSObject* object = JSObject::cast(receiver); |
- ElementsKind kind = object->GetElementsKind(); |
- |
- if (IsHoleyElementsKind(kind)) { |
- bool packed = true; |
- ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); |
- for (int i = 0; i < len; i++) { |
- if (!accessor->HasElement(object, object, i, elms)) { |
- packed = false; |
- break; |
- } |
- } |
- if (packed) { |
- kind = GetPackedElementsKind(kind); |
- } else if (!receiver->IsJSArray()) { |
- return CallJsBuiltin(isolate, "ArraySlice", args); |
- } |
- } |
ASSERT(len >= 0); |
int n_arguments = args.length() - 1; |
@@ -924,6 +907,23 @@ BUILTIN(ArraySlice) { |
// Calculate the length of result array. |
int result_len = Max(final - k, 0); |
+ ElementsKind kind = object->GetElementsKind(); |
+ if (IsHoleyElementsKind(kind)) { |
+ bool packed = true; |
+ ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); |
+ for (int i = k; i < final; i++) { |
+ if (!accessor->HasElement(object, object, i, elms)) { |
+ packed = false; |
+ break; |
+ } |
+ } |
+ if (packed) { |
+ kind = GetPackedElementsKind(kind); |
+ } else if (!receiver->IsJSArray()) { |
+ return CallJsBuiltin(isolate, "ArraySlice", args); |
+ } |
+ } |
+ |
JSArray* result_array; |
MaybeObject* maybe_array = heap->AllocateJSArrayAndStorage(kind, |
result_len, |