Debian Codegraph @

js/src/jit-test/tests/cacheir/fun-apply-as-call-native-3.js

raw
1 // Function.prototype.apply is inlined as Function.prototype.call when it's
2 // called with less than two arguments.
3 //
4 // Test inlining through specialised natives.
5
6 // NOTE: We don't inline when |apply| is called with zero arguments.
7 function testThisAbsent() {
8 for (let i = 0; i < 200; ++i) {
9 let r = Array.apply();
10 assertEq(r.length, 0);
11 }
12 }
13 for (let i = 0; i < 2; ++i) testThisAbsent();
14
15 function test0() {
16 for (let i = 0; i < 200; ++i) {
17 let r = Array.apply(null);
18 assertEq(r.length, 0);
19 }
20 }
21 for (let i = 0; i < 2; ++i) test0();
22
23 // NOTE: We don't yet inline the case when the second argument is |null|.
24 function test1Null() {
25 for (let i = 0; i < 200; ++i) {
26 let r = Array.apply(null, null);
27 assertEq(r.length, 0);
28 }
29 }
30 for (let i = 0; i < 2; ++i) test1Null();
31
32 // NOTE: We don't yet inline the case when the second argument is |undefined|.
33 function test1Undefined() {
34 for (let i = 0; i < 200; ++i) {
35 let r = Array.apply(null, undefined);
36 assertEq(r.length, 0);
37 }
38 }
39 for (let i = 0; i < 2; ++i) test1Undefined();