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

Unified Diff: src/builtins.cc

Issue 11442054: Remove over-zealous hole checking in Array.slice() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add --allow-natives-syntax Created 8 years 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 | test/mjsunit/regress/regress-165637.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-165637.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698