Debian Codegraph @

js/src/jit-test/tests/warp/bug1661728.js

raw
1 with ({}) {} // Don't inline anything into the top-level script.
2
3 function foo() {}
4
5 function inline_foo_into_bar() {
6 with ({}) {} // Don't inline anything into this function.
7 for (var i = 0; i < 10; i++) {
8 bar(2);
9 }
10
11 }
12
13 function bar(x) {
14 switch (x) {
15 case 1:
16 inline_foo_into_bar();
17
18 // Trigger a compacting gc to discard foo's jitscript.
19 // Do it while bar is on the stack to keep bar's jitscript alive.
20 gc(foo, 'shrinking');
21 break;
22 case 2:
23 foo();
24 break;
25 case 3:
26 break;
27 }
28 }
29
30 // Warm up foo and bar.
31 for (var i = 0; i < 10; i++) {
32 foo();
33 bar(3);
34 }
35
36 // Inline and discard foo's jitscript.
37 bar(1);
38
39 // Warp-compile bar
40 for (var i = 0; i < 50; i++) {
41 foo(); // ensure that foo has a new jitscript
42 bar(3);
43 }