Bug 1054066 - OdinMonkey: issue deprecation warning for heaps less than 64kb (r=dougc)

This commit is contained in:
Luke Wagner 2014-08-21 11:29:30 -05:00
parent 0d214cab50
commit aaf90b1508
13 changed files with 228 additions and 175 deletions

View File

@ -245,6 +245,18 @@ static bool
LinkModuleToHeap(JSContext *cx, AsmJSModule &module, Handle<ArrayBufferObject*> heap) LinkModuleToHeap(JSContext *cx, AsmJSModule &module, Handle<ArrayBufferObject*> heap)
{ {
uint32_t heapLength = heap->byteLength(); uint32_t heapLength = heap->byteLength();
if (IsDeprecatedAsmJSHeapLength(heapLength)) {
LinkFail(cx, "ArrayBuffer byteLengths smaller than 64KB are deprecated and "
"will cause a link-time failure in the future");
// The goal of deprecation is to give apps some time before linking
// fails. However, if warnings-as-errors is turned on (which happens as
// part of asm.js testing) an exception may be raised.
if (cx->isExceptionPending())
return false;
}
if (!IsValidAsmJSHeapLength(heapLength)) { if (!IsValidAsmJSHeapLength(heapLength)) {
ScopedJSFreePtr<char> msg( ScopedJSFreePtr<char> msg(
JS_smprintf("ArrayBuffer byteLength 0x%x is not a valid heap length. The next " JS_smprintf("ArrayBuffer byteLength 0x%x is not a valid heap length. The next "
@ -259,7 +271,7 @@ LinkModuleToHeap(JSContext *cx, AsmJSModule &module, Handle<ArrayBufferObject*>
JS_ASSERT((module.minHeapLength() - 1) <= INT32_MAX); JS_ASSERT((module.minHeapLength() - 1) <= INT32_MAX);
if (heapLength < module.minHeapLength()) { if (heapLength < module.minHeapLength()) {
ScopedJSFreePtr<char> msg( ScopedJSFreePtr<char> msg(
JS_smprintf("ArrayBuffer byteLength of 0x%x is less than 0x%x (which is the" JS_smprintf("ArrayBuffer byteLength of 0x%x is less than 0x%x (which is the "
"largest constant heap access offset rounded up to the next valid " "largest constant heap access offset rounded up to the next valid "
"heap size).", "heap size).",
heapLength, heapLength,

View File

@ -69,8 +69,8 @@ static const size_t AsmJSMappedSize = 4 * 1024ULL * 1024ULL * 1024ULL;
inline uint32_t inline uint32_t
RoundUpToNextValidAsmJSHeapLength(uint32_t length) RoundUpToNextValidAsmJSHeapLength(uint32_t length)
{ {
if (length <= 4096) if (length <= 4 * 1024)
return 4096; return 4 * 1024;
if (length <= 16 * 1024 * 1024) if (length <= 16 * 1024 * 1024)
return mozilla::RoundUpPow2(length); return mozilla::RoundUpPow2(length);
@ -82,7 +82,7 @@ RoundUpToNextValidAsmJSHeapLength(uint32_t length)
inline bool inline bool
IsValidAsmJSHeapLength(uint32_t length) IsValidAsmJSHeapLength(uint32_t length)
{ {
bool valid = length >= 4096 && bool valid = length >= 4 * 1024 &&
(IsPowerOfTwo(length) || (IsPowerOfTwo(length) ||
(length & 0x00ffffff) == 0); (length & 0x00ffffff) == 0);
@ -92,6 +92,14 @@ IsValidAsmJSHeapLength(uint32_t length)
return valid; return valid;
} }
// For now, power-of-2 lengths in this range are accepted, but in the future
// we'll change this to cause link-time failure.
inline bool
IsDeprecatedAsmJSHeapLength(uint32_t length)
{
return length >= 4 * 1024 && length < 64 * 1024 && IsPowerOfTwo(length);
}
// Return whether asm.js optimization is inhibited by the platform or // Return whether asm.js optimization is inhibited by the platform or
// dynamically disabled: // dynamically disabled:
extern bool extern bool

View File

@ -11,7 +11,8 @@ const HEAP_IMPORTS = "const i8=new glob.Int8Array(b);var u8=new glob.Uint8Array(
"const i16=new glob.Int16Array(b);var u16=new glob.Uint16Array(b);"+ "const i16=new glob.Int16Array(b);var u16=new glob.Uint16Array(b);"+
"const i32=new glob.Int32Array(b);var u32=new glob.Uint32Array(b);"+ "const i32=new glob.Int32Array(b);var u32=new glob.Uint32Array(b);"+
"const f32=new glob.Float32Array(b);var f64=new glob.Float64Array(b);"; "const f32=new glob.Float32Array(b);var f64=new glob.Float64Array(b);";
const BUF_64KB = new ArrayBuffer(64 * 1024); const BUF_MIN = 64 * 1024;
const BUF_64KB = new ArrayBuffer(BUF_MIN);
function asmCompile() function asmCompile()
{ {
@ -160,6 +161,34 @@ function assertAsmLinkAlwaysFail(f)
options("werror"); options("werror");
} }
function assertAsmLinkDeprecated(f)
{
if (!isAsmJSCompilationAvailable())
return;
// Verify no error is thrown with warnings off
f.apply(null, Array.slice(arguments, 1));
// Turn on warnings-as-errors
var oldOpts = options("werror");
assertEq(oldOpts.indexOf("werror"), -1);
// Verify an error is thrown
var caught = false;
try {
f.apply(null, Array.slice(arguments, 1));
} catch (e) {
// Arbitrary code an run in the GetProperty, so don't assert any
// particular string
caught = true;
}
if (!caught)
throw new Error("Didn't catch the link failure error");
// Turn warnings-as-errors back off
options("werror");
}
// Linking should throw a warning-as-error but otherwise run fine // Linking should throw a warning-as-error but otherwise run fine
function asmLink(f) function asmLink(f)
{ {

View File

@ -28,7 +28,7 @@ var F = (function (stdlib, n, heap) {
}); });
var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F)); var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F));
asmLink(compiled, this, null, new ArrayBuffer(4096))(); asmLink(compiled, this, null, new ArrayBuffer(BUF_MIN))();
var F = (function(stdlib, n, heap) { var F = (function(stdlib, n, heap) {
var Float64ArrayView = new stdlib.Float64Array(heap) var Float64ArrayView = new stdlib.Float64Array(heap)
@ -39,7 +39,7 @@ var F = (function(stdlib, n, heap) {
}); });
var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F)); var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F));
asmLink(compiled, this, null, new ArrayBuffer(4096))(); asmLink(compiled, this, null, new ArrayBuffer(BUF_MIN))();
function test0(x) function test0(x)
{ {

View File

@ -53,20 +53,27 @@ assertAsmLinkAlwaysFail(asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; fun
assertEq(asmLink(asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; function f(i,j) {i=i|0;j=j|0; return im(i,j)|0} return f'), {Math:{imul:Math.imul}})(2,3), 6); assertEq(asmLink(asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; function f(i,j) {i=i|0;j=j|0; return im(i,j)|0} return f'), {Math:{imul:Math.imul}})(2,3), 6);
assertEq(asmLink(asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; function f(i,j) {i=i|0;j=j|0; return im(i,j)|0} return f'), this)(8,4), 32); assertEq(asmLink(asmCompile('glob', USE_ASM + 'var im=glob.Math.imul; function f(i,j) {i=i|0;j=j|0; return im(i,j)|0} return f'), this)(8,4), 32);
assertAsmLinkAlwaysFail(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), null, null); var module = asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f');
assertAsmLinkAlwaysFail(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, null); assertAsmLinkAlwaysFail(module, null, null);
assertAsmLinkAlwaysFail(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, null); assertAsmLinkAlwaysFail(module, this, null, null);
assertAsmLinkAlwaysFail(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, new ArrayBuffer(1)); assertAsmLinkAlwaysFail(module, this, null, null);
assertAsmLinkFail(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, new ArrayBuffer(100)); assertAsmLinkAlwaysFail(module, this, null, new ArrayBuffer(1));
assertAsmLinkFail(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, new ArrayBuffer(4000)); assertAsmLinkFail(module, this, null, new ArrayBuffer(4));
assertEq(asmLink(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, new ArrayBuffer(4096))(), undefined); assertAsmLinkFail(module, this, null, new ArrayBuffer(100));
assertEq(asmLink(asmCompile('glob','i','b', USE_ASM + 'var i32=new glob.Int32Array(b); function f(){} return f'), this, null, new ArrayBuffer(2*4096))(), undefined); assertAsmLinkFail(module, this, null, new ArrayBuffer(4092));
assertAsmLinkFail(module, this, null, new ArrayBuffer(64000));
assertAsmLinkFail(module, this, null, new ArrayBuffer(BUF_MIN+4));
assertAsmLinkDeprecated(module, this, null, new ArrayBuffer(4096));
assertAsmLinkDeprecated(module, this, null, new ArrayBuffer(2*4096));
assertAsmLinkDeprecated(module, this, null, new ArrayBuffer(4*4096));
assertAsmLinkDeprecated(module, this, null, new ArrayBuffer(32*1024));
assertEq(asmLink(module, this, null, new ArrayBuffer(BUF_MIN))(), undefined);
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i]|0; return i|0}; return f'); assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i]|0; return i|0}; return f');
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>1]|0; return i|0}; return f'); assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>1]|0; return i|0}; return f');
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>1]|0; return i|0}; return f'); assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>1]|0; return i|0}; return f');
assertAsmLinkAlwaysFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>2]|0; return i|0}; return f'), this, null, new ArrayBuffer(4095)); assertAsmLinkAlwaysFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>2]|0; return i|0}; return f'), this, null, new ArrayBuffer(BUF_MIN-1));
assertEq(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>2]|0; return i|0}; return f')(this, null, new ArrayBuffer(4096))(), 0); assertEq(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i = i32[i>>2]|0; return i|0}; return f')(this, null, new ArrayBuffer(BUF_MIN))(), 0);
var exp = asmLink(asmCompile(USE_ASM + "return {}")); var exp = asmLink(asmCompile(USE_ASM + "return {}"));
assertEq(Object.keys(exp).length, 0); assertEq(Object.keys(exp).length, 0);

