js/src/jit-test/tests/asm.js/testHeapAccess.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/asm.js/testHeapAccess.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,646 @@
     1.4 +load(libdir + "asm.js");
     1.5 +
     1.6 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[0>>2] = 4.0; return i32[0>>2]|0; } return f');
     1.7 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[0>>2] = 4; return +f32[0>>2]; } return f');
     1.8 +
     1.9 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { var x=0,y=0; return i8[x+y]|0 } return f');
    1.10 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { var x=0,y=0; return u8[x+y]|0 } return f');
    1.11 +
    1.12 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>0]|0 }; return f');
    1.13 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>1]|0 }; return f');
    1.14 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>4]|0 }; return f');
    1.15 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0]|0 }; return f'), this, null, new ArrayBuffer(4096))(), 0);
    1.16 +
    1.17 +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');
    1.18 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.19 +assertEq(f(0), 0);
    1.20 +
    1.21 +setCachingEnabled(true);
    1.22 +
    1.23 +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');
    1.24 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.25 +assertEq(f(0),0);
    1.26 +assertEq(f(0x7f),0x7f);
    1.27 +assertEq(f(0xff),-1);
    1.28 +assertEq(f(0x100),0);
    1.29 +
    1.30 +setCachingEnabled(false);
    1.31 +
    1.32 +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');
    1.33 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.34 +assertEq(f(0),0);
    1.35 +assertEq(f(0x7f),0x7f);
    1.36 +assertEq(f(0xff),0xff);
    1.37 +assertEq(f(0x100),0);
    1.38 +
    1.39 +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');
    1.40 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.41 +assertEq(f(0),0);
    1.42 +assertEq(f(0x7fff),0x7fff);
    1.43 +assertEq(f(0xffff),-1);
    1.44 +assertEq(f(0x10000),0);
    1.45 +
    1.46 +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');
    1.47 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.48 +assertEq(f(0),0);
    1.49 +assertEq(f(0x7fff),0x7fff);
    1.50 +assertEq(f(0xffff),0xffff);
    1.51 +assertEq(f(0x10000),0);
    1.52 +
    1.53 +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');
    1.54 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.55 +assertEq(f(0),0);
    1.56 +assertEq(f(0x7fffffff),0x7fffffff);
    1.57 +assertEq(f(0xffffffff),-1);
    1.58 +assertEq(f(0x100000000),0);
    1.59 +
    1.60 +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');
    1.61 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.62 +assertEq(f(0),0);
    1.63 +assertEq(f(0x7fffffff),0x7fffffff);
    1.64 +assertEq(f(0xffffffff),-1);
    1.65 +assertEq(f(0x100000000),0);
    1.66 +
    1.67 +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');
    1.68 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.69 +assertEq(f(0),0);
    1.70 +assertEq(f(0x7f),0x7f);
    1.71 +assertEq(f(0xff),-1);
    1.72 +assertEq(f(0x100),0);
    1.73 +
    1.74 +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');
    1.75 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.76 +assertEq(f(0),0);
    1.77 +assertEq(f(0x7f),0x7f);
    1.78 +assertEq(f(0xff),0xff);
    1.79 +assertEq(f(0x100),0);
    1.80 +
    1.81 +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');
    1.82 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.83 +assertEq(f(0),0);
    1.84 +assertEq(f(0x7f),0x7f);
    1.85 +assertEq(f(0xff),-1);
    1.86 +assertEq(f(0x100),0);
    1.87 +
    1.88 +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');
    1.89 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.90 +assertEq(f(0),0);
    1.91 +assertEq(f(0x7f),0x7f);
    1.92 +assertEq(f(0xff),0xff);
    1.93 +assertEq(f(0x100),0);
    1.94 +
    1.95 +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');
    1.96 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
    1.97 +assertEq(f(0, 1.3), 1);
    1.98 +assertEq(f(4088, 2.5), 2);
    1.99 +assertEq(f(4096, 3.8), 0);
   1.100 +
   1.101 +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');
   1.102 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
   1.103 +assertEq(f(0, 1.3), 1);
   1.104 +assertEq(f(4088, 2.5), 2);
   1.105 +assertEq(f(4096, 3.8), 0);
   1.106 +
   1.107 +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');
   1.108 +var f = asmLink(code, this, null, new ArrayBuffer(4096));
   1.109 +assertEq(f(0, 1.3), 1.3);
   1.110 +assertEq(f(4088, 2.5), 2.5);
   1.111 +assertEq(f(4096, 3.8), NaN);
   1.112 +
   1.113 +var i32 = new Int32Array(4096);
   1.114 +i32[0] = 42;
   1.115 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = i32[0] }; return f'), this, null, i32.buffer)();
   1.116 +assertEq(i32[1], 42);
   1.117 +
   1.118 +var f64 = new Float64Array(4096);
   1.119 +f64[0] = 42;
   1.120 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = f64[0] }; return f'), this, null, f64.buffer)();
   1.121 +assertEq(f64[1], 42);
   1.122 +
   1.123 +var i32 = new Int32Array(4096/4);
   1.124 +i32[0] = 13;
   1.125 +i32[1] = 0xfffeeee;
   1.126 +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);
   1.127 +assertEq(f(0), 13);
   1.128 +assertEq(f(1), 0xfffeeee);
   1.129 +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);
   1.130 +assertEq(f(0), 13);
   1.131 +assertEq(f(1), 0xfffeeee);
   1.132 +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);
   1.133 +assertEq(f(0), 13);
   1.134 +assertEq(f(1), 13);
   1.135 +assertEq(f(2), 0xfffeeee);
   1.136 +assertEq(f(3), 0xfffeeee);
   1.137 +
   1.138 +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);
   1.139 +assertEq(f(0), 13);
   1.140 +assertEq(f(1), 0xfffeeee);
   1.141 +
   1.142 +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);
   1.143 +assertEq(f(0), 0xfffeeee);
   1.144 +
   1.145 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[7&0xffff] = 41 } return f'), this, null, BUF_64KB)();
   1.146 +assertEq(new Uint8Array(BUF_64KB)[7], 41);
   1.147 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[7&0xffff] = -41 } return f'), this, null, BUF_64KB)();
   1.148 +assertEq(new Int8Array(BUF_64KB)[7], -41);
   1.149 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[(6&0xffff)>>1] = 0xabc } return f'), this, null, BUF_64KB)();
   1.150 +assertEq(new Uint16Array(BUF_64KB)[3], 0xabc);
   1.151 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[(6&0xffff)>>1] = -0xabc } return f'), this, null, BUF_64KB)();
   1.152 +assertEq(new Int16Array(BUF_64KB)[3], -0xabc);
   1.153 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[(4&0xffff)>>2] = 0xabcde } return f'), this, null, BUF_64KB)();
   1.154 +assertEq(new Uint32Array(BUF_64KB)[1], 0xabcde);
   1.155 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[(4&0xffff)>>2] = -0xabcde } return f'), this, null, BUF_64KB)();
   1.156 +assertEq(new Int32Array(BUF_64KB)[1], -0xabcde);
   1.157 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[(4&0xffff)>>2] = 1.0 } return f'), this, null, BUF_64KB)();
   1.158 +assertEq(new Float32Array(BUF_64KB)[1], 1.0);
   1.159 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[(8&0xffff)>>3] = 1.3 } return f'), this, null, BUF_64KB)();
   1.160 +assertEq(new Float64Array(BUF_64KB)[1], 1.3);
   1.161 +
   1.162 +new Float32Array(BUF_64KB)[1] = 1.0;
   1.163 +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);
   1.164 +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);
   1.165 +new Float64Array(BUF_64KB)[1] = 1.3;
   1.166 +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);
   1.167 +
   1.168 +asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[255]; u8[i] } return f');
   1.169 +asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[i&0xff]; u8[255] } return f');
   1.170 +asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[63]; u32[i>>2] } return f');
   1.171 +asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[i>>2]; u32[63] } return f');
   1.172 +
   1.173 +var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[64] } return f');
   1.174 +asmLink(code, this, null, new ArrayBuffer(4096));
   1.175 +
   1.176 +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);
   1.177 +assertEq(new Int32Array(BUF_64KB)[12], 11);
   1.178 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[12]|0 } return f'), this, null, BUF_64KB)(), 11);
   1.179 +new Float64Array(BUF_64KB)[0] = 3.5;
   1.180 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +-f64[0] } return f'), this, null, BUF_64KB)(), -3.5);
   1.181 +
   1.182 +// Test constant loads.
   1.183 +var buf = new ArrayBuffer(8192);
   1.184 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[1] = -1 } return f'), this, null, buf)();
   1.185 +assertEq(new Uint8Array(buf)[0], 0);
   1.186 +assertEq(new Uint8Array(buf)[1], 255);
   1.187 +assertEq(new Uint8Array(buf)[2], 0);
   1.188 +var buf = new ArrayBuffer(8192);
   1.189 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[4095] = -1 } return f'), this, null, buf)();
   1.190 +assertEq(new Uint8Array(buf)[4094], 0);
   1.191 +assertEq(new Uint8Array(buf)[4095], 255);
   1.192 +assertEq(new Uint8Array(buf)[4096], 0);
   1.193 +var buf = new ArrayBuffer(8192);
   1.194 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[4096] = -1 } return f'), this, null, buf)();
   1.195 +assertEq(new Uint8Array(buf)[4095], 0);
   1.196 +assertEq(new Uint8Array(buf)[4096], 255);
   1.197 +assertEq(new Uint8Array(buf)[4097], 0);
   1.198 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[8192] = -1 } return f'), this, null, buf);
   1.199 +var buf = new ArrayBuffer(262144);
   1.200 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[258048] = -1 } return f'), this, null, buf)();
   1.201 +assertEq(new Uint8Array(buf)[258047], 0);
   1.202 +assertEq(new Uint8Array(buf)[258048], 255);
   1.203 +assertEq(new Uint8Array(buf)[258049], 0);
   1.204 +
   1.205 +var buf = new ArrayBuffer(8192);
   1.206 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[1] = -1 } return f'), this, null, buf)();
   1.207 +assertEq(new Int8Array(buf)[0], 0);
   1.208 +assertEq(new Int8Array(buf)[1], -1);
   1.209 +assertEq(new Int8Array(buf)[2], 0);
   1.210 +var buf = new ArrayBuffer(8192);
   1.211 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[4095] = -1 } return f'), this, null, buf)();
   1.212 +assertEq(new Int8Array(buf)[4094], 0);
   1.213 +assertEq(new Int8Array(buf)[4095], -1);
   1.214 +assertEq(new Int8Array(buf)[4096], 0);
   1.215 +var buf = new ArrayBuffer(8192);
   1.216 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[4096] = -1 } return f'), this, null, buf)();
   1.217 +assertEq(new Int8Array(buf)[4095], 0);
   1.218 +assertEq(new Int8Array(buf)[4096], -1);
   1.219 +assertEq(new Int8Array(buf)[4097], 0);
   1.220 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[8192] = -1 } return f'), this, null, buf);
   1.221 +var buf = new ArrayBuffer(262144);
   1.222 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[258048] = -1 } return f'), this, null, buf)();
   1.223 +assertEq(new Int8Array(buf)[258047], 0);
   1.224 +assertEq(new Int8Array(buf)[258048], -1);
   1.225 +assertEq(new Int8Array(buf)[258049], 0);
   1.226 +
   1.227 +var buf = new ArrayBuffer(8192);
   1.228 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[1] = -1 } return f'), this, null, buf)();
   1.229 +assertEq(new Uint16Array(buf)[0], 0);
   1.230 +assertEq(new Uint16Array(buf)[1], 65535);
   1.231 +assertEq(new Uint16Array(buf)[2], 0);
   1.232 +var buf = new ArrayBuffer(8192);
   1.233 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2047] = -1 } return f'), this, null, buf)();
   1.234 +assertEq(new Uint16Array(buf)[2046], 0);
   1.235 +assertEq(new Uint16Array(buf)[2047], 65535);
   1.236 +assertEq(new Uint16Array(buf)[2048], 0);
   1.237 +var buf = new ArrayBuffer(8192);
   1.238 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2048] = -1 } return f'), this, null, buf)();
   1.239 +assertEq(new Uint16Array(buf)[2047], 0);
   1.240 +assertEq(new Uint16Array(buf)[2048], 65535);
   1.241 +assertEq(new Uint16Array(buf)[2049], 0);
   1.242 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[4096] = -1 } return f'), this, null, buf);
   1.243 +var buf = new ArrayBuffer(262144);
   1.244 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[126976] = -1 } return f'), this, null, buf)();
   1.245 +assertEq(new Uint16Array(buf)[126975], 0);
   1.246 +assertEq(new Uint16Array(buf)[126976], 65535);
   1.247 +assertEq(new Uint16Array(buf)[126977], 0);
   1.248 +
   1.249 +var buf = new ArrayBuffer(8192);
   1.250 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[1] = -1 } return f'), this, null, buf)();
   1.251 +assertEq(new Int16Array(buf)[0], 0);
   1.252 +assertEq(new Int16Array(buf)[1], -1);
   1.253 +assertEq(new Int16Array(buf)[2], 0);
   1.254 +var buf = new ArrayBuffer(8192);
   1.255 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2047] = -1 } return f'), this, null, buf)();
   1.256 +assertEq(new Int16Array(buf)[2046], 0);
   1.257 +assertEq(new Int16Array(buf)[2047], -1);
   1.258 +assertEq(new Int16Array(buf)[2048], 0);
   1.259 +var buf = new ArrayBuffer(8192);
   1.260 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2048] = -1 } return f'), this, null, buf)();
   1.261 +assertEq(new Int16Array(buf)[2047], 0);
   1.262 +assertEq(new Int16Array(buf)[2048], -1);
   1.263 +assertEq(new Int16Array(buf)[2049], 0);
   1.264 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[4096] = -1 } return f'), this, null, buf);
   1.265 +var buf = new ArrayBuffer(262144);
   1.266 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[126976] = -1 } return f'), this, null, buf)();
   1.267 +assertEq(new Int16Array(buf)[126975], 0);
   1.268 +assertEq(new Int16Array(buf)[126976], -1);
   1.269 +assertEq(new Int16Array(buf)[126977], 0);
   1.270 +
   1.271 +var buf = new ArrayBuffer(8192);
   1.272 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1] = -1 } return f'), this, null, buf)();
   1.273 +assertEq(new Uint32Array(buf)[0], 0);
   1.274 +assertEq(new Uint32Array(buf)[1], 4294967295);
   1.275 +assertEq(new Uint32Array(buf)[2], 0);
   1.276 +var buf = new ArrayBuffer(8192);
   1.277 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1023] = -1 } return f'), this, null, buf)();
   1.278 +assertEq(new Uint32Array(buf)[1022], 0);
   1.279 +assertEq(new Uint32Array(buf)[1023], 4294967295);
   1.280 +assertEq(new Uint32Array(buf)[1024], 0);
   1.281 +var buf = new ArrayBuffer(8192);
   1.282 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1024] = -1 } return f'), this, null, buf)();
   1.283 +assertEq(new Uint32Array(buf)[1023], 0);
   1.284 +assertEq(new Uint32Array(buf)[1024], 4294967295);
   1.285 +assertEq(new Uint32Array(buf)[1025], 0);
   1.286 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[2048] = -1 } return f'), this, null, buf);
   1.287 +var buf = new ArrayBuffer(262144);
   1.288 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[61440] = -1 } return f'), this, null, buf)();
   1.289 +assertEq(new Uint32Array(buf)[61439], 0);
   1.290 +assertEq(new Uint32Array(buf)[61440], 4294967295);
   1.291 +assertEq(new Uint32Array(buf)[61441], 0);
   1.292 +
   1.293 +var buf = new ArrayBuffer(8192);
   1.294 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = -1 } return f'), this, null, buf)();
   1.295 +assertEq(new Int32Array(buf)[0], 0);
   1.296 +assertEq(new Int32Array(buf)[1], -1);
   1.297 +assertEq(new Int32Array(buf)[2], 0);
   1.298 +var buf = new ArrayBuffer(8192);
   1.299 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1023] = -1 } return f'), this, null, buf)();
   1.300 +assertEq(new Int32Array(buf)[1022], 0);
   1.301 +assertEq(new Int32Array(buf)[1023], -1);
   1.302 +assertEq(new Int32Array(buf)[124], 0);
   1.303 +var buf = new ArrayBuffer(8192);
   1.304 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1024] = -1 } return f'), this, null, buf)();
   1.305 +assertEq(new Int32Array(buf)[1023], 0);
   1.306 +assertEq(new Int32Array(buf)[1024], -1);
   1.307 +assertEq(new Int32Array(buf)[1025], 0);
   1.308 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[2048] = -1 } return f'), this, null, buf);
   1.309 +var buf = new ArrayBuffer(262144);
   1.310 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[61440] = -1 } return f'), this, null, buf)();
   1.311 +assertEq(new Int32Array(buf)[61439], 0);
   1.312 +assertEq(new Int32Array(buf)[61440], -1);
   1.313 +assertEq(new Int32Array(buf)[61441], 0);
   1.314 +
   1.315 +var buf = new ArrayBuffer(8192);
   1.316 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1] = -1.0 } return f'), this, null, buf)();
   1.317 +assertEq(new Int32Array(buf)[0], 0);
   1.318 +assertEq(new Float32Array(buf)[1], -1.0);
   1.319 +assertEq(new Int32Array(buf)[2], 0);
   1.320 +var buf = new ArrayBuffer(8192);
   1.321 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1023] = -1.0 } return f'), this, null, buf)();
   1.322 +assertEq(new Int32Array(buf)[1022], 0);
   1.323 +assertEq(new Float32Array(buf)[1023], -1.0);
   1.324 +assertEq(new Int32Array(buf)[124], 0);
   1.325 +var buf = new ArrayBuffer(8192);
   1.326 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1024] = -1.0 } return f'), this, null, buf)();
   1.327 +assertEq(new Int32Array(buf)[1023], 0);
   1.328 +assertEq(new Float32Array(buf)[1024], -1.0);
   1.329 +assertEq(new Int32Array(buf)[1025], 0);
   1.330 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[2048] = -1.0 } return f'), this, null, buf);
   1.331 +var buf = new ArrayBuffer(262144);
   1.332 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[61440] = -1.0 } return f'), this, null, buf)();
   1.333 +assertEq(new Float32Array(buf)[61439], 0.0);
   1.334 +assertEq(new Float32Array(buf)[61440], -1.0);
   1.335 +assertEq(new Float32Array(buf)[61441], 0.0);
   1.336 +
   1.337 +var buf = new ArrayBuffer(8192);
   1.338 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = -1.0 } return f'), this, null, buf)();
   1.339 +assertEq(new Float64Array(buf)[0], 0.0);
   1.340 +assertEq(new Float64Array(buf)[1], -1.0);
   1.341 +assertEq(new Float64Array(buf)[2], 0.0);
   1.342 +var buf = new ArrayBuffer(8192);
   1.343 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[511] = -1.0 } return f'), this, null, buf)();
   1.344 +assertEq(new Float64Array(buf)[510], 0.0);
   1.345 +assertEq(new Float64Array(buf)[511], -1.0);
   1.346 +assertEq(new Float64Array(buf)[512], 0.0);
   1.347 +var buf = new ArrayBuffer(8192);
   1.348 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[512] = -1.0 } return f'), this, null, buf)();
   1.349 +assertEq(new Float64Array(buf)[511], 0.0);
   1.350 +assertEq(new Float64Array(buf)[512], -1.0);
   1.351 +assertEq(new Float64Array(buf)[513], 0.0);
   1.352 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1024] = -1.0 } return f'), this, null, buf);
   1.353 +var buf = new ArrayBuffer(262144);
   1.354 +asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[28672] = -1.0 } return f'), this, null, buf)();
   1.355 +assertEq(new Float64Array(buf)[28671], 0.0);
   1.356 +assertEq(new Float64Array(buf)[28672], -1.0);
   1.357 +assertEq(new Float64Array(buf)[28673], 0.0);
   1.358 +
   1.359 +
   1.360 +var buf = new ArrayBuffer(8192);
   1.361 +new Uint8Array(buf)[1] = -1;
   1.362 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[1]|0; } return f'), this, null, buf)(),255);
   1.363 +new Int8Array(buf)[1] = -1;
   1.364 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[1]|0; } return f'), this, null, buf)(),-1);
   1.365 +var buf = new ArrayBuffer(262144);
   1.366 +new Uint8Array(buf)[126976] = -1;
   1.367 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[126976]|0; } return f'), this, null, buf)(),255);
   1.368 +new Int8Array(buf)[126976] = -1;
   1.369 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[126976]|0; } return f'), this, null, buf)(),-1);
   1.370 +
   1.371 +var buf = new ArrayBuffer(8192);
   1.372 +new Uint16Array(buf)[1] = -1;
   1.373 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[1]|0; } return f'), this, null, buf)(),65535);
   1.374 +new Int16Array(buf)[1] = -1;
   1.375 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[1]|0; } return f'), this, null, buf)(),-1);
   1.376 +var buf = new ArrayBuffer(262144);
   1.377 +new Uint16Array(buf)[126976] = -1;
   1.378 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[126976]|0; } return f'), this, null, buf)(),65535);
   1.379 +new Int16Array(buf)[126976] = -1;
   1.380 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[126976]|0; } return f'), this, null, buf)(),-1);
   1.381 +
   1.382 +var buf = new ArrayBuffer(8192);
   1.383 +new Uint32Array(buf)[1] = -1;
   1.384 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[1]|0; } return f'), this, null, buf)(),-1);
   1.385 +new Int32Array(buf)[1] = -1;
   1.386 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[1]|0; } return f'), this, null, buf)(),-1);
   1.387 +var buf = new ArrayBuffer(262144);
   1.388 +new Int32Array(buf)[61440] = -1;
   1.389 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[61440]|0; } return f'), this, null, buf)(),-1);
   1.390 +
   1.391 +var buf = new ArrayBuffer(8192);
   1.392 +new Float32Array(buf)[1] = -1.0;
   1.393 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1]; } return f'), this, null, buf)(),-1.0);
   1.394 +new Float32Array(buf)[1023] = -1.0;
   1.395 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1023]; } return f'), this, null, buf)(),-1.0);
   1.396 +new Float32Array(buf)[1024] = -1.0;
   1.397 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1024]; } return f'), this, null, buf)(),-1.0);
   1.398 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[2048]; } return f'), this, null, buf);
   1.399 +var buf = new ArrayBuffer(262144);
   1.400 +new Float32Array(buf)[61440] = -1.0;
   1.401 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[61440]; } return f'), this, null, buf)(),-1.0);
   1.402 +
   1.403 +var buf = new ArrayBuffer(8192);
   1.404 +new Float64Array(buf)[1] = -1.0;
   1.405 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[1]; } return f'), this, null, buf)(),-1.0);
   1.406 +new Float64Array(buf)[511] = -1.0;
   1.407 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[511]; } return f'), this, null, buf)(),-1.0);
   1.408 +new Float64Array(buf)[512] = -1.0;
   1.409 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[512]; } return f'), this, null, buf)(),-1.0);
   1.410 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[1024]; } return f'), this, null, buf);
   1.411 +var buf = new ArrayBuffer(262144);
   1.412 +new Float64Array(buf)[28672] = -1.0;
   1.413 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[28672]; } return f'), this, null, buf)(),-1.0);
   1.414 +
   1.415 +// Test bitwise-and optimizations.
   1.416 +var buf = new ArrayBuffer(8192);
   1.417 +new Uint8Array(buf)[8191] = -1;
   1.418 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[8191&8191]|0; } return f'), this, null, buf)(),255);
   1.419 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[(8191&8191)>>0]|0; } return f'), this, null, buf)(),255);
   1.420 +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);
   1.421 +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);
   1.422 +new Int8Array(buf)[8191] = -1;
   1.423 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[8191&8191]|0; } return f'), this, null, buf)(),-1);
   1.424 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[(8191&8191)>>0]|0; } return f'), this, null, buf)(),-1);
   1.425 +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);
   1.426 +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);
   1.427 +var buf = new ArrayBuffer(8192);
   1.428 +new Uint16Array(buf)[4095] = -1;
   1.429 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[(8190&8191)>>1]|0; } return f'), this, null, buf)(),65535);
   1.430 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[(8191&8191)>>1]|0; } return f'), this, null, buf)(),65535);
   1.431 +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);
   1.432 +new Int16Array(buf)[4095] = -1;
   1.433 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[(8190&8191)>>1]|0; } return f'), this, null, buf)(),-1);
   1.434 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[(8191&8191)>>1]|0; } return f'), this, null, buf)(),-1);
   1.435 +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);
   1.436 +
   1.437 +var buf = new ArrayBuffer(8192);
   1.438 +new Uint32Array(buf)[2047] = -1;
   1.439 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(8188&8191)>>2]|0; } return f'), this, null, buf)(),-1);
   1.440 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(8191&8191)>>2]|0; } return f'), this, null, buf)(),-1);
   1.441 +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);
   1.442 +new Int32Array(buf)[2047] = -1;
   1.443 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(8188&8191)>>2]|0; } return f'), this, null, buf)(),-1);
   1.444 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(8191&8191)>>2]|0; } return f'), this, null, buf)(),-1);
   1.445 +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);
   1.446 +
   1.447 +var buf = new ArrayBuffer(8192);
   1.448 +new Float32Array(buf)[2047] = -1.0;
   1.449 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(8188&8191)>>2]; } return f'), this, null, buf)(),-1.0);
   1.450 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(8191&8191)>>2]; } return f'), this, null, buf)(),-1.0);
   1.451 +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);
   1.452 +
   1.453 +var buf = new ArrayBuffer(8192);
   1.454 +new Float64Array(buf)[1023] = -1.0;
   1.455 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8184&8191)>>3]; } return f'), this, null, buf)(),-1.0);
   1.456 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8191&8191)>>3]; } return f'), this, null, buf)(),-1.0);
   1.457 +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);
   1.458 +
   1.459 +// Bug 913867
   1.460 +var buf = new ArrayBuffer(8192);
   1.461 +new Int32Array(buf)[0] = 0x55aa5a5a;
   1.462 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(0&0)>>2]|0; } return f'), this, null, buf)(),0x55aa5a5a);
   1.463 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(4&0)>>2]|0; } return f'), this, null, buf)(),0x55aa5a5a);
   1.464 +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);
   1.465 +assertEq(new Int32Array(buf)[0], 1);
   1.466 +
   1.467 +
   1.468 +// Bug 882012
   1.469 +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);
   1.470 +
   1.471 +
   1.472 +// Some literal constant paths.
   1.473 +
   1.474 +var buf = new ArrayBuffer(8192);
   1.475 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>4294967295]|0; } return f');
   1.476 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>-1]|0; } return f');
   1.477 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>0x80000000]|0; } return f');
   1.478 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>-2147483648]|0; } return f');
   1.479 +
   1.480 +new Uint32Array(buf)[0] = 0xAA;
   1.481 +new Uint32Array(buf)[0x5A>>2] = 0xA5;
   1.482 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&4294967295)>>2]|0; } return f'), this, null, buf)(),0xA5);
   1.483 +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);
   1.484 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&-1)>>2]|0; } return f'), this, null, buf)(),0xA5);
   1.485 +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);
   1.486 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&0x80000000)>>2]|0; } return f'), this, null, buf)(),0xAA);
   1.487 +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);
   1.488 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x5A&-2147483648)>>2]|0; } return f'), this, null, buf)(),0xAA);
   1.489 +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);
   1.490 +
   1.491 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(4294967295&0x5A)>>2]|0; } return f'), this, null, buf)(),0xA5);
   1.492 +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);
   1.493 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(-1&0x5A)>>2]|0; } return f'), this, null, buf)(),0xA5);
   1.494 +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);
   1.495 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(0x80000000&0x5A)>>2]|0; } return f'), this, null, buf)(),0xAA);
   1.496 +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);
   1.497 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(-2147483648&0x5A)>>2]|0; } return f'), this, null, buf)(),0xAA);
   1.498 +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);
   1.499 +
   1.500 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[4294967295>>2]|0; } return f'), this, null, buf)(),0);
   1.501 +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);
   1.502 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[-1>>2]|0; } return f'), this, null, buf)(),0);
   1.503 +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);
   1.504 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0x80000000>>2]|0; } return f'), this, null, buf)(),0);
   1.505 +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);
   1.506 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[-2147483648>>2]|0; } return f'), this, null, buf)(),0);
   1.507 +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);
   1.508 +
   1.509 +var buf = new ArrayBuffer(8192);
   1.510 +new Uint8Array(buf)[0] = 0xAA;
   1.511 +new Uint8Array(buf)[0x5A] = 0xA5;
   1.512 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&4294967295]|0; } return f'), this, null, buf)(),0xA5);
   1.513 +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);
   1.514 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&-1]|0; } return f'), this, null, buf)(),0xA5);
   1.515 +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);
   1.516 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&0x80000000]|0; } return f'), this, null, buf)(),0xAA);
   1.517 +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);
   1.518 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&-2147483648]|0; } return f'), this, null, buf)(),0xAA);
   1.519 +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);
   1.520 +
   1.521 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[4294967295&0x5A]|0; } return f'), this, null, buf)(),0xA5);
   1.522 +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);
   1.523 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-1&0x5A]|0; } return f'), this, null, buf)(),0xA5);
   1.524 +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);
   1.525 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x80000000&0x5A]|0; } return f'), this, null, buf)(),0xAA);
   1.526 +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);
   1.527 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-2147483648&0x5A]|0; } return f'), this, null, buf)(),0xAA);
   1.528 +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);
   1.529 +
   1.530 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[4294967295]|0; } return f');
   1.531 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=4294967295; function f() { return u8[i]|0; } return f');
   1.532 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-1]|0; } return f');
   1.533 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-1; function f() { return u8[i]|0; } return f');
   1.534 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x80000000]|0; } return f');
   1.535 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=0x80000000; function f() { return u8[i]|0; } return f');
   1.536 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-2147483648]|0; } return f');
   1.537 +assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const i=-2147483648; function f() { return u8[i]|0; } return f');
   1.538 +
   1.539 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[4294967295>>0]|0; } return f'), this, null, buf)(),0);
   1.540 +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);
   1.541 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-1>>0]|0; } return f'), this, null, buf)(),0);
   1.542 +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);
   1.543 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x80000000>>0]|0; } return f'), this, null, buf)(),0);
   1.544 +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);
   1.545 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[-2147483648>>0]|0; } return f'), this, null, buf)(),0);
   1.546 +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);
   1.547 +
   1.548 +// GVN checks
   1.549 +var buf = new ArrayBuffer(8192);
   1.550 +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);
   1.551 +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);
   1.552 +
   1.553 +// Heap length constraints
   1.554 +var buf = new ArrayBuffer(0x0fff);
   1.555 +assertAsmLinkAlwaysFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.556 +var buf = new ArrayBuffer(0x1000);
   1.557 +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);
   1.558 +var buf = new ArrayBuffer(0x1010);
   1.559 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.560 +var buf = new ArrayBuffer(0x2000);
   1.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);
   1.562 +var buf = new ArrayBuffer(0xfe000);
   1.563 +new Uint8Array(buf)[0xfdfff] = 0xAA;
   1.564 +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);
   1.565 +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);
   1.566 +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);
   1.567 +var buf = new ArrayBuffer(0xfe010);
   1.568 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.569 +var buf = new ArrayBuffer(0xff000);
   1.570 +new Uint8Array(buf)[0xfefff] = 0xAA;
   1.571 +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);
   1.572 +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);
   1.573 +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);
   1.574 +var buf = new ArrayBuffer(0xff800);
   1.575 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.576 +var buf = new ArrayBuffer(0x100000);
   1.577 +new Uint8Array(buf)[0xfffff] = 0xAA;
   1.578 +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);
   1.579 +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);
   1.580 +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);
   1.581 +var buf = new ArrayBuffer(0x104000);
   1.582 +new Uint8Array(buf)[0x103fff] = 0xAA;
   1.583 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x103fff]|0; } return f'), this, null, buf)(),0xAA);
   1.584 +var buf = new ArrayBuffer(0x3f8000);
   1.585 +new Uint8Array(buf)[0x3f7fff] = 0xAA;
   1.586 +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);
   1.587 +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);
   1.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)(0x3f8000),0);
   1.589 +var buf = new ArrayBuffer(0x3fc000); // 4080K
   1.590 +new Uint8Array(buf)[0x3fbfff] = 0xAA;
   1.591 +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);
   1.592 +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);
   1.593 +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);
   1.594 +var buf = new ArrayBuffer(0x3fe000);
   1.595 +assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.596 +var buf = new ArrayBuffer(0x410000);
   1.597 +new Uint8Array(buf)[0x40ffff] = 0xAA;
   1.598 +assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x40ffff]|0; } return f'), this, null, buf)(),0xAA);
   1.599 +// The rest are getting too large for regular testing.
   1.600 +//var buf = new ArrayBuffer(0xfe8000);
   1.601 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.602 +//var buf = new ArrayBuffer(0xff0000); // 16302K
   1.603 +//new Uint8Array(buf)[0xfeffff] = 0xAA;
   1.604 +//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);
   1.605 +//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);
   1.606 +//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);
   1.607 +//var buf = new ArrayBuffer(0xff8000);
   1.608 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.609 +//var buf = new ArrayBuffer(0x3fb0000);
   1.610 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.611 +//var buf = new ArrayBuffer(0x3fc0000); // 65280K
   1.612 +//new Uint8Array(buf)[0x3fbffff] = 0xAA;
   1.613 +//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);
   1.614 +//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);
   1.615 +//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);
   1.616 +//var buf = new ArrayBuffer(0x3fe0000);
   1.617 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.618 +//var buf = new ArrayBuffer(0xfe80000);
   1.619 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.620 +//var buf = new ArrayBuffer(0xff00000); // 255M
   1.621 +//new Uint8Array(buf)[0xfeffff] = 0xAA;
   1.622 +//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);
   1.623 +//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);
   1.624 +//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);
   1.625 +//var buf = new ArrayBuffer(0xff80000);
   1.626 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.627 +//var buf = new ArrayBuffer(0x10400000);
   1.628 +//new Uint8Array(buf)[0x103fffff] = 0xAA;
   1.629 +//assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x103fffff]|0; } return f'), this, null, buf)(),0xAA);
   1.630 +//var buf = new ArrayBuffer(0x3fa00000);
   1.631 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.632 +//var buf = new ArrayBuffer(0x3fc00000); // 1020M
   1.633 +//new Uint8Array(buf)[0x3fbfffff] = 0xAA;
   1.634 +//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);
   1.635 +//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);
   1.636 +//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);
   1.637 +//var buf = new ArrayBuffer(0x3fe00000);
   1.638 +//assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f'), this, null, buf);
   1.639 +//var buf = new ArrayBuffer(0x40000000); // 1024M
   1.640 +//new Uint8Array(buf)[0x3fffffff] = 0xAA;
   1.641 +//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);
   1.642 +//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);
   1.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)(0x40000000),0);
   1.644 +//var buf = new ArrayBuffer(0x4f000000); // 1264M - currently the largest possible heap length.
   1.645 +//new Uint8Array(buf)[0x4effffff] = 0xAA;
   1.646 +//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);
   1.647 +//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);
   1.648 +//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);
   1.649 +

mercurial