Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | load(libdir + "asm.js"); |
michael@0 | 2 | |
michael@0 | 3 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[0>>2] = 4.0; return i32[0>>2]|0; } return f'); |
michael@0 | 4 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[0>>2] = 4; return +f32[0>>2]; } return f'); |
michael@0 | 5 | |
michael@0 | 6 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { var x=0,y=0; return i8[x+y]|0 } return f'); |
michael@0 | 7 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { var x=0,y=0; return u8[x+y]|0 } return f'); |
michael@0 | 8 | |
michael@0 | 9 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>0]|0 }; return f'); |
michael@0 | 10 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>1]|0 }; return f'); |
michael@0 | 11 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>4]|0 }; return f'); |
michael@0 | 12 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0]|0 }; return f'), this, null, new ArrayBuffer(4096))(), 0); |
michael@0 | 13 | |
michael@0 | 14 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>2]|0; return i|0}; return f'); |
michael@0 | 15 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 16 | assertEq(f(0), 0); |
michael@0 | 17 | |
michael@0 | 18 | setCachingEnabled(true); |
michael@0 | 19 | |
michael@0 | 20 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i8[0]|0}; return f'); |
michael@0 | 21 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 22 | assertEq(f(0),0); |
michael@0 | 23 | assertEq(f(0x7f),0x7f); |
michael@0 | 24 | assertEq(f(0xff),-1); |
michael@0 | 25 | assertEq(f(0x100),0); |
michael@0 | 26 | |
michael@0 | 27 | setCachingEnabled(false); |
michael@0 | 28 | |
michael@0 | 29 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return u8[0]|0}; return f'); |
michael@0 | 30 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 31 | assertEq(f(0),0); |
michael@0 | 32 | assertEq(f(0x7f),0x7f); |
michael@0 | 33 | assertEq(f(0xff),0xff); |
michael@0 | 34 | assertEq(f(0x100),0); |
michael@0 | 35 | |
michael@0 | 36 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i16[0]|0}; return f'); |
michael@0 | 37 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 38 | assertEq(f(0),0); |
michael@0 | 39 | assertEq(f(0x7fff),0x7fff); |
michael@0 | 40 | assertEq(f(0xffff),-1); |
michael@0 | 41 | assertEq(f(0x10000),0); |
michael@0 | 42 | |
michael@0 | 43 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return u16[0]|0}; return f'); |
michael@0 | 44 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 45 | assertEq(f(0),0); |
michael@0 | 46 | assertEq(f(0x7fff),0x7fff); |
michael@0 | 47 | assertEq(f(0xffff),0xffff); |
michael@0 | 48 | assertEq(f(0x10000),0); |
michael@0 | 49 | |
michael@0 | 50 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i32[0]|0}; return f'); |
michael@0 | 51 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 52 | assertEq(f(0),0); |
michael@0 | 53 | assertEq(f(0x7fffffff),0x7fffffff); |
michael@0 | 54 | assertEq(f(0xffffffff),-1); |
michael@0 | 55 | assertEq(f(0x100000000),0); |
michael@0 | 56 | |
michael@0 | 57 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return u32[0]|0}; return f'); |
michael@0 | 58 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 59 | assertEq(f(0),0); |
michael@0 | 60 | assertEq(f(0x7fffffff),0x7fffffff); |
michael@0 | 61 | assertEq(f(0xffffffff),-1); |
michael@0 | 62 | assertEq(f(0x100000000),0); |
michael@0 | 63 | |
michael@0 | 64 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i8[0]|0}; return f'); |
michael@0 | 65 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 66 | assertEq(f(0),0); |
michael@0 | 67 | assertEq(f(0x7f),0x7f); |
michael@0 | 68 | assertEq(f(0xff),-1); |
michael@0 | 69 | assertEq(f(0x100),0); |
michael@0 | 70 | |
michael@0 | 71 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return u8[0]|0}; return f'); |
michael@0 | 72 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 73 | assertEq(f(0),0); |
michael@0 | 74 | assertEq(f(0x7f),0x7f); |
michael@0 | 75 | assertEq(f(0xff),0xff); |
michael@0 | 76 | assertEq(f(0x100),0); |
michael@0 | 77 | |
michael@0 | 78 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i8[0] = i; return i8[0]|0}; return f'); |
michael@0 | 79 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 80 | assertEq(f(0),0); |
michael@0 | 81 | assertEq(f(0x7f),0x7f); |
michael@0 | 82 | assertEq(f(0xff),-1); |
michael@0 | 83 | assertEq(f(0x100),0); |
michael@0 | 84 | |
michael@0 | 85 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i8[0] = i; return u8[0]|0}; return f'); |
michael@0 | 86 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 87 | assertEq(f(0),0); |
michael@0 | 88 | assertEq(f(0x7f),0x7f); |
michael@0 | 89 | assertEq(f(0xff),0xff); |
michael@0 | 90 | assertEq(f(0x100),0); |
michael@0 | 91 | |
michael@0 | 92 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return (~~+f64[i>>3])|0}; return f'); |
michael@0 | 93 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 94 | assertEq(f(0, 1.3), 1); |
michael@0 | 95 | assertEq(f(4088, 2.5), 2); |
michael@0 | 96 | assertEq(f(4096, 3.8), 0); |
michael@0 | 97 | |
michael@0 | 98 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return (~~f64[i>>3])|0}; return f'); |
michael@0 | 99 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 100 | assertEq(f(0, 1.3), 1); |
michael@0 | 101 | assertEq(f(4088, 2.5), 2); |
michael@0 | 102 | assertEq(f(4096, 3.8), 0); |
michael@0 | 103 | |
michael@0 | 104 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return +f64[i>>3]}; return f'); |
michael@0 | 105 | var f = asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 106 | assertEq(f(0, 1.3), 1.3); |
michael@0 | 107 | assertEq(f(4088, 2.5), 2.5); |
michael@0 | 108 | assertEq(f(4096, 3.8), NaN); |
michael@0 | 109 | |
michael@0 | 110 | var i32 = new Int32Array(4096); |
michael@0 | 111 | i32[0] = 42; |
michael@0 | 112 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = i32[0] }; return f'), this, null, i32.buffer)(); |
michael@0 | 113 | assertEq(i32[1], 42); |
michael@0 | 114 | |
michael@0 | 115 | var f64 = new Float64Array(4096); |
michael@0 | 116 | f64[0] = 42; |
michael@0 | 117 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = f64[0] }; return f'), this, null, f64.buffer)(); |
michael@0 | 118 | assertEq(f64[1], 42); |
michael@0 | 119 | |
michael@0 | 120 | var i32 = new Int32Array(4096/4); |
michael@0 | 121 | i32[0] = 13; |
michael@0 | 122 | i32[1] = 0xfffeeee; |
michael@0 | 123 | var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[((i<<2)+1)>>2]|0 }; return f'), this, null, i32.buffer); |
michael@0 | 124 | assertEq(f(0), 13); |
michael@0 | 125 | assertEq(f(1), 0xfffeeee); |
michael@0 | 126 | var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[((i<<2)+2)>>2]|0 }; return f'), this, null, i32.buffer); |
michael@0 | 127 | assertEq(f(0), 13); |
michael@0 | 128 | assertEq(f(1), 0xfffeeee); |
michael@0 | 129 | var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[(i<<1)>>2]|0 }; return f'), this, null, i32.buffer); |
michael@0 | 130 | assertEq(f(0), 13); |
michael@0 | 131 | assertEq(f(1), 13); |
michael@0 | 132 | assertEq(f(2), 0xfffeeee); |
michael@0 | 133 | assertEq(f(3), 0xfffeeee); |
michael@0 | 134 | |
michael@0 | 135 | var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[(i<<2)>>2]|0 }; return f'), this, null, i32.buffer); |
michael@0 | 136 | assertEq(f(0), 13); |
michael@0 | 137 | assertEq(f(1), 0xfffeeee); |
michael@0 | 138 | |
michael@0 | 139 | var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[((i<<2)+4)>>2]|0 }; return f'), this, null, i32.buffer); |
michael@0 | 140 | assertEq(f(0), 0xfffeeee); |
michael@0 | 141 | |
michael@0 | 142 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[7&0xffff] = 41 } return f'), this, null, BUF_64KB)(); |
michael@0 | 143 | assertEq(new Uint8Array(BUF_64KB)[7], 41); |
michael@0 | 144 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[7&0xffff] = -41 } return f'), this, null, BUF_64KB)(); |
michael@0 | 145 | assertEq(new Int8Array(BUF_64KB)[7], -41); |
michael@0 | 146 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[(6&0xffff)>>1] = 0xabc } return f'), this, null, BUF_64KB)(); |
michael@0 | 147 | assertEq(new Uint16Array(BUF_64KB)[3], 0xabc); |
michael@0 | 148 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[(6&0xffff)>>1] = -0xabc } return f'), this, null, BUF_64KB)(); |
michael@0 | 149 | assertEq(new Int16Array(BUF_64KB)[3], -0xabc); |
michael@0 | 150 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[(4&0xffff)>>2] = 0xabcde } return f'), this, null, BUF_64KB)(); |
michael@0 | 151 | assertEq(new Uint32Array(BUF_64KB)[1], 0xabcde); |
michael@0 | 152 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[(4&0xffff)>>2] = -0xabcde } return f'), this, null, BUF_64KB)(); |
michael@0 | 153 | assertEq(new Int32Array(BUF_64KB)[1], -0xabcde); |
michael@0 | 154 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[(4&0xffff)>>2] = 1.0 } return f'), this, null, BUF_64KB)(); |
michael@0 | 155 | assertEq(new Float32Array(BUF_64KB)[1], 1.0); |
michael@0 | 156 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[(8&0xffff)>>3] = 1.3 } return f'), this, null, BUF_64KB)(); |
michael@0 | 157 | assertEq(new Float64Array(BUF_64KB)[1], 1.3); |
michael@0 | 158 | |
michael@0 | 159 | new Float32Array(BUF_64KB)[1] = 1.0; |
michael@0 | 160 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(4&0xffff)>>2] } return f'), this, null, BUF_64KB)(), 1.0); |
michael@0 | 161 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'var toFloat32 = glob.Math.fround; function f() { return toFloat32(f32[(4&0xffff)>>2]) } return f'), this, null, BUF_64KB)(), 1.0); |
michael@0 | 162 | new Float64Array(BUF_64KB)[1] = 1.3; |
michael@0 | 163 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8&0xffff)>>3] } return f'), this, null, BUF_64KB)(), 1.3); |
michael@0 | 164 | |
michael@0 | 165 | asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[255]; u8[i] } return f'); |
michael@0 | 166 | asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[i&0xff]; u8[255] } return f'); |
michael@0 | 167 | asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[63]; u32[i>>2] } return f'); |
michael@0 | 168 | asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[i>>2]; u32[63] } return f'); |
michael@0 | 169 | |
michael@0 | 170 | var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[64] } return f'); |
michael@0 | 171 | asmLink(code, this, null, new ArrayBuffer(4096)); |
michael@0 | 172 | |
michael@0 | 173 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[12] = i } return f'), this, null, BUF_64KB)(11); |
michael@0 | 174 | assertEq(new Int32Array(BUF_64KB)[12], 11); |
michael@0 | 175 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[12]|0 } return f'), this, null, BUF_64KB)(), 11); |
michael@0 | 176 | new Float64Array(BUF_64KB)[0] = 3.5; |
michael@0 | 177 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +-f64[0] } return f'), this, null, BUF_64KB)(), -3.5); |
michael@0 | 178 | |
michael@0 | 179 | // Test constant loads. |
michael@0 | 180 | var buf = new ArrayBuffer(8192); |
michael@0 | 181 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[1] = -1 } return f'), this, null, buf)(); |
michael@0 | 182 | assertEq(new Uint8Array(buf)[0], 0); |
michael@0 | 183 | assertEq(new Uint8Array(buf)[1], 255); |
michael@0 | 184 | assertEq(new Uint8Array(buf)[2], 0); |
michael@0 | 185 | var buf = new ArrayBuffer(8192); |
michael@0 | 186 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[4095] = -1 } return f'), this, null, buf)(); |
michael@0 | 187 | assertEq(new Uint8Array(buf)[4094], 0); |
michael@0 | 188 | assertEq(new Uint8Array(buf)[4095], 255); |
michael@0 | 189 | assertEq(new Uint8Array(buf)[4096], 0); |
michael@0 | 190 | var buf = new ArrayBuffer(8192); |
michael@0 | 191 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[4096] = -1 } return f'), this, null, buf)(); |
michael@0 | 192 | assertEq(new Uint8Array(buf)[4095], 0); |
michael@0 | 193 | assertEq(new Uint8Array(buf)[4096], 255); |
michael@0 | 194 | assertEq(new Uint8Array(buf)[4097], 0); |
michael@0 | 195 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[8192] = -1 } return f'), this, null, buf); |
michael@0 | 196 | var buf = new ArrayBuffer(262144); |
michael@0 | 197 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[258048] = -1 } return f'), this, null, buf)(); |
michael@0 | 198 | assertEq(new Uint8Array(buf)[258047], 0); |
michael@0 | 199 | assertEq(new Uint8Array(buf)[258048], 255); |
michael@0 | 200 | assertEq(new Uint8Array(buf)[258049], 0); |
michael@0 | 201 | |
michael@0 | 202 | var buf = new ArrayBuffer(8192); |
michael@0 | 203 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[1] = -1 } return f'), this, null, buf)(); |
michael@0 | 204 | assertEq(new Int8Array(buf)[0], 0); |
michael@0 | 205 | assertEq(new Int8Array(buf)[1], -1); |
michael@0 | 206 | assertEq(new Int8Array(buf)[2], 0); |
michael@0 | 207 | var buf = new ArrayBuffer(8192); |
michael@0 | 208 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[4095] = -1 } return f'), this, null, buf)(); |
michael@0 | 209 | assertEq(new Int8Array(buf)[4094], 0); |
michael@0 | 210 | assertEq(new Int8Array(buf)[4095], -1); |
michael@0 | 211 | assertEq(new Int8Array(buf)[4096], 0); |
michael@0 | 212 | var buf = new ArrayBuffer(8192); |
michael@0 | 213 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[4096] = -1 } return f'), this, null, buf)(); |
michael@0 | 214 | assertEq(new Int8Array(buf)[4095], 0); |
michael@0 | 215 | assertEq(new Int8Array(buf)[4096], -1); |
michael@0 | 216 | assertEq(new Int8Array(buf)[4097], 0); |
michael@0 | 217 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[8192] = -1 } return f'), this, null, buf); |
michael@0 | 218 | var buf = new ArrayBuffer(262144); |
michael@0 | 219 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[258048] = -1 } return f'), this, null, buf)(); |
michael@0 | 220 | assertEq(new Int8Array(buf)[258047], 0); |
michael@0 | 221 | assertEq(new Int8Array(buf)[258048], -1); |
michael@0 | 222 | assertEq(new Int8Array(buf)[258049], 0); |
michael@0 | 223 | |
michael@0 | 224 | var buf = new ArrayBuffer(8192); |
michael@0 | 225 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[1] = -1 } return f'), this, null, buf)(); |
michael@0 | 226 | assertEq(new Uint16Array(buf)[0], 0); |
michael@0 | 227 | assertEq(new Uint16Array(buf)[1], 65535); |
michael@0 | 228 | assertEq(new Uint16Array(buf)[2], 0); |
michael@0 | 229 | var buf = new ArrayBuffer(8192); |
michael@0 | 230 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2047] = -1 } return f'), this, null, buf)(); |
michael@0 | 231 | assertEq(new Uint16Array(buf)[2046], 0); |
michael@0 | 232 | assertEq(new Uint16Array(buf)[2047], 65535); |
michael@0 | 233 | assertEq(new Uint16Array(buf)[2048], 0); |
michael@0 | 234 | var buf = new ArrayBuffer(8192); |
michael@0 | 235 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2048] = -1 } return f'), this, null, buf)(); |
michael@0 | 236 | assertEq(new Uint16Array(buf)[2047], 0); |
michael@0 | 237 | assertEq(new Uint16Array(buf)[2048], 65535); |
michael@0 | 238 | assertEq(new Uint16Array(buf)[2049], 0); |
michael@0 | 239 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[4096] = -1 } return f'), this, null, buf); |
michael@0 | 240 | var buf = new ArrayBuffer(262144); |
michael@0 | 241 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[126976] = -1 } return f'), this, null, buf)(); |
michael@0 | 242 | assertEq(new Uint16Array(buf)[126975], 0); |
michael@0 | 243 | assertEq(new Uint16Array(buf)[126976], 65535); |
michael@0 | 244 | assertEq(new Uint16Array(buf)[126977], 0); |
michael@0 | 245 | |
michael@0 | 246 | var buf = new ArrayBuffer(8192); |
michael@0 | 247 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[1] = -1 } return f'), this, null, buf)(); |
michael@0 | 248 | assertEq(new Int16Array(buf)[0], 0); |
michael@0 | 249 | assertEq(new Int16Array(buf)[1], -1); |
michael@0 | 250 | assertEq(new Int16Array(buf)[2], 0); |
michael@0 | 251 | var buf = new ArrayBuffer(8192); |
michael@0 | 252 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2047] = -1 } return f'), this, null, buf)(); |
michael@0 | 253 | assertEq(new Int16Array(buf)[2046], 0); |
michael@0 | 254 | assertEq(new Int16Array(buf)[2047], -1); |
michael@0 | 255 | assertEq(new Int16Array(buf)[2048], 0); |
michael@0 | 256 | var buf = new ArrayBuffer(8192); |
michael@0 | 257 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2048] = -1 } return f'), this, null, buf)(); |
michael@0 | 258 | assertEq(new Int16Array(buf)[2047], 0); |
michael@0 | 259 | assertEq(new Int16Array(buf)[2048], -1); |
michael@0 | 260 | assertEq(new Int16Array(buf)[2049], 0); |
michael@0 | 261 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[4096] = -1 } return f'), this, null, buf); |
michael@0 | 262 | var buf = new ArrayBuffer(262144); |
michael@0 | 263 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[126976] = -1 } return f'), this, null, buf)(); |
michael@0 | 264 | assertEq(new Int16Array(buf)[126975], 0); |
michael@0 | 265 | assertEq(new Int16Array(buf)[126976], -1); |
michael@0 | 266 | assertEq(new Int16Array(buf)[126977], 0); |
michael@0 | 267 | |
michael@0 | 268 | var buf = new ArrayBuffer(8192); |
michael@0 | 269 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1] = -1 } return f'), this, null, buf)(); |
michael@0 | 270 | assertEq(new Uint32Array(buf)[0], 0); |
michael@0 | 271 | assertEq(new Uint32Array(buf)[1], 4294967295); |
michael@0 | 272 | assertEq(new Uint32Array(buf)[2], 0); |
michael@0 | 273 | var buf = new ArrayBuffer(8192); |
michael@0 | 274 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1023] = -1 } return f'), this, null, buf)(); |
michael@0 | 275 | assertEq(new Uint32Array(buf)[1022], 0); |
michael@0 | 276 | assertEq(new Uint32Array(buf)[1023], 4294967295); |
michael@0 | 277 | assertEq(new Uint32Array(buf)[1024], 0); |
michael@0 | 278 | var buf = new ArrayBuffer(8192); |
michael@0 | 279 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1024] = -1 } return f'), this, null, buf)(); |
michael@0 | 280 | assertEq(new Uint32Array(buf)[1023], 0); |
michael@0 | 281 | assertEq(new Uint32Array(buf)[1024], 4294967295); |
michael@0 | 282 | assertEq(new Uint32Array(buf)[1025], 0); |
michael@0 | 283 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[2048] = -1 } return f'), this, null, buf); |
michael@0 | 284 | var buf = new ArrayBuffer(262144); |
michael@0 | 285 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[61440] = -1 } return f'), this, null, buf)(); |
michael@0 | 286 | assertEq(new Uint32Array(buf)[61439], 0); |
michael@0 | 287 | assertEq(new Uint32Array(buf)[61440], 4294967295); |
michael@0 | 288 | assertEq(new Uint32Array(buf)[61441], 0); |
michael@0 | 289 | |
michael@0 | 290 | var buf = new ArrayBuffer(8192); |
michael@0 | 291 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = -1 } return f'), this, null, buf)(); |
michael@0 | 292 | assertEq(new Int32Array(buf)[0], 0); |
michael@0 | 293 | assertEq(new Int32Array(buf)[1], -1); |
michael@0 | 294 | assertEq(new Int32Array(buf)[2], 0); |
michael@0 | 295 | var buf = new ArrayBuffer(8192); |
michael@0 | 296 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1023] = -1 } return f'), this, null, buf)(); |
michael@0 | 297 | assertEq(new Int32Array(buf)[1022], 0); |
michael@0 | 298 | assertEq(new Int32Array(buf)[1023], -1); |
michael@0 | 299 | assertEq(new Int32Array(buf)[124], 0); |
michael@0 | 300 | var buf = new ArrayBuffer(8192); |
michael@0 | 301 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1024] = -1 } return f'), this, null, buf)(); |
michael@0 | 302 | assertEq(new Int32Array(buf)[1023], 0); |
michael@0 | 303 | assertEq(new Int32Array(buf)[1024], -1); |
michael@0 | 304 | assertEq(new Int32Array(buf)[1025], 0); |
michael@0 | 305 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[2048] = -1 } return f'), this, null, buf); |
michael@0 | 306 | var buf = new ArrayBuffer(262144); |
michael@0 | 307 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[61440] = -1 } return f'), this, null, buf)(); |
michael@0 | 308 | assertEq(new Int32Array(buf)[61439], 0); |
michael@0 | 309 | assertEq(new Int32Array(buf)[61440], -1); |
michael@0 | 310 | assertEq(new Int32Array(buf)[61441], 0); |
michael@0 | 311 | |
michael@0 | 312 | var buf = new ArrayBuffer(8192); |
michael@0 | 313 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 314 | assertEq(new Int32Array(buf)[0], 0); |
michael@0 | 315 | assertEq(new Float32Array(buf)[1], -1.0); |
michael@0 | 316 | assertEq(new Int32Array(buf)[2], 0); |
michael@0 | 317 | var buf = new ArrayBuffer(8192); |
michael@0 | 318 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1023] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 319 | assertEq(new Int32Array(buf)[1022], 0); |
michael@0 | 320 | assertEq(new Float32Array(buf)[1023], -1.0); |
michael@0 | 321 | assertEq(new Int32Array(buf)[124], 0); |
michael@0 | 322 | var buf = new ArrayBuffer(8192); |
michael@0 | 323 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1024] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 324 | assertEq(new Int32Array(buf)[1023], 0); |
michael@0 | 325 | assertEq(new Float32Array(buf)[1024], -1.0); |
michael@0 | 326 | assertEq(new Int32Array(buf)[1025], 0); |
michael@0 | 327 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[2048] = -1.0 } return f'), this, null, buf); |
michael@0 | 328 | var buf = new ArrayBuffer(262144); |
michael@0 | 329 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[61440] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 330 | assertEq(new Float32Array(buf)[61439], 0.0); |
michael@0 | 331 | assertEq(new Float32Array(buf)[61440], -1.0); |
michael@0 | 332 | assertEq(new Float32Array(buf)[61441], 0.0); |
michael@0 | 333 | |
michael@0 | 334 | var buf = new ArrayBuffer(8192); |
michael@0 | 335 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 336 | assertEq(new Float64Array(buf)[0], 0.0); |
michael@0 | 337 | assertEq(new Float64Array(buf)[1], -1.0); |
michael@0 | 338 | assertEq(new Float64Array(buf)[2], 0.0); |
michael@0 | 339 | var buf = new ArrayBuffer(8192); |
michael@0 | 340 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[511] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 341 | assertEq(new Float64Array(buf)[510], 0.0); |
michael@0 | 342 | assertEq(new Float64Array(buf)[511], -1.0); |
michael@0 | 343 | assertEq(new Float64Array(buf)[512], 0.0); |
michael@0 | 344 | var buf = new ArrayBuffer(8192); |
michael@0 | 345 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[512] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 346 | assertEq(new Float64Array(buf)[511], 0.0); |
michael@0 | 347 | assertEq(new Float64Array(buf)[512], -1.0); |
michael@0 | 348 | assertEq(new Float64Array(buf)[513], 0.0); |
michael@0 | 349 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1024] = -1.0 } return f'), this, null, buf); |
michael@0 | 350 | var buf = new ArrayBuffer(262144); |
michael@0 | 351 | asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[28672] = -1.0 } return f'), this, null, buf)(); |
michael@0 | 352 | assertEq(new Float64Array(buf)[28671], 0.0); |
michael@0 | 353 | assertEq(new Float64Array(buf)[28672], -1.0); |
michael@0 | 354 | assertEq(new Float64Array(buf)[28673], 0.0); |
michael@0 | 355 | |
michael@0 | 356 | |
michael@0 | 357 | var buf = new ArrayBuffer(8192); |
michael@0 | 358 | new Uint8Array(buf)[1] = -1; |
michael@0 | 359 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[1]|0; } return f'), this, null, buf)(),255); |
michael@0 | 360 | new Int8Array(buf)[1] = -1; |
michael@0 | 361 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[1]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 362 | var buf = new ArrayBuffer(262144); |
michael@0 | 363 | new Uint8Array(buf)[126976] = -1; |
michael@0 | 364 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[126976]|0; } return f'), this, null, buf)(),255); |
michael@0 | 365 | new Int8Array(buf)[126976] = -1; |
michael@0 | 366 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[126976]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 367 | |
michael@0 | 368 | var buf = new ArrayBuffer(8192); |
michael@0 | 369 | new Uint16Array(buf)[1] = -1; |
michael@0 | 370 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[1]|0; } return f'), this, null, buf)(),65535); |
michael@0 | 371 | new Int16Array(buf)[1] = -1; |
michael@0 | 372 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[1]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 373 | var buf = new ArrayBuffer(262144); |
michael@0 | 374 | new Uint16Array(buf)[126976] = -1; |
michael@0 | 375 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[126976]|0; } return f'), this, null, buf)(),65535); |
michael@0 | 376 | new Int16Array(buf)[126976] = -1; |
michael@0 | 377 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[126976]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 378 | |
michael@0 | 379 | var buf = new ArrayBuffer(8192); |
michael@0 | 380 | new Uint32Array(buf)[1] = -1; |
michael@0 | 381 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[1]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 382 | new Int32Array(buf)[1] = -1; |
michael@0 | 383 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[1]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 384 | var buf = new ArrayBuffer(262144); |
michael@0 | 385 | new Int32Array(buf)[61440] = -1; |
michael@0 | 386 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[61440]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 387 | |
michael@0 | 388 | var buf = new ArrayBuffer(8192); |
michael@0 | 389 | new Float32Array(buf)[1] = -1.0; |
michael@0 | 390 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 391 | new Float32Array(buf)[1023] = -1.0; |
michael@0 | 392 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1023]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 393 | new Float32Array(buf)[1024] = -1.0; |
michael@0 | 394 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1024]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 395 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[2048]; } return f'), this, null, buf); |
michael@0 | 396 | var buf = new ArrayBuffer(262144); |
michael@0 | 397 | new Float32Array(buf)[61440] = -1.0; |
michael@0 | 398 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[61440]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 399 | |
michael@0 | 400 | var buf = new ArrayBuffer(8192); |
michael@0 | 401 | new Float64Array(buf)[1] = -1.0; |
michael@0 | 402 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[1]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 403 | new Float64Array(buf)[511] = -1.0; |
michael@0 | 404 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[511]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 405 | new Float64Array(buf)[512] = -1.0; |
michael@0 | 406 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[512]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 407 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[1024]; } return f'), this, null, buf); |
michael@0 | 408 | var buf = new ArrayBuffer(262144); |
michael@0 | 409 | new Float64Array(buf)[28672] = -1.0; |
michael@0 | 410 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[28672]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 411 | |
michael@0 | 412 | // Test bitwise-and optimizations. |
michael@0 | 413 | var buf = new ArrayBuffer(8192); |
michael@0 | 414 | new Uint8Array(buf)[8191] = -1; |
michael@0 | 415 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[8191&8191]|0; } return f'), this, null, buf)(),255); |
michael@0 | 416 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[(8191&8191)>>0]|0; } return f'), this, null, buf)(),255); |
michael@0 | 417 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[8192&8191] = -1; u8[0] = 0; return u8[8192&8191]|0; } return f'), this, null, buf)(),0); |
michael@0 | 418 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[(8192&8191)>>0] = -1; u8[0] = 0; return u8[(8192&8191)>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 419 | new Int8Array(buf)[8191] = -1; |
michael@0 | 420 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[8191&8191]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 421 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[(8191&8191)>>0]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 422 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[8192&8191] = -1; i8[0] = 0; return i8[8192&8191]|0; } return f'), this, null, buf)(),0); |
michael@0 | 423 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[(8192&8191)>>0] = -1; i8[0] = 0; return i8[(8192&8191)>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 424 | var buf = new ArrayBuffer(8192); |
michael@0 | 425 | new Uint16Array(buf)[4095] = -1; |
michael@0 | 426 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[(8190&8191)>>1]|0; } return f'), this, null, buf)(),65535); |
michael@0 | 427 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[(8191&8191)>>1]|0; } return f'), this, null, buf)(),65535); |
michael@0 | 428 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[(8192&8191)>>1] = -1; u16[0] = 0; return u16[(8192&8191)>>1]|0; } return f'), this, null, buf)(),0); |
michael@0 | 429 | new Int16Array(buf)[4095] = -1; |
michael@0 | 430 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[(8190&8191)>>1]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 431 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[(8191&8191)>>1]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 432 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[(8192&8191)>>1] = -1; i16[0] = 0; return i16[(8192&8191)>>1]|0; } return f'), this, null, buf)(),0); |
michael@0 | 433 | |
michael@0 | 434 | var buf = new ArrayBuffer(8192); |
michael@0 | 435 | new Uint32Array(buf)[2047] = -1; |
michael@0 | 436 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(8188&8191)>>2]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 437 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(8191&8191)>>2]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 438 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[(8192&8191)>>2] = -1; u32[0] = 0; return u32[(8192&8191)>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 439 | new Int32Array(buf)[2047] = -1; |
michael@0 | 440 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(8188&8191)>>2]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 441 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(8191&8191)>>2]|0; } return f'), this, null, buf)(),-1); |
michael@0 | 442 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[(8192&8191)>>2] = -1; i32[0] = 0; return i32[(8192&8191)>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 443 | |
michael@0 | 444 | var buf = new ArrayBuffer(8192); |
michael@0 | 445 | new Float32Array(buf)[2047] = -1.0; |
michael@0 | 446 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(8188&8191)>>2]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 447 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(8191&8191)>>2]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 448 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[(8192&8191)>>2] = -1.0; f32[0] = 0.0; return +f32[(8192&8191)>>2]; } return f'), this, null, buf)(),0.0); |
michael@0 | 449 | |
michael@0 | 450 | var buf = new ArrayBuffer(8192); |
michael@0 | 451 | new Float64Array(buf)[1023] = -1.0; |
michael@0 | 452 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8184&8191)>>3]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 453 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8191&8191)>>3]; } return f'), this, null, buf)(),-1.0); |
michael@0 | 454 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[(8192&8191)>>3] = -1.0; f64[0] = 0.0; return +f64[(8192&8191)>>3]; } return f'), this, null, buf)(),0.0); |
michael@0 | 455 | |
michael@0 | 456 | // Bug 913867 |
michael@0 | 457 | var buf = new ArrayBuffer(8192); |
michael@0 | 458 | new Int32Array(buf)[0] = 0x55aa5a5a; |
michael@0 | 459 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(0&0)>>2]|0; } return f'), this, null, buf)(),0x55aa5a5a); |
michael@0 | 460 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(4&0)>>2]|0; } return f'), this, null, buf)(),0x55aa5a5a); |
michael@0 | 461 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f1() { i32[0] = 1; return 8; }; function f() { return i32[((f1()|0)&0)>>2]|0; } return f'), this, null, buf)(),1); |
michael@0 | 462 | assertEq(new Int32Array(buf)[0], 1); |
michael@0 | 463 | |
michael@0 | 464 | |
michael@0 | 465 | // Bug 882012 |
michael@0 | 466 | assertEq(asmLink(asmCompile('stdlib', 'foreign', 'heap', USE_ASM + "var id=foreign.id;var doubles=new stdlib.Float64Array(heap);function g(){doubles[0]=+id(2.0);return +doubles[0];}return g"), this, {id: function(x){return x;}}, BUF_64KB)(), 2.0); |
michael@0 | 467 | |
michael@0 | 468 | |
michael@0 | 469 | // Some literal constant paths. |
michael@0 | 470 | |
michael@0 | 471 | var buf = new ArrayBuffer(8192); |
michael@0 | 472 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>4294967295]|0; } return f'); |
michael@0 | 473 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>-1]|0; } return f'); |
michael@0 | 474 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>0x80000000]|0; } return f'); |
michael@0 | 475 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>-2147483648]|0; } return f'); |
michael@0 | 476 | |
michael@0 | 477 | new Uint32Array(buf)[0] = 0xAA; |
michael@0 | 478 | new Uint32Array(buf)[0x5A>>2] = 0xA5; |
michael@0 | 479 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&4294967295)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 480 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u32[(0x5A&i)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 481 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&-1)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 482 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u32[(0x5A&i)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 483 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&0x80000000)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 484 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u32[(0x5A&i)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 485 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&-2147483648)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 486 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u32[(0x5A&i)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 487 | |
michael@0 | 488 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(4294967295&0x5A)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 489 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u32[(i&0x5A)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 490 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(-1&0x5A)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 491 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u32[(i&0x5A)>>2]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 492 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x80000000&0x5A)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 493 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u32[(i&0x5A)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 494 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(-2147483648&0x5A)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 495 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u32[(-2147483648&0x5A)>>2]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 496 | |
michael@0 | 497 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[4294967295>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 498 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u32[i>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 499 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[-1>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 500 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u32[i>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 501 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0x80000000>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 502 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u32[i>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 503 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[-2147483648>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 504 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u32[-2147483648>>2]|0; } return f'), this, null, buf)(),0); |
michael@0 | 505 | |
michael@0 | 506 | var buf = new ArrayBuffer(8192); |
michael@0 | 507 | new Uint8Array(buf)[0] = 0xAA; |
michael@0 | 508 | new Uint8Array(buf)[0x5A] = 0xA5; |
michael@0 | 509 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&4294967295]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 510 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u8[0x5A&i]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 511 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&-1]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 512 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u8[0x5A&i]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 513 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&0x80000000]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 514 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u8[0x5A&i]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 515 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&-2147483648]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 516 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u8[0x5A&i]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 517 | |
michael@0 | 518 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[4294967295&0x5A]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 519 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u8[i&0x5A]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 520 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-1&0x5A]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 521 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u8[i&0x5A]|0; } return f'), this, null, buf)(),0xA5); |
michael@0 | 522 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x80000000&0x5A]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 523 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u8[i&0x5A]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 524 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-2147483648&0x5A]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 525 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u8[i&0x5A]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 526 | |
michael@0 | 527 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[4294967295]|0; } return f'); |
michael@0 | 528 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u8[i]|0; } return f'); |
michael@0 | 529 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-1]|0; } return f'); |
michael@0 | 530 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u8[i]|0; } return f'); |
michael@0 | 531 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x80000000]|0; } return f'); |
michael@0 | 532 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u8[i]|0; } return f'); |
michael@0 | 533 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-2147483648]|0; } return f'); |
michael@0 | 534 | assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u8[i]|0; } return f'); |
michael@0 | 535 | |
michael@0 | 536 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[4294967295>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 537 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u8[i>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 538 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-1>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 539 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u8[i>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 540 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x80000000>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 541 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u8[i>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 542 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-2147483648>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 543 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u8[i>>0]|0; } return f'), this, null, buf)(),0); |
michael@0 | 544 | |
michael@0 | 545 | // GVN checks |
michael@0 | 546 | var buf = new ArrayBuffer(8192); |
michael@0 | 547 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'var i=0; function f() { var x = 0, y = 0; u8[0] = 1; u8[1] = 2; x = 0|u8[i]; i = x; y = 0|u8[i]; return y|0;} return f'), this, null, buf)(),2); |
michael@0 | 548 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'var i=0; function f() { var x = 0, y = 0; u8[0] = 1; u8[1] = 2; x = 0|u8[i]; y = 0|u8[i]; return (x+y)|0;} return f'), this, null, buf)(),2); |
michael@0 | 549 | |
michael@0 | 550 | // Heap length constraints |
michael@0 | 551 | var buf = new ArrayBuffer(0x0fff); |
michael@0 | 552 | assertAsmLinkAlwaysFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 553 | var buf = new ArrayBuffer(0x1000); |
michael@0 | 554 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 555 | var buf = new ArrayBuffer(0x1010); |
michael@0 | 556 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 557 | var buf = new ArrayBuffer(0x2000); |
michael@0 | 558 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 559 | var buf = new ArrayBuffer(0xfe000); |
michael@0 | 560 | new Uint8Array(buf)[0xfdfff] = 0xAA; |
michael@0 | 561 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 562 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfdfff),0xAA); |
michael@0 | 563 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfe000),0); |
michael@0 | 564 | var buf = new ArrayBuffer(0xfe010); |
michael@0 | 565 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 566 | var buf = new ArrayBuffer(0xff000); |
michael@0 | 567 | new Uint8Array(buf)[0xfefff] = 0xAA; |
michael@0 | 568 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 569 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfefff),0xAA); |
michael@0 | 570 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xff000),0); |
michael@0 | 571 | var buf = new ArrayBuffer(0xff800); |
michael@0 | 572 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 573 | var buf = new ArrayBuffer(0x100000); |
michael@0 | 574 | new Uint8Array(buf)[0xfffff] = 0xAA; |
michael@0 | 575 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 576 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfffff),0xAA); |
michael@0 | 577 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x100000),0); |
michael@0 | 578 | var buf = new ArrayBuffer(0x104000); |
michael@0 | 579 | new Uint8Array(buf)[0x103fff] = 0xAA; |
michael@0 | 580 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x103fff]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 581 | var buf = new ArrayBuffer(0x3f8000); |
michael@0 | 582 | new Uint8Array(buf)[0x3f7fff] = 0xAA; |
michael@0 | 583 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 584 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3f7fff),0xAA); |
michael@0 | 585 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3f8000),0); |
michael@0 | 586 | var buf = new ArrayBuffer(0x3fc000); // 4080K |
michael@0 | 587 | new Uint8Array(buf)[0x3fbfff] = 0xAA; |
michael@0 | 588 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 589 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fbfff),0xAA); |
michael@0 | 590 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fc000),0); |
michael@0 | 591 | var buf = new ArrayBuffer(0x3fe000); |
michael@0 | 592 | assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 593 | var buf = new ArrayBuffer(0x410000); |
michael@0 | 594 | new Uint8Array(buf)[0x40ffff] = 0xAA; |
michael@0 | 595 | assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x40ffff]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 596 | // The rest are getting too large for regular testing. |
michael@0 | 597 | //var buf = new ArrayBuffer(0xfe8000); |
michael@0 | 598 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 599 | //var buf = new ArrayBuffer(0xff0000); // 16302K |
michael@0 | 600 | //new Uint8Array(buf)[0xfeffff] = 0xAA; |
michael@0 | 601 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 602 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfeffff),0xAA); |
michael@0 | 603 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xff0000),0); |
michael@0 | 604 | //var buf = new ArrayBuffer(0xff8000); |
michael@0 | 605 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 606 | //var buf = new ArrayBuffer(0x3fb0000); |
michael@0 | 607 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 608 | //var buf = new ArrayBuffer(0x3fc0000); // 65280K |
michael@0 | 609 | //new Uint8Array(buf)[0x3fbffff] = 0xAA; |
michael@0 | 610 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 611 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fbffff),0xAA); |
michael@0 | 612 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fc0000),0); |
michael@0 | 613 | //var buf = new ArrayBuffer(0x3fe0000); |
michael@0 | 614 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 615 | //var buf = new ArrayBuffer(0xfe80000); |
michael@0 | 616 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 617 | //var buf = new ArrayBuffer(0xff00000); // 255M |
michael@0 | 618 | //new Uint8Array(buf)[0xfeffff] = 0xAA; |
michael@0 | 619 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 620 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xfeffff),0xAA); |
michael@0 | 621 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0xff00000),0); |
michael@0 | 622 | //var buf = new ArrayBuffer(0xff80000); |
michael@0 | 623 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 624 | //var buf = new ArrayBuffer(0x10400000); |
michael@0 | 625 | //new Uint8Array(buf)[0x103fffff] = 0xAA; |
michael@0 | 626 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x103fffff]|0; } return f'), this, null, buf)(),0xAA); |
michael@0 | 627 | //var buf = new ArrayBuffer(0x3fa00000); |
michael@0 | 628 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 629 | //var buf = new ArrayBuffer(0x3fc00000); // 1020M |
michael@0 | 630 | //new Uint8Array(buf)[0x3fbfffff] = 0xAA; |
michael@0 | 631 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 632 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fbfffff),0xAA); |
michael@0 | 633 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fc00000),0); |
michael@0 | 634 | //var buf = new ArrayBuffer(0x3fe00000); |
michael@0 | 635 | //assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf); |
michael@0 | 636 | //var buf = new ArrayBuffer(0x40000000); // 1024M |
michael@0 | 637 | //new Uint8Array(buf)[0x3fffffff] = 0xAA; |
michael@0 | 638 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 639 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x3fffffff),0xAA); |
michael@0 | 640 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x40000000),0); |
michael@0 | 641 | //var buf = new ArrayBuffer(0x4f000000); // 1264M - currently the largest possible heap length. |
michael@0 | 642 | //new Uint8Array(buf)[0x4effffff] = 0xAA; |
michael@0 | 643 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0),0); |
michael@0 | 644 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x4effffff),0xAA); |
michael@0 | 645 | //assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf)(0x4f000000),0); |
michael@0 | 646 |