Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | enableOsiPointRegisterChecks(); |
michael@0 | 2 | |
michael@0 | 3 | function DiagModule(stdlib, foreign) { |
michael@0 | 4 | "use asm"; |
michael@0 | 5 | |
michael@0 | 6 | var sqrt = stdlib.Math.sqrt; |
michael@0 | 7 | var test = foreign.test; |
michael@0 | 8 | |
michael@0 | 9 | function square(x) { |
michael@0 | 10 | x = x|0; |
michael@0 | 11 | return ((x|0)+(x|0))|0; |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | function diag() { |
michael@0 | 15 | var x = 0.0; |
michael@0 | 16 | while(1) { |
michael@0 | 17 | test(1, x); |
michael@0 | 18 | x = x+1.0 |
michael@0 | 19 | if (x > 15.0) |
michael@0 | 20 | return 0; |
michael@0 | 21 | } |
michael@0 | 22 | return 0; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function diag_1() { |
michael@0 | 26 | test(); |
michael@0 | 27 | return 0; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | |
michael@0 | 31 | return { diag: diag, diag_1:diag_1 }; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | var foreign = { |
michael@0 | 35 | test:function(a,b) { |
michael@0 | 36 | print(a+":"+b) |
michael@0 | 37 | var c = [0.0]; |
michael@0 | 38 | if (b > 10) |
michael@0 | 39 | return c[1]; |
michael@0 | 40 | return c[0]; |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | // make sure foreign is compiled |
michael@0 | 45 | |
michael@0 | 46 | var fast = DiagModule(this, foreign); // produces AOT-compiled version |
michael@0 | 47 | print(fast.diag()); // 5 |
michael@0 | 48 | gc() |
michael@0 | 49 | print(fast.diag()); // 5 |
michael@0 | 50 | |
michael@0 | 51 |