View File

@ -96,7 +96,7 @@ assertEq(asmLink(asmCompileCached(USE_ASM + "function f1() { return 1 } function
assertEq(asmLink(asmCompileCached("g", USE_ASM + "var s=g.Math.sin; function f(d) { d=+d; return +s(d) } return f"), this)(.3), Math.sin(.3)); assertEq(asmLink(asmCompileCached("g", USE_ASM + "var s=g.Math.sin; function f(d) { d=+d; return +s(d) } return f"), this)(.3), Math.sin(.3));
assertEq(asmLink(asmCompileCached("g","ffis", USE_ASM + "var ffi=ffis.ffi; function f(i) { i=i|0; return ffi(i|0)|0 } return f"), null, {ffi:function(i){return i+2}})(1), 3); assertEq(asmLink(asmCompileCached("g","ffis", USE_ASM + "var ffi=ffis.ffi; function f(i) { i=i|0; return ffi(i|0)|0 } return f"), null, {ffi:function(i){return i+2}})(1), 3);
assertEq(asmLink(asmCompileCached("g","ffis", USE_ASM + "var x=ffis.x|0; function f() { return x|0 } return f"), null, {x:43})(), 43); assertEq(asmLink(asmCompileCached("g","ffis", USE_ASM + "var x=ffis.x|0; function f() { return x|0 } return f"), null, {x:43})(), 43);
var i32 = new Int32Array(4096); var i32 = new Int32Array(BUF_MIN/4);
i32[4] = 42; i32[4] = 42;
assertEq(asmLink(asmCompileCached("g","ffis","buf", USE_ASM + "var i32=new g.Int32Array(buf); function f(i) { i=i|0; return i32[i>>2]|0 } return f"), this, null, i32.buffer)(4*4), 42); assertEq(asmLink(asmCompileCached("g","ffis","buf", USE_ASM + "var i32=new g.Int32Array(buf); function f(i) { i=i|0; return i32[i>>2]|0 } return f"), this, null, i32.buffer)(4*4), 42);
assertEq(asmLink(asmCompileCached('glob', USE_ASM + 'var x=glob.Math.PI; function f() { return +x } return f'), this)(), Math.PI); assertEq(asmLink(asmCompileCached('glob', USE_ASM + 'var x=glob.Math.PI; function f() { return +x } return f'), this)(), Math.PI);

View File

@ -5,9 +5,9 @@ assertEq(asmLink(code)(), 42);
assertEq(asmLink(code)(), 42); assertEq(asmLink(code)(), 42);
var code = asmCompile('glob', 'ffis', 'buf', USE_ASM + 'var i32=new glob.Int32Array(buf); function g() { return i32[0]|0 } return g'); var code = asmCompile('glob', 'ffis', 'buf', USE_ASM + 'var i32=new glob.Int32Array(buf); function g() { return i32[0]|0 } return g');
var i32_1 = new Int32Array(4096); var i32_1 = new Int32Array(BUF_MIN/4);
i32_1[0] = 42; i32_1[0] = 42;
var i32_2 = new Int32Array(4096); var i32_2 = new Int32Array(BUF_MIN/4);
i32_2[0] = 13; i32_2[0] = 13;
assertEq(asmLink(code, this, null, i32_1.buffer)(), 42); assertEq(asmLink(code, this, null, i32_1.buffer)(), 42);
assertEq(asmLink(code, this, null, i32_2.buffer)(), 13); assertEq(asmLink(code, this, null, i32_2.buffer)(), 13);

View File

@ -279,7 +279,7 @@ assertEq(asmLink(asmCompile(USE_ASM + "function f() { return (4 | (2 == 2))|0 }
assertEq(asmLink(asmCompile(USE_ASM + "function f() { return (4 | (!2))|0 } return f"))(), 4); assertEq(asmLink(asmCompile(USE_ASM + "function f() { return (4 | (!2))|0 } return f"))(), 4);
// get that order-of-operations right! // get that order-of-operations right!
var buf = new ArrayBuffer(4096); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob','imp','buf', USE_ASM + "var i32=new glob.Int32Array(buf); var x=0; function a() { return x|0 } function b() { x=42; return 0 } function f() { i32[((b()|0) & 0x3) >> 2] = a()|0 } return f"), this, null, buf)(); asmLink(asmCompile('glob','imp','buf', USE_ASM + "var i32=new glob.Int32Array(buf); var x=0; function a() { return x|0 } function b() { x=42; return 0 } function f() { i32[((b()|0) & 0x3) >> 2] = a()|0 } return f"), this, null, buf)();
assertEq(new Int32Array(buf)[0], 42); assertEq(new Int32Array(buf)[0], 42);

View File

@ -2,7 +2,7 @@ load(libdir + "asm.js");
const TO_FLOAT32 = "var toF = glob.Math.fround;"; const TO_FLOAT32 = "var toF = glob.Math.fround;";
const HEAP32 = "var f32 = new glob.Float32Array(heap);"; const HEAP32 = "var f32 = new glob.Float32Array(heap);";
const HEAP64 = "var f64 = new glob.Float64Array(heap);" const HEAP64 = "var f64 = new glob.Float64Array(heap);"
var heap = new ArrayBuffer(4096); var heap = new ArrayBuffer(BUF_MIN);
// Module linking // Module linking
assertAsmLinkAlwaysFail(asmCompile('glob', USE_ASM + TO_FLOAT32 + "function f() {} return f"), null); assertAsmLinkAlwaysFail(asmCompile('glob', USE_ASM + TO_FLOAT32 + "function f() {} return f"), null);

View File

@ -94,7 +94,7 @@ var {f,g} = asmLink(asmCompile(USE_ASM + "function f() { return 3.5 } function g
assertEq(f(), 3.5); assertEq(f(), 3.5);
assertEq(g(1), 1+3.5); assertEq(g(1), 1+3.5);
var buf = new ArrayBuffer(4096); var buf = new ArrayBuffer(BUF_MIN);
var f64 = new Float64Array(buf); var f64 = new Float64Array(buf);
var i32 = new Int32Array(buf); var i32 = new Int32Array(buf);
var u32 = new Uint32Array(buf); var u32 = new Uint32Array(buf);

View File

@ -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>>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>>1]|0 }; return f');
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return i32[0>>4]|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 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); assertEq(f(0), 0);
setCachingEnabled(true); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),-1); assertEq(f(0xff),-1);
@ -35,11 +35,11 @@ assertEq(f(0x100),0);
// Cloned modules should fail on linking if the initial module has // Cloned modules should fail on linking if the initial module has
// been compiled with signals but signals are deactivated. // 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'); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),-1); assertEq(f(0xff),-1);
@ -54,97 +54,97 @@ assertEq(f(0x100),0);
setCachingEnabled(false); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),0xff); assertEq(f(0xff),0xff);
assertEq(f(0x100),0); 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 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(0),0);
assertEq(f(0x7fff),0x7fff); assertEq(f(0x7fff),0x7fff);
assertEq(f(0xffff),-1); assertEq(f(0xffff),-1);
assertEq(f(0x10000),0); 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 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(0),0);
assertEq(f(0x7fff),0x7fff); assertEq(f(0x7fff),0x7fff);
assertEq(f(0xffff),0xffff); assertEq(f(0xffff),0xffff);
assertEq(f(0x10000),0); 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 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(0),0);
assertEq(f(0x7fffffff),0x7fffffff); assertEq(f(0x7fffffff),0x7fffffff);
assertEq(f(0xffffffff),-1); assertEq(f(0xffffffff),-1);
assertEq(f(0x100000000),0); 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 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(0),0);
assertEq(f(0x7fffffff),0x7fffffff); assertEq(f(0x7fffffff),0x7fffffff);
assertEq(f(0xffffffff),-1); assertEq(f(0xffffffff),-1);
assertEq(f(0x100000000),0); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),-1); assertEq(f(0xff),-1);
assertEq(f(0x100),0); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),0xff); assertEq(f(0xff),0xff);
assertEq(f(0x100),0); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),-1); assertEq(f(0xff),-1);
assertEq(f(0x100),0); 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 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(0),0);
assertEq(f(0x7f),0x7f); assertEq(f(0x7f),0x7f);
assertEq(f(0xff),0xff); assertEq(f(0xff),0xff);
assertEq(f(0x100),0); 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 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(0, 1.3), 1);
assertEq(f(4088, 2.5), 2); assertEq(f(BUF_MIN-8, 2.5), 2);
assertEq(f(4096, 3.8), 0); 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 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(0, 1.3), 1);
assertEq(f(4088, 2.5), 2); assertEq(f(BUF_MIN-8, 2.5), 2);
assertEq(f(4096, 3.8), 0); 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 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(0, 1.3), 1.3);
assertEq(f(4088, 2.5), 2.5); assertEq(f(BUF_MIN-8, 2.5), 2.5);
assertEq(f(4096, 3.8), NaN); assertEq(f(BUF_MIN, 3.8), NaN);
var i32 = new Int32Array(4096); var i32 = new Int32Array(BUF_MIN);
i32[0] = 42; i32[0] = 42;
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1] = i32[0] }; return f'), this, null, i32.buffer)(); 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); assertEq(i32[1], 42);
var f64 = new Float64Array(4096); var f64 = new Float64Array(BUF_MIN);
f64[0] = 42; f64[0] = 42;
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1] = f64[0] }; return f'), this, null, f64.buffer)(); 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); assertEq(f64[1], 42);
var i32 = new Int32Array(4096/4); var i32 = new Int32Array(BUF_MIN/4);
i32[0] = 13; i32[0] = 13;
i32[1] = 0xfffeeee; 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); 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'); 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'); 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); 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); 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); 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. // 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)(); 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)[0], 0);
assertEq(new Uint8Array(buf)[1], 255); assertEq(new Uint8Array(buf)[1], 255);
assertEq(new Uint8Array(buf)[2], 0); 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)(); 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)[4094], 0);
assertEq(new Uint8Array(buf)[4095], 255); assertEq(new Uint8Array(buf)[4095], 255);
assertEq(new Uint8Array(buf)[4096], 0); 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)(); 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)[4095], 0);
assertEq(new Uint8Array(buf)[4096], 255); assertEq(new Uint8Array(buf)[4096], 255);
assertEq(new Uint8Array(buf)[4097], 0); 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); var buf = new ArrayBuffer(262144);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[258048] = -1 } return f'), this, null, buf)(); 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)[258047], 0);
assertEq(new Uint8Array(buf)[258048], 255); assertEq(new Uint8Array(buf)[258048], 255);
assertEq(new Uint8Array(buf)[258049], 0); 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)(); 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)[0], 0);
assertEq(new Int8Array(buf)[1], -1); assertEq(new Int8Array(buf)[1], -1);
assertEq(new Int8Array(buf)[2], 0); 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)(); 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)[4094], 0);
assertEq(new Int8Array(buf)[4095], -1); assertEq(new Int8Array(buf)[4095], -1);
assertEq(new Int8Array(buf)[4096], 0); 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)(); 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)[4095], 0);
assertEq(new Int8Array(buf)[4096], -1); assertEq(new Int8Array(buf)[4096], -1);
assertEq(new Int8Array(buf)[4097], 0); 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); var buf = new ArrayBuffer(262144);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[258048] = -1 } return f'), this, null, buf)(); 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)[258047], 0);
assertEq(new Int8Array(buf)[258048], -1); assertEq(new Int8Array(buf)[258048], -1);
assertEq(new Int8Array(buf)[258049], 0); 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)(); 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)[0], 0);
assertEq(new Uint16Array(buf)[1], 65535); assertEq(new Uint16Array(buf)[1], 65535);
assertEq(new Uint16Array(buf)[2], 0); assertEq(new Uint16Array(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() { u16[2047] = -1 } return f'), this, null, buf)(); 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)[2046], 0); assertEq(new Uint16Array(buf)[BUF_MIN/2-2], 0);
assertEq(new Uint16Array(buf)[2047], 65535); assertEq(new Uint16Array(buf)[BUF_MIN/2-1], 65535);
assertEq(new Uint16Array(buf)[2048], 0); assertEq(new Uint16Array(buf)[BUF_MIN/2], undefined);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[2048] = -1 } return f'), this, null, buf)(); 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)[2047], 0); assertEq(new Uint16Array(buf)[BUF_MIN/4-1], 0);
assertEq(new Uint16Array(buf)[2048], 65535); assertEq(new Uint16Array(buf)[BUF_MIN/4], 65535);
assertEq(new Uint16Array(buf)[2049], 0); assertEq(new Uint16Array(buf)[BUF_MIN/4+1], 0);
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[4096] = -1 } return f'), this, null, buf); 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); var buf = new ArrayBuffer(262144);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[126976] = -1 } return f'), this, null, buf)(); 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)[126975], 0);
assertEq(new Uint16Array(buf)[126976], 65535); assertEq(new Uint16Array(buf)[126976], 65535);
assertEq(new Uint16Array(buf)[126977], 0); 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)(); 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)[0], 0);
assertEq(new Int16Array(buf)[1], -1); assertEq(new Int16Array(buf)[1], -1);
assertEq(new Int16Array(buf)[2], 0); assertEq(new Int16Array(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() { i16[2047] = -1 } return f'), this, null, buf)(); 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)[2046], 0); assertEq(new Int16Array(buf)[BUF_MIN/2-2], 0);
assertEq(new Int16Array(buf)[2047], -1); assertEq(new Int16Array(buf)[BUF_MIN/2-1], -1);
assertEq(new Int16Array(buf)[2048], 0); assertEq(new Int16Array(buf)[BUF_MIN/2], undefined);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[2048] = -1 } return f'), this, null, buf)(); 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)[2047], 0); assertEq(new Int16Array(buf)[BUF_MIN/4-1], 0);
assertEq(new Int16Array(buf)[2048], -1); assertEq(new Int16Array(buf)[BUF_MIN/4], -1);
assertEq(new Int16Array(buf)[2049], 0); assertEq(new Int16Array(buf)[BUF_MIN/4+1], 0);
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[4096] = -1 } return f'), this, null, buf); 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); var buf = new ArrayBuffer(262144);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[126976] = -1 } return f'), this, null, buf)(); 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)[126975], 0);
assertEq(new Int16Array(buf)[126976], -1); assertEq(new Int16Array(buf)[126976], -1);
assertEq(new Int16Array(buf)[126977], 0); 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)(); 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)[0], 0);
assertEq(new Uint32Array(buf)[1], 4294967295); assertEq(new Uint32Array(buf)[1], 4294967295);
assertEq(new Uint32Array(buf)[2], 0); assertEq(new Uint32Array(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() { u32[1023] = -1 } return f'), this, null, buf)(); 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)[1022], 0); assertEq(new Uint32Array(buf)[BUF_MIN/4-2], 0);
assertEq(new Uint32Array(buf)[1023], 4294967295); assertEq(new Uint32Array(buf)[BUF_MIN/4-1], 4294967295);
assertEq(new Uint32Array(buf)[1024], 0); assertEq(new Uint32Array(buf)[BUF_MIN/4], undefined);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[1024] = -1 } return f'), this, null, buf)(); 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)[1023], 0); assertEq(new Uint32Array(buf)[BUF_MIN/8-1], 0);
assertEq(new Uint32Array(buf)[1024], 4294967295); assertEq(new Uint32Array(buf)[BUF_MIN/8], 4294967295);
assertEq(new Uint32Array(buf)[1025], 0); assertEq(new Uint32Array(buf)[BUF_MIN/8+1], 0);
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[2048] = -1 } return f'), this, null, buf); 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); var buf = new ArrayBuffer(262144);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[61440] = -1 } return f'), this, null, buf)(); 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)[61439], 0);
assertEq(new Uint32Array(buf)[61440], 4294967295); assertEq(new Uint32Array(buf)[61440], 4294967295);
assertEq(new Uint32Array(buf)[61441], 0); 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)(); 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)[0], 0);
assertEq(new Int32Array(buf)[1], -1); assertEq(new Int32Array(buf)[1], -1);
assertEq(new Int32Array(buf)[2], 0); assertEq(new Int32Array(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() { i32[1023] = -1 } return f'), this, null, buf)(); 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)[1022], 0); assertEq(new Int32Array(buf)[BUF_MIN/4-2], 0);
assertEq(new Int32Array(buf)[1023], -1); assertEq(new Int32Array(buf)[BUF_MIN/4-1], -1);
assertEq(new Int32Array(buf)[124], 0); assertEq(new Int32Array(buf)[BUF_MIN/4], undefined);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[1024] = -1 } return f'), this, null, buf)(); 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)[1023], 0); assertEq(new Int32Array(buf)[BUF_MIN/8-1], 0);
assertEq(new Int32Array(buf)[1024], -1); assertEq(new Int32Array(buf)[BUF_MIN/8], -1);
assertEq(new Int32Array(buf)[1025], 0); assertEq(new Int32Array(buf)[BUF_MIN/8+1], 0);
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[2048] = -1 } return f'), this, null, buf); 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); var buf = new ArrayBuffer(262144);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[61440] = -1 } return f'), this, null, buf)(); 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)[61439], 0);
assertEq(new Int32Array(buf)[61440], -1); assertEq(new Int32Array(buf)[61440], -1);
assertEq(new Int32Array(buf)[61441], 0); 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)(); 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 Int32Array(buf)[0], 0);
assertEq(new Float32Array(buf)[1], -1.0); assertEq(new Float32Array(buf)[1], -1.0);
assertEq(new Int32Array(buf)[2], 0); assertEq(new Int32Array(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() { f32[1023] = -1.0 } return f'), this, null, buf)(); 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)[1022], 0); assertEq(new Int32Array(buf)[BUF_MIN/4-2], 0);
assertEq(new Float32Array(buf)[1023], -1.0); assertEq(new Float32Array(buf)[BUF_MIN/4-1], -1.0);
assertEq(new Int32Array(buf)[124], 0); assertEq(new Int32Array(buf)[BUF_MIN/4], undefined);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[1024] = -1.0 } return f'), this, null, buf)(); 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)[1023], 0); assertEq(new Int32Array(buf)[BUF_MIN/8-1], 0);
assertEq(new Float32Array(buf)[1024], -1.0); assertEq(new Float32Array(buf)[BUF_MIN/8], -1.0);
assertEq(new Int32Array(buf)[1025], 0); assertEq(new Int32Array(buf)[BUF_MIN/8+1], 0);
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f32[2048] = -1.0 } return f'), this, null, buf); 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); 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)(); 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)[61439], 0.0);
assertEq(new Float32Array(buf)[61440], -1.0); assertEq(new Float32Array(buf)[61440], -1.0);
assertEq(new Float32Array(buf)[61441], 0.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)(); 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)[0], 0.0);
assertEq(new Float64Array(buf)[1], -1.0); assertEq(new Float64Array(buf)[1], -1.0);
assertEq(new Float64Array(buf)[2], 0.0); assertEq(new Float64Array(buf)[2], 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[511] = -1.0 } return f'), this, null, buf)(); 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)[510], 0.0); assertEq(new Float64Array(buf)[BUF_MIN/8-2], 0.0);
assertEq(new Float64Array(buf)[511], -1.0); assertEq(new Float64Array(buf)[BUF_MIN/8-1], -1.0);
assertEq(new Float64Array(buf)[512], 0.0); assertEq(new Float64Array(buf)[BUF_MIN/8], undefined);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[512] = -1.0 } return f'), this, null, buf)(); 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)[511], 0.0); assertEq(new Float64Array(buf)[BUF_MIN/16-1], 0.0);
assertEq(new Float64Array(buf)[512], -1.0); assertEq(new Float64Array(buf)[BUF_MIN/16], -1.0);
assertEq(new Float64Array(buf)[513], 0.0); assertEq(new Float64Array(buf)[BUF_MIN/16+1], 0.0);
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { f64[1024] = -1.0 } return f'), this, null, buf); 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); 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)(); 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); 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); assertEq(new Float64Array(buf)[28673], 0.0);
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
new Uint8Array(buf)[1] = -1; 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); 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; 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; 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); 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; 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); 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; 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; 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); 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; 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); 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; new Int32Array(buf)[1] = -1;
@ -412,32 +412,32 @@ var buf = new ArrayBuffer(262144);
new Int32Array(buf)[61440] = -1; 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); 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; 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); 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; new Float32Array(buf)[BUF_MIN/4-1] = -1.0;
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1023]; } return f'), this, null, buf)(),-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)[1024] = -1.0; new Float32Array(buf)[BUF_MIN/8] = -1.0;
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[1024]; } return f'), this, null, buf)(),-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[2048]; } return f'), this, null, buf); 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); var buf = new ArrayBuffer(262144);
new Float32Array(buf)[61440] = -1.0; 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); 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; 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); 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; new Float64Array(buf)[BUF_MIN/8-1] = -1.0;
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[511]; } return f'), this, null, buf)(),-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)[512] = -1.0; new Float64Array(buf)[BUF_MIN/16] = -1.0;
assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[512]; } return f'), this, null, buf)(),-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[1024]; } return f'), this, null, buf); 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); var buf = new ArrayBuffer(262144);
new Float64Array(buf)[28672] = -1.0; 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); 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. // Test bitwise-and optimizations.
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
new Uint8Array(buf)[8191] = -1; 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; } 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); 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() { 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] = -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); 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; 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[(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); 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() { 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); 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; 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[(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); 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() { 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); 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; 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[(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() { 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); 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; 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[(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() { 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); 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 // Bug 913867
var buf = new ArrayBuffer(8192); var buf = new ArrayBuffer(BUF_MIN);
new Int32Array(buf)[0] = 0x55aa5a5a; 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[(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); 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. // 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>>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>>-1]|0; } return f');
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return u32[0>>0x80000000]|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 + '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); 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)[0] = 0xAA;
new Uint8Array(buf)[0x5A] = 0xA5; 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); 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); 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 // 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]; 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); 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 // 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'); 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)); assertAsmLinkAlwaysFail(m, this, null, new ArrayBuffer(0xffff));
assertEq(asmLink(m, this, null, new ArrayBuffer(0x1000))(0),0); assertEq(asmLink(m, this, null, new ArrayBuffer(0x10000))(0),0);
assertAsmLinkFail(m, this, null, new ArrayBuffer(0x1010)); assertAsmLinkFail(m, this, null, new ArrayBuffer(0x10010));
assertEq(asmLink(m, this, null, new ArrayBuffer(0x2000))(0),0); assertEq(asmLink(m, this, null, new ArrayBuffer(0x20000))(0),0);
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe000)); assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe0000));
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe010)); assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe0010));
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe000)); assertAsmLinkFail(m, this, null, new ArrayBuffer(0xfe0000));
assertAsmLinkFail(m, this, null, new ArrayBuffer(0xff800)); assertAsmLinkFail(m, this, null, new ArrayBuffer(0xff8000));
var buf = new ArrayBuffer(0x100000); var buf = new ArrayBuffer(0x100000);
new Uint8Array(buf)[0x4242] = 0xAA; new Uint8Array(buf)[0x4242] = 0xAA;
var f = asmLink(m, this, null, buf); var f = asmLink(m, this, null, buf);

