blob: 5ed18095c9f6ebef8cee649d6c0a00f4f5e8d2d0 [file] [log] [blame]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
var flag = false;
function recompile(regExp) {
if (flag)
regExp.compile("e");
}
noInline(recompile);
function target() {
var regExp = /test/;
recompile(regExp);
regExp.lastIndex = 0;
return regExp.exec("Hey");
}
noInline(target);
for (var i = 0; i < 1e4; ++i)
shouldBe(target(), null);
flag = true;
shouldBe(JSON.stringify(target()), `["e"]`);
for (var i = 0; i < 1e4; ++i)
shouldBe(JSON.stringify(target()), `["e"]`);