|
|
|
@ -9,16 +9,16 @@ assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { v
|
|
|
|
|
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>0]|0 }; return f');
|
|
|
|
|
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>1]|0 }; return f');
|
|
|
|
|
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>4]|0 }; return f');
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0]|0 }; return f'), this, null, new ArrayBuffer(4096))(), 0);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0]|0 }; return f'), this, null, new ArrayBuffer(BUF_MIN))(), 0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0), 0);
|
|
|
|
|
|
|
|
|
|
setCachingEnabled(true);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),-1);
|
|
|
|
@ -35,11 +35,11 @@ assertEq(f(0x100),0);
|
|
|
|
|
// Cloned modules should fail on linking if the initial module has
|
|
|
|
|
// been compiled with signals but signals are deactivated.
|
|
|
|
|
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');
|
|
|
|
|
assertAsmLinkFail(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
assertAsmLinkFail(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + '/* not a clone */ function f(i) {i=i|0; i32[0] = i; return i8[0]|0}; return f');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),-1);
|
|
|
|
@ -54,97 +54,97 @@ assertEq(f(0x100),0);
|
|
|
|
|
setCachingEnabled(false);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),0xff);
|
|
|
|
|
assertEq(f(0x100),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7fff),0x7fff);
|
|
|
|
|
assertEq(f(0xffff),-1);
|
|
|
|
|
assertEq(f(0x10000),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7fff),0x7fff);
|
|
|
|
|
assertEq(f(0xffff),0xffff);
|
|
|
|
|
assertEq(f(0x10000),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7fffffff),0x7fffffff);
|
|
|
|
|
assertEq(f(0xffffffff),-1);
|
|
|
|
|
assertEq(f(0x100000000),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7fffffff),0x7fffffff);
|
|
|
|
|
assertEq(f(0xffffffff),-1);
|
|
|
|
|
assertEq(f(0x100000000),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),-1);
|
|
|
|
|
assertEq(f(0x100),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),0xff);
|
|
|
|
|
assertEq(f(0x100),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),-1);
|
|
|
|
|
assertEq(f(0x100),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0),0);
|
|
|
|
|
assertEq(f(0x7f),0x7f);
|
|
|
|
|
assertEq(f(0xff),0xff);
|
|
|
|
|
assertEq(f(0x100),0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0, 1.3), 1);
|
|
|
|
|
assertEq(f(4088, 2.5), 2);
|
|
|
|
|
assertEq(f(4096, 3.8), 0);
|
|
|
|
|
assertEq(f(BUF_MIN-8, 2.5), 2);
|
|
|
|
|
assertEq(f(BUF_MIN, 3.8), 0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0, 1.3), 1);
|
|
|
|
|
assertEq(f(4088, 2.5), 2);
|
|
|
|
|
assertEq(f(4096, 3.8), 0);
|
|
|
|
|
assertEq(f(BUF_MIN-8, 2.5), 2);
|
|
|
|
|
assertEq(f(BUF_MIN, 3.8), 0);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
var f = asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
assertEq(f(0, 1.3), 1.3);
|
|
|
|
|
assertEq(f(4088, 2.5), 2.5);
|
|
|
|
|
assertEq(f(4096, 3.8), NaN);
|
|
|
|
|
assertEq(f(BUF_MIN-8, 2.5), 2.5);
|
|
|
|
|
assertEq(f(BUF_MIN, 3.8), NaN);
|
|
|
|
|
|
|
|
|
|
var i32 = new Int32Array(4096);
|
|
|
|
|
var i32 = new Int32Array(BUF_MIN);
|
|
|
|
|
i32[0] = 42;
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = i32[0] }; return f'), this, null, i32.buffer)();
|
|
|
|
|
assertEq(i32[1], 42);
|
|
|
|
|
|
|
|
|
|
var f64 = new Float64Array(4096);
|
|
|
|
|
var f64 = new Float64Array(BUF_MIN);
|
|
|
|
|
f64[0] = 42;
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = f64[0] }; return f'), this, null, f64.buffer)();
|
|
|
|
|
assertEq(f64[1], 42);
|
|
|
|
|
|
|
|
|
|
var i32 = new Int32Array(4096/4);
|
|
|
|
|
var i32 = new Int32Array(BUF_MIN/4);
|
|
|
|
|
i32[0] = 13;
|
|
|
|
|
i32[1] = 0xfffeeee;
|
|
|
|
|
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);
|
|
|
|
@ -195,7 +195,7 @@ asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0;
|
|
|
|
|
asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[i>>2]; u32[63] } return f');
|
|
|
|
|
|
|
|
|
|
var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[64] } return f');
|
|
|
|
|
asmLink(code, this, null, new ArrayBuffer(4096));
|
|
|
|
|
asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
assertEq(new Int32Array(BUF_64KB)[12], 11);
|
|
|
|
@ -204,176 +204,176 @@ new Float64Array(BUF_64KB)[0] = 3.5;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +-f64[0] } return f'), this, null, BUF_64KB)(), -3.5);
|
|
|
|
|
|
|
|
|
|
// Test constant loads.
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[1] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint8Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Uint8Array(buf)[1], 255);
|
|
|
|
|
assertEq(new Uint8Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[4095] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint8Array(buf)[4094], 0);
|
|
|
|
|
assertEq(new Uint8Array(buf)[4095], 255);
|
|
|
|
|
assertEq(new Uint8Array(buf)[4096], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[4096] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint8Array(buf)[4095], 0);
|
|
|
|
|
assertEq(new Uint8Array(buf)[4096], 255);
|
|
|
|
|
assertEq(new Uint8Array(buf)[4097], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[8192] = -1 } return f'), this, null, buf);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[' + BUF_MIN + '] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[258048] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint8Array(buf)[258047], 0);
|
|
|
|
|
assertEq(new Uint8Array(buf)[258048], 255);
|
|
|
|
|
assertEq(new Uint8Array(buf)[258049], 0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[1] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int8Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Int8Array(buf)[1], -1);
|
|
|
|
|
assertEq(new Int8Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[4095] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int8Array(buf)[4094], 0);
|
|
|
|
|
assertEq(new Int8Array(buf)[4095], -1);
|
|
|
|
|
assertEq(new Int8Array(buf)[4096], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[4096] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int8Array(buf)[4095], 0);
|
|
|
|
|
assertEq(new Int8Array(buf)[4096], -1);
|
|
|
|
|
assertEq(new Int8Array(buf)[4097], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[8192] = -1 } return f'), this, null, buf);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[' + BUF_MIN + '] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[258048] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int8Array(buf)[258047], 0);
|
|
|
|
|
assertEq(new Int8Array(buf)[258048], -1);
|
|
|
|
|
assertEq(new Int8Array(buf)[258049], 0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[1] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint16Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Uint16Array(buf)[1], 65535);
|
|
|
|
|
assertEq(new Uint16Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2047] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint16Array(buf)[2046], 0);
|
|
|
|
|
assertEq(new Uint16Array(buf)[2047], 65535);
|
|
|
|
|
assertEq(new Uint16Array(buf)[2048], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2048] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint16Array(buf)[2047], 0);
|
|
|
|
|
assertEq(new Uint16Array(buf)[2048], 65535);
|
|
|
|
|
assertEq(new Uint16Array(buf)[2049], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[4096] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[' + (BUF_MIN/2-1) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint16Array(buf)[BUF_MIN/2-2], 0);
|
|
|
|
|
assertEq(new Uint16Array(buf)[BUF_MIN/2-1], 65535);
|
|
|
|
|
assertEq(new Uint16Array(buf)[BUF_MIN/2], undefined);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[' + (BUF_MIN/4) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint16Array(buf)[BUF_MIN/4-1], 0);
|
|
|
|
|
assertEq(new Uint16Array(buf)[BUF_MIN/4], 65535);
|
|
|
|
|
assertEq(new Uint16Array(buf)[BUF_MIN/4+1], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[' + (BUF_MIN/2) + '] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[126976] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint16Array(buf)[126975], 0);
|
|
|
|
|
assertEq(new Uint16Array(buf)[126976], 65535);
|
|
|
|
|
assertEq(new Uint16Array(buf)[126977], 0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[1] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int16Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Int16Array(buf)[1], -1);
|
|
|
|
|
assertEq(new Int16Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2047] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int16Array(buf)[2046], 0);
|
|
|
|
|
assertEq(new Int16Array(buf)[2047], -1);
|
|
|
|
|
assertEq(new Int16Array(buf)[2048], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2048] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int16Array(buf)[2047], 0);
|
|
|
|
|
assertEq(new Int16Array(buf)[2048], -1);
|
|
|
|
|
assertEq(new Int16Array(buf)[2049], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[4096] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[' + (BUF_MIN/2-1) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int16Array(buf)[BUF_MIN/2-2], 0);
|
|
|
|
|
assertEq(new Int16Array(buf)[BUF_MIN/2-1], -1);
|
|
|
|
|
assertEq(new Int16Array(buf)[BUF_MIN/2], undefined);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[' + (BUF_MIN/4) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int16Array(buf)[BUF_MIN/4-1], 0);
|
|
|
|
|
assertEq(new Int16Array(buf)[BUF_MIN/4], -1);
|
|
|
|
|
assertEq(new Int16Array(buf)[BUF_MIN/4+1], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[' + (BUF_MIN/2) + '] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[126976] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int16Array(buf)[126975], 0);
|
|
|
|
|
assertEq(new Int16Array(buf)[126976], -1);
|
|
|
|
|
assertEq(new Int16Array(buf)[126977], 0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint32Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Uint32Array(buf)[1], 4294967295);
|
|
|
|
|
assertEq(new Uint32Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1023] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint32Array(buf)[1022], 0);
|
|
|
|
|
assertEq(new Uint32Array(buf)[1023], 4294967295);
|
|
|
|
|
assertEq(new Uint32Array(buf)[1024], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1024] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint32Array(buf)[1023], 0);
|
|
|
|
|
assertEq(new Uint32Array(buf)[1024], 4294967295);
|
|
|
|
|
assertEq(new Uint32Array(buf)[1025], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[2048] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[' + (BUF_MIN/4-1) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint32Array(buf)[BUF_MIN/4-2], 0);
|
|
|
|
|
assertEq(new Uint32Array(buf)[BUF_MIN/4-1], 4294967295);
|
|
|
|
|
assertEq(new Uint32Array(buf)[BUF_MIN/4], undefined);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[' + (BUF_MIN/8) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint32Array(buf)[BUF_MIN/8-1], 0);
|
|
|
|
|
assertEq(new Uint32Array(buf)[BUF_MIN/8], 4294967295);
|
|
|
|
|
assertEq(new Uint32Array(buf)[BUF_MIN/8+1], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[' + (BUF_MIN/4) + '] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[61440] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Uint32Array(buf)[61439], 0);
|
|
|
|
|
assertEq(new Uint32Array(buf)[61440], 4294967295);
|
|
|
|
|
assertEq(new Uint32Array(buf)[61441], 0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Int32Array(buf)[1], -1);
|
|
|
|
|
assertEq(new Int32Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1023] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[1022], 0);
|
|
|
|
|
assertEq(new Int32Array(buf)[1023], -1);
|
|
|
|
|
assertEq(new Int32Array(buf)[124], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1024] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[1023], 0);
|
|
|
|
|
assertEq(new Int32Array(buf)[1024], -1);
|
|
|
|
|
assertEq(new Int32Array(buf)[1025], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[2048] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[' + (BUF_MIN/4-1) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/4-2], 0);
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/4-1], -1);
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/4], undefined);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[' + (BUF_MIN/8) + '] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/8-1], 0);
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/8], -1);
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/8+1], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[' + (BUF_MIN/4) + '] = -1 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[61440] = -1 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[61439], 0);
|
|
|
|
|
assertEq(new Int32Array(buf)[61440], -1);
|
|
|
|
|
assertEq(new Int32Array(buf)[61441], 0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[0], 0);
|
|
|
|
|
assertEq(new Float32Array(buf)[1], -1.0);
|
|
|
|
|
assertEq(new Int32Array(buf)[2], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1023] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[1022], 0);
|
|
|
|
|
assertEq(new Float32Array(buf)[1023], -1.0);
|
|
|
|
|
assertEq(new Int32Array(buf)[124], 0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1024] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[1023], 0);
|
|
|
|
|
assertEq(new Float32Array(buf)[1024], -1.0);
|
|
|
|
|
assertEq(new Int32Array(buf)[1025], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[2048] = -1.0 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[' + (BUF_MIN/4-1) + '] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/4-2], 0);
|
|
|
|
|
assertEq(new Float32Array(buf)[BUF_MIN/4-1], -1.0);
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/4], undefined);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[' + (BUF_MIN/8) + '] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/8-1], 0);
|
|
|
|
|
assertEq(new Float32Array(buf)[BUF_MIN/8], -1.0);
|
|
|
|
|
assertEq(new Int32Array(buf)[BUF_MIN/8+1], 0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[' + (BUF_MIN/4) + '] = -1.0 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[61440] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float32Array(buf)[61439], 0.0);
|
|
|
|
|
assertEq(new Float32Array(buf)[61440], -1.0);
|
|
|
|
|
assertEq(new Float32Array(buf)[61441], 0.0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float64Array(buf)[0], 0.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[1], -1.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[2], 0.0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[511] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float64Array(buf)[510], 0.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[511], -1.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[512], 0.0);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[512] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float64Array(buf)[511], 0.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[512], -1.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[513], 0.0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1024] = -1.0 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[' + (BUF_MIN/8-1) + '] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float64Array(buf)[BUF_MIN/8-2], 0.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[BUF_MIN/8-1], -1.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[BUF_MIN/8], undefined);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[' + (BUF_MIN/16) + '] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float64Array(buf)[BUF_MIN/16-1], 0.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[BUF_MIN/16], -1.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[BUF_MIN/16+1], 0.0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[' + (BUF_MIN/8) + '] = -1.0 } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[28672] = -1.0 } return f'), this, null, buf)();
|
|
|
|
|
assertEq(new Float64Array(buf)[28671], 0.0);
|
|
|
|
@ -381,7 +381,7 @@ assertEq(new Float64Array(buf)[28672], -1.0);
|
|
|
|
|
assertEq(new Float64Array(buf)[28673], 0.0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint8Array(buf)[1] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[1]|0; } return f'), this, null, buf)(),255);
|
|
|
|
|
new Int8Array(buf)[1] = -1;
|
|
|
|
@ -392,7 +392,7 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi
|
|
|
|
|
new Int8Array(buf)[126976] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[126976]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint16Array(buf)[1] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[1]|0; } return f'), this, null, buf)(),65535);
|
|
|
|
|
new Int16Array(buf)[1] = -1;
|
|
|
|
@ -403,7 +403,7 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi
|
|
|
|
|
new Int16Array(buf)[126976] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[126976]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint32Array(buf)[1] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[1]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
new Int32Array(buf)[1] = -1;
|
|
|
|
@ -412,32 +412,32 @@ var buf = new ArrayBuffer(262144);
|
|
|
|
|
new Int32Array(buf)[61440] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[61440]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Float32Array(buf)[1] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
new Float32Array(buf)[1023] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1023]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
new Float32Array(buf)[1024] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1024]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[2048]; } return f'), this, null, buf);
|
|
|
|
|
new Float32Array(buf)[BUF_MIN/4-1] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[' + (BUF_MIN/4-1) + ']; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
new Float32Array(buf)[BUF_MIN/8] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[' + (BUF_MIN/8) + ']; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[' + (BUF_MIN/4) + ']; } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
new Float32Array(buf)[61440] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[61440]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Float64Array(buf)[1] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[1]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
new Float64Array(buf)[511] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[511]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
new Float64Array(buf)[512] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[512]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[1024]; } return f'), this, null, buf);
|
|
|
|
|
new Float64Array(buf)[BUF_MIN/8-1] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[' + (BUF_MIN/8-1) + ']; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
new Float64Array(buf)[BUF_MIN/16] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[' + (BUF_MIN/16) + ']; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[' + (BUF_MIN/8) + ']; } return f'), this, null, buf);
|
|
|
|
|
var buf = new ArrayBuffer(262144);
|
|
|
|
|
new Float64Array(buf)[28672] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[28672]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
|
|
|
|
|
// Test bitwise-and optimizations.
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint8Array(buf)[8191] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[8191&8191]|0; } return f'), this, null, buf)(),255);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[(8191&8191)>>0]|0; } return f'), this, null, buf)(),255);
|
|
|
|
@ -448,7 +448,7 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i8[(8191&8191)>>0]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint16Array(buf)[4095] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[(8190&8191)>>1]|0; } return f'), this, null, buf)(),65535);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u16[(8191&8191)>>1]|0; } return f'), this, null, buf)(),65535);
|
|
|
|
@ -458,7 +458,7 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i16[(8191&8191)>>1]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint32Array(buf)[2047] = -1;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(8188&8191)>>2]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[(8191&8191)>>2]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
@ -468,20 +468,20 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(8191&8191)>>2]|0; } return f'), this, null, buf)(),-1);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Float32Array(buf)[2047] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(8188&8191)>>2]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(8191&8191)>>2]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Float64Array(buf)[1023] = -1.0;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8184&8191)>>3]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8191&8191)>>3]; } return f'), this, null, buf)(),-1.0);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Bug 913867
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Int32Array(buf)[0] = 0x55aa5a5a;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(0&0)>>2]|0; } return f'), this, null, buf)(),0x55aa5a5a);
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[(4&0)>>2]|0; } return f'), this, null, buf)(),0x55aa5a5a);
|
|
|
|
@ -495,7 +495,7 @@ assertEq(asmLink(asmCompile('stdlib', 'foreign', 'heap', USE_ASM + "var id=forei
|
|
|
|
|
|
|
|
|
|
// Some literal constant paths.
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>4294967295]|0; } return f');
|
|
|
|
|
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>-1]|0; } return f');
|
|
|
|
|
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>0x80000000]|0; } return f');
|
|
|
|
@ -530,7 +530,7 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'const
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[-2147483648>>2]|0; } return f'), this, null, buf)(),0);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
new Uint8Array(buf)[0] = 0xAA;
|
|
|
|
|
new Uint8Array(buf)[0x5A] = 0xA5;
|
|
|
|
|
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u8[0x5A&4294967295]|0; } return f'), this, null, buf)(),0xA5);
|
|
|
|
@ -570,20 +570,20 @@ assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'functi
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// GVN checks
|
|
|
|
|
var buf = new ArrayBuffer(8192);
|
|
|
|
|
var buf = new ArrayBuffer(BUF_MIN);
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Heap length constraints
|
|
|
|
|
var m = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; return u8[i]|0; } return f');
|
|
|
|
|
assertAsmLinkAlwaysFail(m, this, null, new ArrayBuffer(0x0fff));
|
|
|
|
|
assertEq(asmLink(m, this, null, new ArrayBuffer(0x1000))(0),0);
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0x1010));
|
|
|
|
|
assertEq(asmLink(m, this, null, new ArrayBuffer(0x2000))(0),0);
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe000));
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe010));
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe000));
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xff800));
|
|
|
|
|
assertAsmLinkAlwaysFail(m, this, null, new ArrayBuffer(0xffff));
|
|
|
|
|
assertEq(asmLink(m, this, null, new ArrayBuffer(0x10000))(0),0);
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0x10010));
|
|
|
|
|
assertEq(asmLink(m, this, null, new ArrayBuffer(0x20000))(0),0);
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe0000));
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe0010));
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe0000));
|
|
|
|
|
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xff8000));
|
|
|
|
|
var buf = new ArrayBuffer(0x100000);
|
|
|
|
|
new Uint8Array(buf)[0x4242] = 0xAA;
|
|
|
|
|
var f = asmLink(m, this, null, buf);
|
|
|
|
|