View File

@ -20,7 +20,7 @@ var body =
}\ }\
return g;'; return g;';
var buf=new ArrayBuffer(4096); var buf=new ArrayBuffer(BUF_MIN);
var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf); var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf);
assertEq(g(1,2,3), 46); assertEq(g(1,2,3), 46);
assertEq(new Int8Array(buf)[1], 7); assertEq(new Int8Array(buf)[1], 7);
@ -45,7 +45,7 @@ var body =
}\ }\
return g;'; return g;';
var buf=new ArrayBuffer(4096); var buf=new ArrayBuffer(BUF_MIN);
var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf); var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf);
assertEq(g(1,2,3), 46); assertEq(g(1,2,3), 46);
assertEq(new Int8Array(buf)[1], 9); assertEq(new Int8Array(buf)[1], 9);
@ -71,7 +71,7 @@ var body =
}\ }\
return g;'; return g;';
var buf=new ArrayBuffer(4096); var buf=new ArrayBuffer(BUF_MIN);
var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf); var g = asmLink(asmCompile('global','foreign','buffer',body), this, null, buf);
assertEq(g(1,2,3), 63); assertEq(g(1,2,3), 63);
assertEq(new Int8Array(buf)[1], 17); assertEq(new Int8Array(buf)[1], 17);

