44f88dcd87
This fixes the second-order Array.prototype function {forEach} and {map} to now perform a callability check of the given callback function. For empty arrays it is observable whether such a check outside the loop has been elided or not. R=mvstanton@chromium.org TEST=mjsunit/regress/regress-crbug-747062 BUG=chromium:747062 Change-Id: I1bbe7f44b3b3d18e9b41ad0436975434adf84321 Reviewed-on: https://chromium-review.googlesource.com/588893 Reviewed-by: Michael Stanton <mvstanton@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#46942}
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
(function TestNonCallableForEach() {
|
|
function foo() { [].forEach(undefined) }
|
|
assertThrows(foo, TypeError);
|
|
assertThrows(foo, TypeError);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo, TypeError);
|
|
})();
|
|
|
|
(function TestNonCallableForEachCaught() {
|
|
function foo() { try { [].forEach(undefined) } catch(e) { return e } }
|
|
assertInstanceof(foo(), TypeError);
|
|
assertInstanceof(foo(), TypeError);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertInstanceof(foo(), TypeError);
|
|
})();
|
|
|
|
(function TestNonCallableMap() {
|
|
function foo() { [].map(undefined); }
|
|
assertThrows(foo, TypeError);
|
|
assertThrows(foo, TypeError);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo, TypeError);
|
|
})();
|
|
|
|
(function TestNonCallableMapCaught() {
|
|
function foo() { try { [].map(undefined) } catch(e) { return e } }
|
|
assertInstanceof(foo(), TypeError);
|
|
assertInstanceof(foo(), TypeError);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertInstanceof(foo(), TypeError);
|
|
})();
|