Title: [185038] trunk
Revision
185038
Author
[email protected]
Date
2015-05-31 02:28:54 -0700 (Sun, 31 May 2015)

Log Message

Array#reduce and reduceRight don't follow ToLength
https://bugs.webkit.org/show_bug.cgi?id=145364
Source/_javascript_Core:

Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength

Patch by Jordan Harband <[email protected]> on 2015-05-31
Reviewed by Yusuke Suzuki.

* builtins/Array.prototype.js:
(reduce):
(reduceRight):
* runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::finishCreation):
(JSC::arrayProtoFuncReduce): Deleted.
(JSC::arrayProtoFuncReduceRight): Deleted.

LayoutTests:

Patch by Jordan Harband <[email protected]> on 2015-05-31
Reviewed by Yusuke Suzuki.

* js/array-reduce-expected.txt:
* js/array-reduceRight-expected.txt:
* js/dom/array-prototype-properties-expected.txt:
* js/dom/script-tests/array-prototype-properties.js:
* js/script-tests/array-reduce.js:
* js/script-tests/array-reduceRight.js:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185037 => 185038)


--- trunk/LayoutTests/ChangeLog	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/ChangeLog	2015-05-31 09:28:54 UTC (rev 185038)
@@ -1,3 +1,17 @@
+2015-05-31  Jordan Harband  <[email protected]>
+
+        Array#reduce and reduceRight don't follow ToLength
+        https://bugs.webkit.org/show_bug.cgi?id=145364
+
+        Reviewed by Yusuke Suzuki.
+
+        * js/array-reduce-expected.txt:
+        * js/array-reduceRight-expected.txt:
+        * js/dom/array-prototype-properties-expected.txt:
+        * js/dom/script-tests/array-prototype-properties.js:
+        * js/script-tests/array-reduce.js:
+        * js/script-tests/array-reduceRight.js:
+
 2015-05-30  Filip Pizlo  <[email protected]>
 
         FTL codegen for MultiGetByOffset and MultiPutByOffset where the structure set is already proved should have an unreachable default case instead of an exit

Modified: trunk/LayoutTests/js/array-reduce-expected.txt (185037 => 185038)


--- trunk/LayoutTests/js/array-reduce-expected.txt	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/js/array-reduce-expected.txt	2015-05-31 09:28:54 UTC (rev 185038)
@@ -34,6 +34,7 @@
 PASS toUnorderedObject([0,1,2,3,4,5]).reduce(function(a,b,i) {return a.concat([i,b]);}, []) is [0,0,1,1,2,2,3,3,4,4,5,5]
 PASS [0,1,2,3,4,5].reduce(function(a,b,i) {return a.concat([i,b]);}, []) is [0,0,1,1,2,2,3,3,4,4,5,5]
 PASS [2,3].reduce(function() {'use strict'; return this;}) is undefined
+PASS Array.prototype.reduce.call(negativeLengthObject, function (a, b) { return a + b; }, 100) is 100
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/js/array-reduceRight-expected.txt (185037 => 185038)


--- trunk/LayoutTests/js/array-reduceRight-expected.txt	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/js/array-reduceRight-expected.txt	2015-05-31 09:28:54 UTC (rev 185038)
@@ -35,6 +35,7 @@
 PASS toUnorderedObject([0,1,2,3,4,5]).reduceRight(function(a,b,i) {return a.concat([i,b]);}, []) is [5,5,4,4,3,3,2,2,1,1,0,0]
 PASS [0,1,2,3,4,5].reduceRight(function(a,b,i) {return a.concat([i,b]);}, []) is [5,5,4,4,3,3,2,2,1,1,0,0]
 PASS [2,3].reduceRight(function() {'use strict'; return this;}) is undefined
+PASS Array.prototype.reduceRight.call(negativeLengthObject, function (a, b) { return a + b; }, 100) is 100
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/js/dom/array-prototype-properties-expected.txt (185037 => 185038)


--- trunk/LayoutTests/js/dom/array-prototype-properties-expected.txt	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/js/dom/array-prototype-properties-expected.txt	2015-05-31 09:28:54 UTC (rev 185038)
@@ -19,10 +19,10 @@
 PASS Array.prototype.forEach.call(undefined, toString) threw exception TypeError: Array.prototype.forEach requires that |this| not be undefined.
 PASS Array.prototype.some.call(undefined, toString) threw exception TypeError: Array.prototype.some requires that |this| not be undefined.
 PASS Array.prototype.indexOf.call(undefined, 0) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.indexOf.call(undefined, 0)').
