Bug 1176214 - Part 8: jit-test changes. r=bbouvier

--HG--
extra : rebase_source : 1e6de87ce395ba20280becee5e113bc328ef683f
This commit is contained in:
Lars T Hansen 2015-11-23 17:35:06 +01:00
Родитель 6bda1e516c
Коммит 9031bb2c2c
20 изменённых файлов: 98 добавлений и 168 удалений

Просмотреть файл

@ -1,10 +1,6 @@
// Transitional test cases, useful while Odin accepts both
// "Int32Array" and "SharedInt32Array" to construct a view onto shared
// memory but the former only when an atomic operation is referenced,
// as per spec. Eventually it will stop accepting "SharedInt32Array",
// because that name is going away.
// Test the inference of shared memory in asm.js.
//
// These should not run with --no-asmjs.
// These should not be run with --no-asmjs, the guard below checks this.
if (!this.SharedArrayBuffer || !isAsmJSCompilationAvailable())
quit(0);
@ -32,62 +28,6 @@ assertEq(isAsmJSModule(m1), true);
var { f } = m1(this, {}, new SharedArrayBuffer(65536));
assertEq(f(), 37);
//////////////////////////////////////////////////////////////////////
//
// SharedInt8Array can still be used on SharedArrayBuffer.
// (SharedInt8Array will eventually disappear, and this
// test case with it.)
function m2(stdlib, ffi, heap) {
"use asm";
var i8 = new stdlib.SharedInt8Array(heap);
var add = stdlib.Atomics.add;
function g() {
add(i8, 0, 1);
return 42;
}
return { g:g }
}
assertEq(isAsmJSModule(m2), true);
var { g } = m2(this, {}, new SharedArrayBuffer(65536));
assertEq(g(), 42);
//////////////////////////////////////////////////////////////////////
//
// SharedInt8Array still cannot be used on ArrayBuffer, even without
// atomics present.
// (SharedInt8Array will eventually disappear, and this
// test case with it.)
function m3(stdlib, ffi, heap) {
"use asm";
var i8 = new stdlib.SharedInt8Array(heap);
function h() {
return i8[0]|0;
}
return { h:h }
}
// Running the shell with -w you should see an error here.
assertEq(isAsmJSModule(m3), true);
try {
var wasThrown = false;
m3(this, {}, new ArrayBuffer(65536));
}
catch (e) {
wasThrown = true;
}
assertEq(wasThrown, true);
//////////////////////////////////////////////////////////////////////
//
// Int8Array cannot be used on SharedArrayBuffer if atomics are not imported.

Просмотреть файл

