| 1 |
// |jit-test| --ion-warmup-threshold=50 |
| 2 |
setJitCompilerOption("offthread-compilation.enable", 0); |
| 3 |
gcPreserveCode(); |
| 4 |
|
| 5 |
var testSet1 = [1, "", Symbol("a"), true]; |
| 6 |
var testSet2 = [1, "", Symbol("a"), true, { bar: 5 }]; |
| 7 |
|
| 8 |
Number.prototype.bar = 1; |
| 9 |
String.prototype.bar = 2; |
| 10 |
Symbol.prototype.bar = 3; |
| 11 |
Boolean.prototype.bar = 4; |
| 12 |
|
| 13 |
function assertEqIf(prev, curr, expected) { |
| 14 |
// Branch pruning absolutely want to get rid of the next branch |
| 15 |
// which causes bailouts, so we forbid inlining of this function. |
| 16 |
with({}){} |
| 17 |
if (prev) { |
| 18 |
assertEq(curr, expected); |
| 19 |
return false; |
| 20 |
} |
| 21 |
return true; |
| 22 |
} |
| 23 |
|
| 24 |
var f; |
| 25 |
var template = function (set) { |
| 26 |
var lastX = 0, x = 0, i = 0, y = 0; |
| 27 |
var cont = true; |
| 28 |
while (cont) { // OSR here. |
| 29 |
for (var i = 0; i < set.length; i++) { |
| 30 |
x = x + (inIon() ? 1 : 0); |
| 31 |
if (set[i].placeholder != set[(i + 1) % set.length].placeholder) |
| 32 |
y += 1; |
| 33 |
} |
| 34 |
|
| 35 |
// If we bailout in the inner loop, then x will have a smaller value |
| 36 |
// than the number of iterations. |
| 37 |
cont = assertEqIf(lastX > 0, x, set.length); |
| 38 |
if (inIon()) |
| 39 |
lastX = x; |
| 40 |
x = 0; |
| 41 |
} |
| 42 |
return y; |
| 43 |
} |
| 44 |
|
| 45 |
// Set 1, Non existing properties. |
| 46 |
f = eval(`(${template})`.replace(".placeholder", ".foo")); |
| 47 |
f(testSet1); |
| 48 |
|
| 49 |
// Set 2, Non existing properties. |
| 50 |
f = eval(`(${template})`.replace(".placeholder", ".foo")); |
| 51 |
f(testSet2); |
| 52 |
|
| 53 |
// Set 1, Existing properties. |
| 54 |
f = eval(`(${template})`.replace(".placeholder", ".bar")); |
| 55 |
f(testSet1); |
| 56 |
|
| 57 |
// Set 2, Existing properties. |
| 58 |
f = eval(`(${template})`.replace(".placeholder", ".bar")); |
| 59 |
f(testSet2); |