-PASS Array.prototype.indlastIndexOfexOf.call(undefined, 0) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.indlastIndexOfexOf.call').
+PASS Array.prototype.lastIndexOf.call(undefined, 0) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.lastIndexOf.call(undefined, 0)').
 PASS Array.prototype.filter.call(undefined, toString) threw exception TypeError: Array.prototype.filter requires that |this| not be undefined.
-PASS Array.prototype.reduce.call(undefined, toString) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.reduce.call(undefined, toString)').
-PASS Array.prototype.reduceRight.call(undefined, toString) threw exception TypeError: undefined is not an object (evaluating 'Array.prototype.reduceRight.call(undefined, toString)').
+PASS Array.prototype.reduce.call(undefined, toString) threw exception TypeError: Array.prototype.reduce requires that |this| not be undefined.
+PASS Array.prototype.reduceRight.call(undefined, toString) threw exception TypeError: Array.prototype.reduceRight requires that |this| not be undefined.
 PASS Array.prototype.map.call(undefined, toString) threw exception TypeError: Array.prototype.map requires that |this| not be undefined.
 PASS [{toLocaleString:function(){throw 1}},{toLocaleString:function(){throw 2}}].toLocaleString() threw exception 1.
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/js/dom/script-tests/array-prototype-properties.js (185037 => 185038)


--- trunk/LayoutTests/js/dom/script-tests/array-prototype-properties.js	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/js/dom/script-tests/array-prototype-properties.js	2015-05-31 09:28:54 UTC (rev 185038)
@@ -19,7 +19,7 @@
 shouldThrow("Array.prototype.forEach.call(undefined, toString)");
 shouldThrow("Array.prototype.some.call(undefined, toString)");
 shouldThrow("Array.prototype.indexOf.call(undefined, 0)");
-shouldThrow("Array.prototype.indlastIndexOfexOf.call(undefined, 0)");
+shouldThrow("Array.prototype.lastIndexOf.call(undefined, 0)");
 shouldThrow("Array.prototype.filter.call(undefined, toString)");
 shouldThrow("Array.prototype.reduce.call(undefined, toString)");
 shouldThrow("Array.prototype.reduceRight.call(undefined, toString)");

Added: trunk/LayoutTests/js/regress/array-prototype-reduce-expected.txt (0 => 185038)


--- trunk/LayoutTests/js/regress/array-prototype-reduce-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regress/array-prototype-reduce-expected.txt	2015-05-31 09:28:54 UTC (rev 185038)
@@ -0,0 +1,10 @@
+JSRegress/array-prototype-reduce
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/regress/array-prototype-reduce.html (0 => 185038)


--- trunk/LayoutTests/js/regress/array-prototype-reduce.html	                        (rev 0)
+++ trunk/LayoutTests/js/regress/array-prototype-reduce.html	2015-05-31 09:28:54 UTC (rev 185038)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/regress/array-prototype-reduceRight-expected.txt (0 => 185038)


--- trunk/LayoutTests/js/regress/array-prototype-reduceRight-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regress/array-prototype-reduceRight-expected.txt	2015-05-31 09:28:54 UTC (rev 185038)
@@ -0,0 +1,10 @@
+JSRegress/array-prototype-reduceRight
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/regress/array-prototype-reduceRight.html (0 => 185038)


--- trunk/LayoutTests/js/regress/array-prototype-reduceRight.html	                        (rev 0)
+++ trunk/LayoutTests/js/regress/array-prototype-reduceRight.html	2015-05-31 09:28:54 UTC (rev 185038)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/regress/script-tests/array-prototype-reduce.js (0 => 185038)


