summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/asm.js/testX86ByteStore.js
blob: 05556a5d9a70374a09c5ccca547331a1b320cc30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
load(libdir + "asm.js");

var body =
'   "use asm";\
    var i8=new global.Int8Array(buffer);\
    function g(i,j,k) {\
        i=i|0;\
        j=j|0;\
        k=k|0;\
        var a=0,b=0,c=0,d=0,e=0,f=0;\
        a=(i+j)|0;\
        b=(k+j)|0;\
        c=(i+k)|0;\
        b=(a+b)|0;\
        d=(b+c+i+j)|0;\
        e=(a+j+c)|0;\
        f=(a+i+k)|0;\
        i8[i] = f;\
        return (a+b+c+d+e+f)|0;\
    }\
    return g;';

var buf=new ArrayBuffer(BUF_MIN);
var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf);
assertEq(g(1,2,3), 46);
assertEq(new Int8Array(buf)[1], 7);

var body =
'   "use asm";\
    var i8=new global.Int8Array(buffer);\
    function g(i,j,k) {\
        i=i|0;\
        j=j|0;\
        k=k|0;\
        var a=0,b=0,c=0,d=0,e=0,f=0;\
        a=(i+j)|0;\
        b=(k+j)|0;\
        c=(i+k)|0;\
        b=(a+b)|0;\
        d=(b+c+i+j)|0;\
        e=(a+j+c)|0;\
        f=(a+i+k)|0;\
        i8[i] = e;\
        return (a+b+c+d+e+f)|0;\
    }\
    return g;';

var buf=new ArrayBuffer(BUF_MIN);
var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf);
assertEq(g(1,2,3), 46);
assertEq(new Int8Array(buf)[1], 9);

var body =
'   "use asm";\
    var i8=new global.Int8Array(buffer);\
    function g(i,j,k) {\
        i=i|0;\
        j=j|0;\
        k=k|0;\
        var a=0,b=0,c=0,d=0,e=0,f=0,g=0;\
        a=(i+j)|0;\
        b=(k+j)|0;\
        c=(i+k)|0;\
        b=(a+b)|0;\
        d=(b+c+i+j)|0;\
        e=(a+j+c)|0;\
        f=(a+i+k)|0;\
        g=(f+j+b)|0;\
        i8[i] = g;\
        return (a+b+c+d+e+f+g)|0;\
    }\
    return g;';

var buf=new ArrayBuffer(BUF_MIN);
var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf);
assertEq(g(1,2,3), 63);
assertEq(new Int8Array(buf)[1], 17);