Debian Codegraph @

js/src/jit-test/tests/warp/scalar-replace-rest-apply-array.js

raw
1 // Prevent GC from cancelling/discarding Ion compilations.
2 gczeal(0);
3
4 // Create a fresh set of functions for each argument count to avoid type pollution.
5 function makeTest(count) {
6 var args = Array(count).fill(0).join(",");
7
8 return Function(`
9 function g() {
10 return arguments.length;
11 }
12
13 function f(...args) {
14 assertRecoveredOnBailout(args, true);
15 return g(...args);
16 }
17
18 function test() {
19 // Ensure |f| isn't inlined into its caller.
20 with ({});
21
22 for (let i = 0; i < 1000; ++i) {
23 assertEq(f(${args}), ${count});
24 }
25 }
26
27 return test;
28 `)();
29 }
30
31 // Inline rest arguments are limited to 14 elements, cf.
32 // gc::CanUseFixedElementsForArray() in WarpBuilder::build_Rest().
33 // There isn't such limit when the function isn't inlined.
34 const maxRestArgs = 20;
35
36 for (let i = 0; i <= maxRestArgs; ++i) {
37 makeTest(i)();
38 }