js/src/jit-test/tests/ion/bug908903.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 function f(x) {
michael@0 3 return x + 1;
michael@0 4 }
michael@0 5
michael@0 6 setJitCompilerOption("ion.usecount.trigger", 2);
michael@0 7 setJitCompilerOption("baseline.usecount.trigger", 0);
michael@0 8
michael@0 9 assertEq(f(1), 2); // usecount == 1 => eagerly compile with baseline.
michael@0 10 assertEq(f(0.5), 1.5); // usecount == 2 => normaly compile with ion.
michael@0 11 // invalidate for unexpect output.
michael@0 12
michael@0 13
michael@0 14 function normal() {
michael@0 15 setJitCompilerOption("ion.usecount.trigger", 8);
michael@0 16 setJitCompilerOption("baseline.usecount.trigger", 5);
michael@0 17 }
michael@0 18
michael@0 19 function eager() {
michael@0 20 setJitCompilerOption("ion.usecount.trigger", 0);
michael@0 21 }
michael@0 22
michael@0 23 function h(x) {
michael@0 24 return x + 1;
michael@0 25 }
michael@0 26
michael@0 27 function g(x) {
michael@0 28 normal();
michael@0 29 return h(x) + 1;
michael@0 30 }
michael@0 31
michael@0 32 normal();
michael@0 33 for (var i = 0; i < 10; i++) {
michael@0 34 eager();
michael@0 35 assertEq(g(i), i + 2);
michael@0 36 }
michael@0 37
michael@0 38
michael@0 39 // Check for wrong arguments.
michael@0 40 try {
michael@0 41 setJitCompilerOption("not.an.option", 51);
michael@0 42 assertEq(false, true);
michael@0 43 } catch (x) { }
michael@0 44
michael@0 45 try {
michael@0 46 var ion = { usecount: { trigger: null } };
michael@0 47 setJitCompilerOption(ion.usecount.trigger, 42);
michael@0 48 assertEq(false, true);
michael@0 49 } catch (x) { }
michael@0 50
michael@0 51 try {
michael@0 52 setJitCompilerOption("ion.usecount.trigger", "32");
michael@0 53 assertEq(false, true);
michael@0 54 } catch (x) { }

mercurial