@ -7,7 +7,7 @@ load(libdir + "asm.js");
var code = `
"use asm";
var HEAP32 = new stdlib.SharedInt32Array(heap);
var HEAP32 = new stdlib.Int32Array(heap);
var add = stdlib.Atomics.add;
var load = stdlib.Atomics.load;
var _emscripten_asm_const_int=ffi._emscripten_asm_const_int;

Просмотреть файл

@ -1,4 +1,5 @@
// |jit-test| test-also-noasmjs
if (!this.SharedArrayBuffer || !this.Atomics)
quit();
@ -8,27 +9,6 @@ if (!this.SharedArrayBuffer || !this.Atomics)
load(libdir + "asm.js");
load(libdir + "asserts.js");
// This hack allows the test cases to run with --no-asmjs: the field values
// are basically ignored in asm.js mode, and the correct (Firefox-specific)
// field values are used in non-asm.js mode. If run in a non-Firefox
// browser that does not have the parallel type hierarchy this should also
// work.
//
// This hack will be removed when the parallel type hierarchy is removed
// from Firefox, bug 1176214.
const atomicStdlib = {
Atomics: Atomics,
Int8Array: this.SharedInt8Array ? SharedInt8Array : Int8Array,
Uint8Array: this.SharedUint8Array ? SharedUint8Array : Uint8Array,
Int16Array: this.SharedInt16Array ? SharedInt16Array : Int16Array,
Uint16Array: this.SharedUint16Array ? SharedUint16Array : Uint16Array,
Int32Array: this.SharedInt32Array ? SharedInt32Array : Int32Array,
Uint32Array: this.SharedUint32Array ? SharedUint32Array : Uint32Array,
Float32Array: this.SharedFloat32Array ? SharedFloat32Array : Float32Array,
Float64Array: this.SharedFloat64Array ? SharedFloat64Array : Float64Array
};
var loadModule_int32_code =
USE_ASM + `
var atomic_fence = stdlib.Atomics.fence;
@ -253,10 +233,10 @@ var loadModule_int32_code =
var loadModule_int32 = asmCompile('stdlib', 'foreign', 'heap', loadModule_int32_code);
function test_int32(heap) {
var i32a = new SharedInt32Array(heap);
var i32m = asmLink(loadModule_int32, atomicStdlib, {}, heap);
var i32a = new Int32Array(heap);
var i32m = asmLink(loadModule_int32, this, {}, heap);
var size = SharedInt32Array.BYTES_PER_ELEMENT;
var size = Int32Array.BYTES_PER_ELEMENT;
i32m.fence();
@ -536,10 +516,10 @@ var loadModule_uint32_code =
var loadModule_uint32 = asmCompile('stdlib', 'foreign', 'heap', loadModule_uint32_code);
function test_uint32(heap) {
var i32a = new SharedUint32Array(heap);
var i32m = loadModule_uint32(atomicStdlib, {}, heap);
var i32a = new Uint32Array(heap);
var i32m = loadModule_uint32(this, {}, heap);
var size = SharedUint32Array.BYTES_PER_ELEMENT;
var size = Uint32Array.BYTES_PER_ELEMENT;
i32a[0] = 12345;
assertEq(i32m.load(), 12345);
@ -822,10 +802,10 @@ var loadModule_int16_code =
var loadModule_int16 = asmCompile('stdlib', 'foreign', 'heap', loadModule_int16_code);
function test_int16(heap) {
var i16a = new SharedInt16Array(heap);
var i16m = loadModule_int16(atomicStdlib, {}, heap);
var i16a = new Int16Array(heap);
var i16m = loadModule_int16(this, {}, heap);
var size = SharedInt16Array.BYTES_PER_ELEMENT;
var size = Int16Array.BYTES_PER_ELEMENT;
i16m.fence();
@ -1112,10 +1092,10 @@ var loadModule_uint16_code =
var loadModule_uint16 = asmCompile('stdlib', 'foreign', 'heap', loadModule_uint16_code);
function test_uint16(heap) {
var i16a = new SharedUint16Array(heap);
var i16m = loadModule_uint16(atomicStdlib, {}, heap);
var i16a = new Uint16Array(heap);
var i16m = loadModule_uint16(this, {}, heap);
var size = SharedUint16Array.BYTES_PER_ELEMENT;
var size = Uint16Array.BYTES_PER_ELEMENT;
i16a[0] = 12345;
assertEq(i16m.load(), 12345);
@ -1400,13 +1380,13 @@ var loadModule_int8_code =
var loadModule_int8 = asmCompile('stdlib', 'foreign', 'heap', loadModule_int8_code);
function test_int8(heap) {
var i8a = new SharedInt8Array(heap);
var i8m = loadModule_int8(atomicStdlib, {}, heap);
var i8a = new Int8Array(heap);
var i8m = loadModule_int8(this, {}, heap);
for ( var i=0 ; i < i8a.length ; i++ )
i8a[i] = 0;
var size = SharedInt8Array.BYTES_PER_ELEMENT;
var size = Int8Array.BYTES_PER_ELEMENT;
i8a[0] = 123;
assertEq(i8m.load(), 123);
@ -1681,13 +1661,13 @@ var loadModule_uint8_code =
var loadModule_uint8 = asmCompile('stdlib', 'foreign', 'heap', loadModule_uint8_code);
function test_uint8(heap) {
var i8a = new SharedUint8Array(heap);
var i8m = loadModule_uint8(atomicStdlib, {}, heap);
var i8a = new Uint8Array(heap);
var i8m = loadModule_uint8(this, {}, heap);
for ( var i=0 ; i < i8a.length ; i++ )
i8a[i] = 0;
var size = SharedUint8Array.BYTES_PER_ELEMENT;
var size = Uint8Array.BYTES_PER_ELEMENT;
i8a[0] = 123;
assertEq(i8m.load(), 123);
@ -1837,7 +1817,7 @@ var loadModule_misc_code =
var loadModule_misc = asmCompile('stdlib', 'foreign', 'heap', loadModule_misc_code);
function test_misc(heap) {
var misc = loadModule_misc(atomicStdlib, {}, heap);
var misc = loadModule_misc(this, {}, heap);
assertEq(misc.ilf1(), 1);
assertEq(misc.ilf2(), 1);
@ -1851,7 +1831,7 @@ function test_misc(heap) {
assertEq(misc.ilf9(), 0);
}
// SharedUint8ClampedArray is not supported for asm.js.
// Shared-memory Uint8ClampedArray is not supported for asm.js.
var heap = new SharedArrayBuffer(65536);

Просмотреть файл

@ -8,7 +8,7 @@ if (!this.SharedArrayBuffer || !isAsmJSCompilationAvailable())
function m(stdlib, ffi, heap) {
"use asm";
var view = new stdlib.SharedUint32Array(heap);
var view = new stdlib.Uint32Array(heap);
var cas = stdlib.Atomics.compareExchange;
var hi = ffi.hi;
@ -23,7 +23,7 @@ assertEq(isAsmJSModule(m), true);
function nonm(stdlib, ffi, heap) {
var view = new stdlib.SharedUint32Array(heap);
var view = new stdlib.Uint32Array(heap);
var cas = stdlib.Atomics.compareExchange;
var hi = ffi.hi;
@ -35,7 +35,7 @@ function nonm(stdlib, ffi, heap) {
}
var sab = new SharedArrayBuffer(65536);
var ua = new SharedUint32Array(sab);
var ua = new Uint32Array(sab);
var results = [];
var mrun = m(this, {hi: function (x) { results.push(x) }}, sab);
var nonmrun = nonm(this, {hi: function (x) { results.push(x) }}, sab);

Просмотреть файл

@ -5,7 +5,7 @@ load(libdir + "asserts.js");
function m(stdlib, ffi, heap) {
"use asm";
var HEAP32 = new stdlib.SharedInt32Array(heap);
var HEAP32 = new stdlib.Int32Array(heap);
var add = stdlib.Atomics.add;
var load = stdlib.Atomics.load;
function add_sharedEv(i1) {

Просмотреть файл

@ -8,7 +8,7 @@ function loadModule_uint16(stdlib, foreign, heap) {
var atomic_and = stdlib.Atomics.and;
var atomic_or = stdlib.Atomics.or;
var atomic_xor = stdlib.Atomics.xor;
var i16a = new stdlib.SharedUint16Array(heap);
var i16a = new stdlib.Uint16Array(heap);
function do_add_i(i) {
i = i|0;
var v = 0;
@ -43,7 +43,7 @@ function loadModule_uint16(stdlib, foreign, heap) {
function test_uint16(heap) {
var i16m = loadModule_uint16(this, {}, heap);
var size = SharedUint16Array.BYTES_PER_ELEMENT;
var size = Uint16Array.BYTES_PER_ELEMENT;
i16m.add_i(size*40)
i16m.sub_i(size*40)
i16m.and_i(size*40)

Просмотреть файл

@ -369,7 +369,7 @@ function exchangeLoop(ta) {
}
function adHocExchange() {
var a = new SharedInt8Array(16)
var a = new Int8Array(new SharedArrayBuffer(16));
for ( var i=0 ; i < a.length ; i++ )
a[i] = 255;
assertEq(exchangeLoop(a), -100000);
@ -425,8 +425,8 @@ function runTests() {
var sab = new SharedArrayBuffer(4096);
// Test that two arrays created on the same storage alias
var t1 = new SharedInt8Array(sab);
var t2 = new SharedUint16Array(sab);
var t1 = new Int8Array(sab);
var t2 = new Uint16Array(sab);
assertEq(t1[0], 0);
assertEq(t2[0], 0);
@ -438,13 +438,13 @@ function runTests() {
t1[0] = 0;
// Test that invoking as Atomics.whatever() works, on correct arguments.
CLONE(testMethod)(new SharedInt8Array(sab), 0, 42, 4095);
CLONE(testMethod)(new SharedUint8Array(sab), 0, 42, 4095);
CLONE(testMethod)(new SharedUint8ClampedArray(sab), 0, 42, 4095);
CLONE(testMethod)(new SharedInt16Array(sab), 0, 42, 2047);
CLONE(testMethod)(new SharedUint16Array(sab), 0, 42, 2047);
CLONE(testMethod)(new SharedInt32Array(sab), 0, 42, 1023);
CLONE(testMethod)(new SharedUint32Array(sab), 0, 42, 1023);
CLONE(testMethod)(new Int8Array(sab), 0, 42, 4095);
CLONE(testMethod)(new Uint8Array(sab), 0, 42, 4095);
CLONE(testMethod)(new Uint8ClampedArray(sab), 0, 42, 4095);
CLONE(testMethod)(new Int16Array(sab), 0, 42, 2047);
CLONE(testMethod)(new Uint16Array(sab), 0, 42, 2047);
CLONE(testMethod)(new Int32Array(sab), 0, 42, 1023);
CLONE(testMethod)(new Uint32Array(sab), 0, 42, 1023);
// Test that invoking as v = Atomics.whatever; v() works, on correct arguments.
gAtomics_compareExchange = Atomics.compareExchange;
@ -458,17 +458,17 @@ function runTests() {
gAtomics_or = Atomics.or;
gAtomics_xor = Atomics.xor;
CLONE(testFunction)(new SharedInt8Array(sab), 0, 42, 4095);
CLONE(testFunction)(new SharedUint8Array(sab), 0, 42, 4095);
CLONE(testFunction)(new SharedUint8ClampedArray(sab), 0, 42, 4095);
CLONE(testFunction)(new SharedInt16Array(sab), 0, 42, 2047);
CLONE(testFunction)(new SharedUint16Array(sab), 0, 42, 2047);
CLONE(testFunction)(new SharedInt32Array(sab), 0, 42, 1023);
CLONE(testFunction)(new SharedUint32Array(sab), 0, 42, 1023);
CLONE(testFunction)(new Int8Array(sab), 0, 42, 4095);
CLONE(testFunction)(new Uint8Array(sab), 0, 42, 4095);
CLONE(testFunction)(new Uint8ClampedArray(sab), 0, 42, 4095);
CLONE(testFunction)(new Int16Array(sab), 0, 42, 2047);
CLONE(testFunction)(new Uint16Array(sab), 0, 42, 2047);
CLONE(testFunction)(new Int32Array(sab), 0, 42, 1023);
CLONE(testFunction)(new Uint32Array(sab), 0, 42, 1023);
// Test various range and type conditions
var v8 = new SharedInt8Array(sab);
var v32 = new SharedInt32Array(sab);
var v8 = new Int8Array(sab);
var v32 = new Int32Array(sab);
CLONE(testTypeCAS)(v8);
CLONE(testTypeCAS)(v32);
@ -492,10 +492,10 @@ function runTests() {
CLONE(testRangeCAS)(v32);
// Test extreme values
testInt8Extremes(new SharedInt8Array(sab));
testUint8Extremes(new SharedUint8Array(sab));
testInt16Extremes(new SharedInt16Array(sab));
testUint32(new SharedUint32Array(sab));
testInt8Extremes(new Int8Array(sab));
testUint8Extremes(new Uint8Array(sab));
testInt16Extremes(new Int16Array(sab));
testUint32(new Uint32Array(sab));
// Misc ad-hoc tests
adHocExchange();
@ -504,5 +504,5 @@ function runTests() {
testIsLockFree();
}
if (this.Atomics && this.SharedArrayBuffer && this.SharedInt32Array)
if (this.Atomics && this.SharedArrayBuffer)
runTests();

Просмотреть файл

@ -18,11 +18,11 @@ function add(ta) {
return w;
}
if (!this.SharedArrayBuffer || !this.Atomics || !this.SharedInt32Array)
if (!this.SharedArrayBuffer || !this.Atomics)
quit(0);
var sab = new SharedArrayBuffer(4096);
var ia = new SharedInt32Array(sab);
var ia = new Int32Array(sab);
for ( var i=0, limit=ia.length ; i < limit ; i++ )
ia[i] = 37;
var v = 0;

Просмотреть файл

@ -1,8 +1,8 @@
// |jit-test| slow;
//
// Like inline-add, but with SharedUint32Array, which is a special
// case because the value is representable only as a Number.
// All this tests is that the Uint32 path is being triggered.
// Like inline-add, but with Uint32Array, which is a special case
// because the value is representable only as a Number. All this
// tests is that the Uint32 path is being triggered.
//
// This is intended to be run manually with IONFLAGS=logs and
// postprocessing by iongraph to verify manually (by inspecting the
@ -18,11 +18,11 @@ function add(ta) {
return Atomics.add(ta, 86, 6);
}
if (!this.SharedArrayBuffer || !this.Atomics || !this.SharedUint32Array)
if (!this.SharedArrayBuffer || !this.Atomics)
quit(0);
var sab = new SharedArrayBuffer(4096);
var ia = new SharedUint32Array(sab);
var ia = new Uint32Array(sab);
for ( var i=0, limit=ia.length ; i < limit ; i++ )
ia[i] = 0xdeadbeef; // Important: Not an int32-capable value
var v = 0;

Просмотреть файл

@ -18,11 +18,11 @@ function cmpxchg(ta) {
return w;
}
if (!this.SharedArrayBuffer || !this.Atomics || !this.SharedInt32Array)
if (!this.SharedArrayBuffer || !this.Atomics)
quit(0);
var sab = new SharedArrayBuffer(4096);
var ia = new SharedInt32Array(sab);
var ia = new Int32Array(sab);
for ( var i=0, limit=ia.length ; i < limit ; i++ )
ia[i] = 37;
var v = 0;

Просмотреть файл

@ -18,11 +18,11 @@ function fence(ta) {
return w;
}
if (!this.SharedArrayBuffer || !this.Atomics || !this.SharedInt32Array)
if (!this.SharedArrayBuffer || !this.Atomics)
quit(0);
var sab = new SharedArrayBuffer(4096);
var ia = new SharedInt32Array(sab);
var ia = new Int32Array(sab);
for ( var i=0, limit=ia.length ; i < limit ; i++ )
ia[i] = 37;
var v = 0;

Просмотреть файл

@ -39,7 +39,7 @@ const sab = new SharedArrayBuffer(sabLength);
setSharedArrayBuffer(sab);
const iab = new SharedInt32Array(sab);
const iab = new Int32Array(sab);
function testRun(limit) {
console.log("Limit = " + limit);
@ -47,7 +47,7 @@ function testRun(limit) {
// Fork off workers to hammer on memory.
for ( var i=0 ; i < numWorkers ; i++ ) {
evalInWorker(`
const iab = new SharedInt32Array(getSharedArrayBuffer());
const iab = new Int32Array(getSharedArrayBuffer());
const v = 1 << (8 * ${i});
for ( var i=0 ; i < ${limit} ; i++ ) {
for ( var k=0 ; k < ${iterCount} ; k++ ) {

Просмотреть файл

@ -11,7 +11,7 @@
// all platforms
// Bug 1141121 - immediate operand in atomic operations on x86/x64
if (!(this.Atomics && this.SharedArrayBuffer && this.SharedInt8Array))
if (!(this.Atomics && this.SharedArrayBuffer))
quit(0);
var sum = 0;
@ -86,7 +86,7 @@ function g4(ia, k) {
function mod(stdlib, ffi, heap) {
"use asm";
var i8a = new stdlib.SharedInt8Array(heap);
var i8a = new stdlib.Int8Array(heap);
var add = stdlib.Atomics.add;
var sum = 0;
@ -105,7 +105,7 @@ function mod(stdlib, ffi, heap) {
return {f3:f3, g3:g3};
}
var i8a = new SharedInt8Array(65536);
var i8a = new Int8Array(new SharedArrayBuffer(65536));
var { f3, g3 } = mod(this, {}, i8a.buffer);
for ( var i=0 ; i < 10000 ; i++ ) {
f(i8a, i % 10);

Просмотреть файл

@ -5,3 +5,11 @@ for (var i = 0; i < 10; i++) {
new Uint16Array(x).set(JSON.parse)
gcslice()
}
for (var i = 0; i < 10; i++) {
x = new SharedArrayBuffer(4)
x.f = (function() {})
new Uint16Array(x).set(JSON.parse)
gcslice()
}

Просмотреть файл

@ -3,13 +3,13 @@
function $(stdlib, foreign, heap) {
"use asm";
var f64 = new stdlib.SharedFloat64Array(heap);
var f64 = new stdlib.Float64Array(heap);
function f() { var v=0.0; v=+f64[0]; return +v; }
return f
}
if (this.SharedArrayBuffer && this.SharedFloat64Array) {
if (this.SharedArrayBuffer) {
var heap = new SharedArrayBuffer(65536);
(new SharedFloat64Array(heap))[0] = 3.14159;
(new Float64Array(heap))[0] = 3.14159;
assertEq($(this, {}, heap)(), 3.14159);
}

Просмотреть файл

@ -2,9 +2,9 @@
function f() {
var x = new SharedArrayBuffer(0x1000);
var y = new SharedInt32Array(x);
var y = new Int32Array(x);
gc();
}
if (this.SharedArrayBuffer && this.SharedInt32Array)
if (this.SharedArrayBuffer)
f();

Просмотреть файл

@ -2,10 +2,10 @@
function f() {
var x = new SharedArrayBuffer(0x1000);
var y = new SharedInt32Array(x);
var z = new SharedInt8Array(x);
var y = new Int32Array(x);
var z = new Int8Array(x);
gc();
}
if (this.SharedArrayBuffer && this.SharedInt32Array && this.SharedInt8Array)
if (this.SharedArrayBuffer)
f();

Просмотреть файл

@ -14,14 +14,14 @@
// that it contains instructions like "typedarraylength", "loadtypedarrayelement",
// and "storetypedarrayelement".
if (!this.SharedInt32Array)
if (!this.SharedArrayBuffer)
quit();
function f(ta) {
return (ta[2] = ta[0] + ta[1] + ta.length);
}
var v = new SharedInt32Array(1024);
var v = new Int32Array(new SharedArrayBuffer(4096));
var sum = 0;
var iter = 1000;
for ( var i=0 ; i < iter ; i++ )

Просмотреть файл

@ -2,11 +2,11 @@
function f() {
var x = new SharedArrayBuffer(4096);
var y = new SharedInt32Array(x);
var y = new Int32Array(x);
assertEq(y[0], 0);
assertEq(y[1], 0);
assertEq(y[1023], 0);
}
if (this.SharedArrayBuffer && this.SharedInt32Array)
if (this.SharedArrayBuffer)
f();

Просмотреть файл

@ -6,18 +6,20 @@ if (!this.SharedArrayBuffer)
// Original test case
var x = new SharedInt32Array(4);
var sab = new SharedArrayBuffer(4);
var x = new Int32Array(sab);
x.__proto__ = (function(){});
new Uint8Array(x); // Should assert here
new Uint8Array(x); // Would assert here
// Supposedly equivalent test case, provoking the error directly
var x = new SharedInt32Array(4);
var x = new Int32Array(sab);
Object.defineProperty(x, "length", { value: 0 });
new Uint8Array(x); // Should assert here
new Uint8Array(x); // Would assert here
// Derived test case - should not tickle the bug, though.
// Derived test case - would not tickle the bug, though.
var x = new SharedInt32Array(4);
var x = new Int32Array(sab);
Object.defineProperty(x, "length", { value: 1 << 20 });
new Uint8Array(x);