Debian Codegraph @

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

raw
1 // |jit-test| --fast-warmup; --no-threads
2
3 setJitCompilerOption("baseline.warmup.trigger", 0);
4 setJitCompilerOption("ion.warmup.trigger", 100);
5
6 // Prevent GC from cancelling/discarding Ion compilations.
7 gczeal(0);
8
9 // Create a fresh set of functions for each argument count to avoid type pollution.
10 function makeTest(count) {
11 var args = Array(count).fill(0).join(",");
12
13 return Function(`
14 function g() {
15 return arguments.length;
16 }
17
18 function f(...args) {
19 // When |f| is inlined into its caller, the number of arguments is fixed and
20 // we can scalar replace the inlined rest array.
21 assertRecoveredOnBailout(args, true);
22 return g(...args);
23 }
24
25 // |f| must be small enough to be inlined into the test function.
26 assertEq(isSmallFunction(f), true);
27
28 function test() {
29 for (let i = 0; i < 1000; ++i) {
30 assertEq(f(${args}), ${count});
31 }
32 }
33
34 return test;
35 `)();
36 }
37
38 // Limited by gc::CanUseFixedElementsForArray(), see also WarpBuilder::build_Rest().
39 const maxRestArgs = 14;
40
41 for (let i = 0; i <= maxRestArgs; ++i) {
42 makeTest(i)();
43 }