michael@0: michael@0: function f(x) { michael@0: return x + 1; michael@0: } michael@0: michael@0: setJitCompilerOption("ion.usecount.trigger", 2); michael@0: setJitCompilerOption("baseline.usecount.trigger", 0); michael@0: michael@0: assertEq(f(1), 2); // usecount == 1 => eagerly compile with baseline. michael@0: assertEq(f(0.5), 1.5); // usecount == 2 => normaly compile with ion. michael@0: // invalidate for unexpect output. michael@0: michael@0: michael@0: function normal() { michael@0: setJitCompilerOption("ion.usecount.trigger", 8); michael@0: setJitCompilerOption("baseline.usecount.trigger", 5); michael@0: } michael@0: michael@0: function eager() { michael@0: setJitCompilerOption("ion.usecount.trigger", 0); michael@0: } michael@0: michael@0: function h(x) { michael@0: return x + 1; michael@0: } michael@0: michael@0: function g(x) { michael@0: normal(); michael@0: return h(x) + 1; michael@0: } michael@0: michael@0: normal(); michael@0: for (var i = 0; i < 10; i++) { michael@0: eager(); michael@0: assertEq(g(i), i + 2); michael@0: } michael@0: michael@0: michael@0: // Check for wrong arguments. michael@0: try { michael@0: setJitCompilerOption("not.an.option", 51); michael@0: assertEq(false, true); michael@0: } catch (x) { } michael@0: michael@0: try { michael@0: var ion = { usecount: { trigger: null } }; michael@0: setJitCompilerOption(ion.usecount.trigger, 42); michael@0: assertEq(false, true); michael@0: } catch (x) { } michael@0: michael@0: try { michael@0: setJitCompilerOption("ion.usecount.trigger", "32"); michael@0: assertEq(false, true); michael@0: } catch (x) { }