blob: 2edfaf2502164ef96b1f37418662b0dfb4195503 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
function inner_env() {
let result = [];
let x = 0;
result.push(() => x);
var tmp = [1,2,3];
for (let y in tmp)
result.push(() => tmp[y])
for (let z = 4; z < 7; z++)
result.push(() => z)
return result;
}
function outer_env() {
let result = inner_env();
var tmp = [7,8,9];
for (let x in tmp)
result.push(() => tmp[x])
return result;
}
function check_result(result, expectedLen) {
assertEq(result.length, expectedLen);
for (var i = 0; i < expectedLen; ++i)
assertEq(result[i], i);
}
// Wipeout jitcode
bailout();
gc(); gc();
// Test lexical environment bailouts
for (var i = 0; i < 100; ++i)
{
bailAfter(i);
var result = inner_env().map(fn => fn());
check_result(result, 7);
}
// Test inlined lexical environment bailouts
for (var i = 0; i < 100; ++i)
{
bailAfter(i);
var result = outer_env().map(fn => fn());
check_result(result, 10);
}
|