--- trunk/LayoutTests/js/regress/script-tests/array-prototype-reduce.js	                        (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/array-prototype-reduce.js	2015-05-31 09:28:54 UTC (rev 185038)
@@ -0,0 +1,29 @@
+var result = 0;
+function test1(a) {
+    result << 1;
+    result++;
+    return true;
+}
+function test2(a,b) {
+    result ^= 3;
+    result *= 3;
+    return true;
+}
+function test3(a,b,c) {
+    result ^= result >> 1;
+    return true;
+}
+
+var result = 0;
+var array = []
+for (var i = 0; i < 100000; ++i)
+    array[i] = 1;
+
+for (var i = 0; i < 10; i++) {
+    array.reduce(test1, {});
+    array.reduce(test2, {});
+    array.reduce(test3, {});
+}
+
+if (result != 1428810496)
+    throw "Error: bad result: " + result;

Added: trunk/LayoutTests/js/regress/script-tests/array-prototype-reduceRight.js (0 => 185038)


--- trunk/LayoutTests/js/regress/script-tests/array-prototype-reduceRight.js	                        (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/array-prototype-reduceRight.js	2015-05-31 09:28:54 UTC (rev 185038)
@@ -0,0 +1,29 @@
+var result = 0;
+function test1(a) {
+    result << 1;
+    result++;
+    return true;
+}
+function test2(a,b) {
+    result ^= 3;
+    result *= 3;
+    return true;
+}
+function test3(a,b,c) {
+    result ^= result >> 1;
+    return true;
+}
+
+var result = 0;
+var array = []
+for (var i = 0; i < 100000; ++i)
+    array[i] = 1;
+
+for (var i = 0; i < 10; i++) {
+    array.reduceRight(test1, {});
+    array.reduceRight(test2, {});
+    array.reduceRight(test3, {});
+}
+
+if (result != 1428810496)
+    throw "Error: bad result: " + result;

Modified: trunk/LayoutTests/js/script-tests/array-reduce.js (185037 => 185038)


--- trunk/LayoutTests/js/script-tests/array-reduce.js	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/js/script-tests/array-reduce.js	2015-05-31 09:28:54 UTC (rev 185038)
@@ -66,3 +66,6 @@
 shouldBe("toUnorderedObject([0,1,2,3,4,5]).reduce(function(a,b,i) {return a.concat([i,b]);}, [])", "[0,0,1,1,2,2,3,3,4,4,5,5]");
 shouldBe("[0,1,2,3,4,5].reduce(function(a,b,i) {return a.concat([i,b]);}, [])", "[0,0,1,1,2,2,3,3,4,4,5,5]");
 shouldBe("[2,3].reduce(function() {'use strict'; return this;})", "undefined");
+
+var negativeLengthObject = { length: -1, 0: 1, 1: 2 };
+shouldBe("Array.prototype.reduce.call(negativeLengthObject, function (a, b) { return a + b; }, 100)", "100");

Modified: trunk/LayoutTests/js/script-tests/array-reduceRight.js (185037 => 185038)


--- trunk/LayoutTests/js/script-tests/array-reduceRight.js	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/LayoutTests/js/script-tests/array-reduceRight.js	2015-05-31 09:28:54 UTC (rev 185038)
@@ -68,3 +68,6 @@
 shouldBe("toUnorderedObject([0,1,2,3,4,5]).reduceRight(function(a,b,i) {return a.concat([i,b]);}, [])", "[5,5,4,4,3,3,2,2,1,1,0,0]");
 shouldBe("[0,1,2,3,4,5].reduceRight(function(a,b,i) {return a.concat([i,b]);}, [])", "[5,5,4,4,3,3,2,2,1,1,0,0]");
 shouldBe("[2,3].reduceRight(function() {'use strict'; return this;})", "undefined");
+
+var negativeLengthObject = { length: -1, 0: 1, 1: 2 };
+shouldBe("Array.prototype.reduceRight.call(negativeLengthObject, function (a, b) { return a + b; }, 100)", "100");

Modified: trunk/Source/_javascript_Core/ChangeLog (185037 => 185038)


--- trunk/Source/_javascript_Core/ChangeLog	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-05-31 09:28:54 UTC (rev 185038)
@@ -1,3 +1,19 @@
+2015-05-31  Jordan Harband  <[email protected]>
+
+        Array#reduce and reduceRight don't follow ToLength
+        https://bugs.webkit.org/show_bug.cgi?id=145364
+        Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
+
+        Reviewed by Yusuke Suzuki.
+
+        * builtins/Array.prototype.js:
+        (reduce):
+        (reduceRight):
+        * runtime/ArrayPrototype.cpp:
+        (JSC::ArrayPrototype::finishCreation):
+        (JSC::arrayProtoFuncReduce): Deleted.
+        (JSC::arrayProtoFuncReduceRight): Deleted.
+
 2015-05-29  Filip Pizlo  <[email protected]>
 
         FTL codegen for MultiGetByOffset and MultiPutByOffset where the structure set is already proved should have an unreachable default case instead of an exit

Modified: trunk/Source/_javascript_Core/builtins/Array.prototype.js (185037 => 185038)


--- trunk/Source/_javascript_Core/builtins/Array.prototype.js	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/Source/_javascript_Core/builtins/Array.prototype.js	2015-05-31 09:28:54 UTC (rev 185038)
@@ -24,6 +24,80 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+function reduce(callback /*, initialValue */)
+{
+    "use strict";
+    if (this === null)
+        throw new @TypeError("Array.prototype.reduce requires that |this| not be null");
+
+    if (this === undefined)
+        throw new @TypeError("Array.prototype.reduce requires that |this| not be undefined");
+
+    var array = @Object(this);
+    var length = @ToLength(array.length);
+
+    if (typeof callback !== "function")
+        throw new @TypeError("Array.prototype.reduce callback must be a function");
+
+    if (length === 0 && arguments.length < 2)
+        throw new @TypeError("reduce of empty array with no initial value");
+
+    var accumulator, k = 0;
+    if (arguments.length > 1)
+        accumulator = arguments[1];
+    else {
+        while (k < length && !(k in array))
+            k += 1;
+        if (k >= length)
+            throw new @TypeError("reduce of empty array with no initial value");
+        accumulator = array[k++];
+    }
+
+    while (k < length) {
+        if (k in array)
+            accumulator = callback.@call(undefined, accumulator, array[k], k, array);
+        k += 1;
+    }
+    return accumulator;
+}
+
+function reduceRight(callback /*, initialValue */)
+{
+    "use strict";
+    if (this === null)
+        throw new @TypeError("Array.prototype.reduceRight requires that |this| not be null");
+
+    if (this === undefined)
+        throw new @TypeError("Array.prototype.reduceRight requires that |this| not be undefined");
+
+    var array = @Object(this);
+    var length = @ToLength(array.length);
+
+    if (typeof callback !== "function")
+        throw new @TypeError("Array.prototype.reduceRight callback must be a function");
+
+    if (length === 0 && arguments.length < 2)
+        throw new @TypeError("reduceRight of empty array with no initial value");
+
+    var accumulator, k = length - 1;
+    if (arguments.length > 1)
+        accumulator = arguments[1];
+    else {
+        while (k >= 0 && !(k in array))
+            k -= 1;
+        if (k < 0)
+            throw new @TypeError("reduceRight of empty array with no initial value");
+        accumulator = array[k--];
+    }
+
+    while (k >= 0) {
+        if (k in array)
+            accumulator = callback.@call(undefined, accumulator, array[k], k, array);
+        k -= 1;
+    }
+    return accumulator;
+}
+
 function every(callback /*, thisArg */) {
     "use strict";
     if (this === null)

Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (185037 => 185038)


--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2015-05-31 05:53:06 UTC (rev 185037)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2015-05-31 09:28:54 UTC (rev 185038)
@@ -109,8 +109,8 @@
     JSC_NATIVE_FUNCTION("indexOf", arrayProtoFuncIndexOf, DontEnum, 1);
     JSC_NATIVE_FUNCTION("lastIndexOf", arrayProtoFuncLastIndexOf, DontEnum, 1);
     JSC_BUILTIN_FUNCTION("filter", arrayPrototypeFilterCodeGenerator, DontEnum);
-    JSC_NATIVE_FUNCTION("reduce", arrayProtoFuncReduce, DontEnum, 1);
-    JSC_NATIVE_FUNCTION("reduceRight", arrayProtoFuncReduceRight, DontEnum, 1);
+    JSC_BUILTIN_FUNCTION("reduce", arrayPrototypeReduceCodeGenerator, DontEnum);
+    JSC_BUILTIN_FUNCTION("reduceRight", arrayPrototypeReduceRightCodeGenerator, DontEnum);
     JSC_BUILTIN_FUNCTION("map", arrayPrototypeMapCodeGenerator, DontEnum);
     JSC_NATIVE_FUNCTION(vm.propertyNames->entries, arrayProtoFuncEntries, DontEnum, 0);
     JSC_NATIVE_FUNCTION(vm.propertyNames->keys, arrayProtoFuncKeys, DontEnum, 0);
@@ -720,159 +720,6 @@
     return JSValue::encode(result);
 }
 
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduce(ExecState* exec)
-{
-    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
-    unsigned length = getLength(exec, thisObj);
-    if (exec->hadException())
-        return JSValue::encode(jsUndefined());
-
-    JSValue function = exec->argument(0);
-    CallData callData;
-    CallType callType = getCallData(function, callData);
-    if (callType == CallTypeNone)
-        return throwVMTypeError(exec);
-
-    unsigned i = 0;
-    JSValue rv;
-    if (!length && exec->argumentCount() == 1)
-        return throwVMTypeError(exec);
-
-    JSArray* array = 0;
-    if (isJSArray(thisObj))
-        array = asArray(thisObj);
-
-    if (exec->argumentCount() >= 2)
-        rv = exec->uncheckedArgument(1);
-    else if (array && array->canGetIndexQuickly(0)) {
-        rv = array->getIndexQuickly(0);
-        i = 1;
-    } else {
-        for (i = 0; i < length; i++) {
-            rv = getProperty(exec, thisObj, i);
-            if (exec->hadException())
-                return JSValue::encode(jsUndefined());
-            if (rv)
-                break;
-        }
-        if (!rv)
-            return throwVMTypeError(exec);
-        i++;
-    }
-
-    if (callType == CallTypeJS && array) {
-        CachedCall cachedCall(exec, jsCast<JSFunction*>(function), 4);
-        for (; i < length && !exec->hadException(); ++i) {
-            cachedCall.setThis(jsUndefined());
-            cachedCall.setArgument(0, rv);
-            JSValue v;
-            if (LIKELY(array->canGetIndexQuickly(i)))
-                v = array->getIndexQuickly(i);
-            else
-                break; // length has been made unsafe while we enumerate fallback to slow path
-            cachedCall.setArgument(1, v);
-            cachedCall.setArgument(2, jsNumber(i));
-            cachedCall.setArgument(3, array);
-            rv = cachedCall.call();
-        }
-        if (i == length) // only return if we reached the end of the array
-            return JSValue::encode(rv);
-    }
-
-    for (; i < length && !exec->hadException(); ++i) {
-        JSValue prop = getProperty(exec, thisObj, i);
-        if (exec->hadException())
-            return JSValue::encode(jsUndefined());
-        if (!prop)
-            continue;
-        
-        MarkedArgumentBuffer eachArguments;
-        eachArguments.append(rv);
-        eachArguments.append(prop);
-        eachArguments.append(jsNumber(i));
-        eachArguments.append(thisObj);
-        
-        rv = call(exec, function, callType, callData, jsUndefined(), eachArguments);
-    }
-    return JSValue::encode(rv);
-}
-
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncReduceRight(ExecState* exec)
-{
-    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
-    unsigned length = getLength(exec, thisObj);
-    if (exec->hadException())
-        return JSValue::encode(jsUndefined());
-
-    JSValue function = exec->argument(0);
-    CallData callData;
-    CallType callType = getCallData(function, callData);
-    if (callType == CallTypeNone)
-        return throwVMTypeError(exec);
-    
-    unsigned i = 0;
-    JSValue rv;
-    if (!length && exec->argumentCount() == 1)
-        return throwVMTypeError(exec);
-
-    JSArray* array = 0;
-    if (isJSArray(thisObj))
-        array = asArray(thisObj);
-    
-    if (exec->argumentCount() >= 2)
-        rv = exec->uncheckedArgument(1);
-    else if (array && array->canGetIndexQuickly(length - 1)) {
-        rv = array->getIndexQuickly(length - 1);
-        i = 1;
-    } else {
-        for (i = 0; i < length; i++) {
-            rv = getProperty(exec, thisObj, length - i - 1);
-            if (exec->hadException())
-                return JSValue::encode(jsUndefined());
-            if (rv)
-                break;
-        }
-        if (!rv)
-            return throwVMTypeError(exec);
-        i++;
-    }
-    
-    if (callType == CallTypeJS && array) {
-        CachedCall cachedCall(exec, jsCast<JSFunction*>(function), 4);
-        for (; i < length && !exec->hadException(); ++i) {
-            unsigned idx = length - i - 1;
-            cachedCall.setThis(jsUndefined());
-            cachedCall.setArgument(0, rv);
-            if (UNLIKELY(!array->canGetIndexQuickly(idx)))
-                break; // length has been made unsafe while we enumerate fallback to slow path
-            cachedCall.setArgument(1, array->getIndexQuickly(idx));
-            cachedCall.setArgument(2, jsNumber(idx));
-            cachedCall.setArgument(3, array);
-            rv = cachedCall.call();
-        }
-        if (i == length) // only return if we reached the end of the array
-            return JSValue::encode(rv);
-    }
-    
-    for (; i < length && !exec->hadException(); ++i) {
-        unsigned idx = length - i - 1;
-        JSValue prop = getProperty(exec, thisObj, idx);
-        if (exec->hadException())
-            return JSValue::encode(jsUndefined());
-        if (!prop)
-            continue;
-        
-        MarkedArgumentBuffer eachArguments;
-        eachArguments.append(rv);
-        eachArguments.append(prop);
-        eachArguments.append(jsNumber(idx));
-        eachArguments.append(thisObj);
-        
-        rv = call(exec, function, callType, callData, jsUndefined(), eachArguments);
-    }
-    return JSValue::encode(rv);        
-}
-
 EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec)
 {
     // 15.4.4.14
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to