1 // This program attempts to relatively rare OSR exits due to mispredictions
2 // on the value of a local variable, where the basic block in which the local
3 // is assigned the offending value is different than the basic block in which
4 // the misspeculation occurs. The occurrence of the value that causes
5 // speculation failure is rare enough that the old JIT's value profiler is
6 // unlikely to catch it, but common enough that recompilation will be
9 // If the local was defined and used in the same basic block, then OSR exit
10 // would update the value profile associated with the assignment, and
11 // everything would be fine. But in this case OSR exit will see that the value
12 // comes from a GetLocal. If our mechanisms for updating the type predictions
13 // of local variables whose live ranges span basic blocks work, then it will
14 // only take one recompile for the optimizing compiler to converge to an
15 // optimal version of this code, where the variable is known to be one of two
16 // types and we optimize for both.
18 // TL;DR: This tests that OSR exit updates type predictions on local variables.
22 // Assign to the value on one of two basic blocks.
30 for (var i = 0; i < 10000; ++i)
35 var array = [1,2,3,4,5,6,7,8,9,10];
39 for (var i = 0; i < 300; ++i) {
41 if (i <= 100 || (i%4))
42 v = {f:{h:v}, g:{h:v+1}, h:array};
44 v = {f:(i%3)==0, g:((i+1)%3)==0, h:array};
45 result += foo(v,(i%2)==0);
48 if (result != 16500033)
49 throw "Bad result: " + result;