View File

@ -4,7 +4,7 @@ setIonCheckGraphCoherency(false);
setCachingEnabled(false); setCachingEnabled(false);
// constants // constants
var buf = new ArrayBuffer(4096); var buf = new ArrayBuffer(BUF_MIN);
// An unshifted literal constant byte index in the range 0 to 2^31-1 inclusive should give a link failure. // An unshifted literal constant byte index in the range 0 to 2^31-1 inclusive should give a link failure.
assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.Int8Array(b); function f() {return arr[0x7fffffff]|0 } return f'), this, null, buf); assertAsmLinkFail(asmCompile('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.Int8Array(b); function f() {return arr[0x7fffffff]|0 } return f'), this, null, buf);
@ -46,15 +46,15 @@ assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.Int32Array(b);
// Folded non-intish constant expressions should cause an error compiling. // Folded non-intish constant expressions should cause an error compiling.
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.Int8Array(b); function f() {return arr[0xffffffff+1]|0 } return f'); assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.Int8Array(b); function f() {return arr[0xffffffff+1]|0 } return f');
var ab = new ArrayBuffer(BUF_MIN);
var arr = new Int32Array(BUF_MIN);
for (var i = 0; i < arr.length; i++)
arr[i] = i;
function testInt(ctor, shift, scale, disp) { function testInt(ctor, shift, scale, disp) {
var ab = new ArrayBuffer(4096);
var arr = new ctor(ab); var arr = new ctor(ab);
for (var i = 0; i < arr.length; i++)
arr[i] = i;
var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.' + ctor.name + '(b); function f(i) {i=i|0; return arr[((i<<' + scale + ')+' + disp + ')>>' + shift + ']|0 } return f'), this, null, ab); var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.' + ctor.name + '(b); function f(i) {i=i|0; return arr[((i<<' + scale + ')+' + disp + ')>>' + shift + ']|0 } return f'), this, null, ab);
for (var i of [0,1,2,3,4,1023,1024,1025,4095,4096,4097]) for (var i of [0,1,2,3,4,1023,1024,1025,BUF_MIN-2,BUF_MIN-1,BUF_MIN,BUF_MIN+1])
assertEq(f(i), arr[((i<<scale)+disp)>>shift]|0); assertEq(f(i), arr[((i<<scale)+disp)>>shift]|0);
for (var i of [-Math.pow(2,28),Math.pow(2,28),-Math.pow(2,29),Math.pow(2,29),-Math.pow(2,30),Math.pow(2,30),-Math.pow(2,31),Math.pow(2,31),-Math.pow(2,32),Math.pow(2,32)]) { for (var i of [-Math.pow(2,28),Math.pow(2,28),-Math.pow(2,29),Math.pow(2,29),-Math.pow(2,30),Math.pow(2,30),-Math.pow(2,31),Math.pow(2,31),-Math.pow(2,32),Math.pow(2,32)]) {
@ -83,12 +83,9 @@ function testInt(ctor, shift, scale, disp) {
} }
function testFloat(ctor, shift, scale, disp, coercion) { function testFloat(ctor, shift, scale, disp, coercion) {
var ab = new ArrayBuffer(4096);
var arr = new ctor(ab); var arr = new ctor(ab);
for (var i = 0; i < arr.length; i++)
arr[i] = i;
var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.' + ctor.name + '(b); var toF = glob.Math.fround; function f(i) {i=i|0; return ' + coercion + '(arr[((i<<' + scale + ')+' + disp + ')>>' + shift + ']) } return f'), this, null, ab); var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + 'var arr=new glob.' + ctor.name + '(b); var toF = glob.Math.fround; function f(i) {i=i|0; return ' + coercion + '(arr[((i<<' + scale + ')+' + disp + ')>>' + shift + ']) } return f'), this, null, ab);
for (var i of [0,1,2,3,4,1023,1024,1025,4095,4096,4097]) for (var i of [0,1,2,3,4,1023,1024,1025,BUF_MIN-2,BUF_MIN-1,BUF_MIN,BUF_MIN+1])
assertEq(f(i), +arr[((i<<scale)+disp)>>shift]); assertEq(f(i), +arr[((i<<scale)+disp)>>shift]);
for (var i of [-Math.pow(2,31), Math.pow(2,31)-1, Math.pow(2,32)]) { for (var i of [-Math.pow(2,31), Math.pow(2,31)-1, Math.pow(2,32)]) {