Debian Codegraph @

js/src/jit-test/tests/warp/scalar-replace-rest-construct-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 class Base {
10 constructor() {
11 this.count = arguments.length;
12 }
13 }
14
15 class C extends Base {
16 constructor(...args) {
17 assertRecoveredOnBailout(args, true);
18 return super(...args);
19 }
20 }
21
22 function test() {
23 // Ensure |C| isn't inlined into its caller.
24 with ({});
25
26 for (let i = 0; i < 1000; ++i) {
27 let obj = new C(${args});
28 assertEq(obj.count, ${count});
29 }
30 }
31
32 return test;
33 `)();
34 }
35
36 // Inline rest arguments are limited to 14 elements, cf.
37 // gc::CanUseFixedElementsForArray() in WarpBuilder::build_Rest().
38 // There isn't such limit when the function isn't inlined.
39 const maxRestArgs = 20;
40
41 for (let i = 0; i <= maxRestArgs; ++i) {
42 makeTest(i)();
43 }