js/src/jit-test/tests/ion/bug860838-4.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 function DiagModule(stdlib, foreign) {
michael@0 2 "use asm";
michael@0 3
michael@0 4 var sqrt = stdlib.Math.sqrt;
michael@0 5 var test = foreign.test;
michael@0 6 var foo = foreign.foo;
michael@0 7
michael@0 8 function square(x) {
michael@0 9 x = x|0;
michael@0 10 return ((x|0)+(x|0))|0;
michael@0 11 }
michael@0 12
michael@0 13 function diag() {
michael@0 14 var x = 0.0;
michael@0 15 while(1) {
michael@0 16 test(1, x);
michael@0 17 x = x+1.0
michael@0 18 if (x > 15.0)
michael@0 19 return 0;
michael@0 20 }
michael@0 21 return 0;
michael@0 22 }
michael@0 23
michael@0 24 function diag_1() {
michael@0 25 foo();
michael@0 26 return 0;
michael@0 27 }
michael@0 28
michael@0 29
michael@0 30 return { diag: diag, diag_1:diag_1 };
michael@0 31 }
michael@0 32
michael@0 33 var foreign = {
michael@0 34 test:function(a,b) {
michael@0 35 print(a+":"+b)
michael@0 36 var c = [0.0];
michael@0 37 if (b > 10)
michael@0 38 return c[1];
michael@0 39 return c[0];
michael@0 40 },
michael@0 41 foo:function() {
michael@0 42 with({}) {};
michael@0 43 gc();
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 // make sure foreign is compiled
michael@0 48
michael@0 49 var fast = DiagModule(this, foreign); // produces AOT-compiled version
michael@0 50 print(fast.diag_1()); // 5
michael@0 51 gc()
michael@0 52 print(fast.diag()); // 5
michael@0 53
michael@0 54

mercurial