Bug 1250556: Require Store value expression to have the opcode's type; r=sunfish

MozReview-Commit-ID: 3O5O0t1M5SN
This commit is contained in:
Benjamin Bouvier 2016-02-23 19:45:38 +01:00
parent f6394d9555
commit 74980cc73a
4 changed files with 10 additions and 16 deletions

View File

@ -381,7 +381,7 @@ static bool
DecodeStore(FunctionDecoder& f, ExprType expected, ExprType type)
{
return DecodeLoadStoreAddress(f) &&
DecodeExpr(f, expected) &&
DecodeExpr(f, type) &&
CheckType(f, type, expected);
}

View File

@ -3,11 +3,6 @@ load(libdir + "wasm.js");
if (!wasmIsSupported())
quit();
function mismatchError(actual, expect) {
var str = "type mismatch: expression has type " + actual + " but expected " + expect;
return RegExp(str);
}
function testConst(type, str, expect) {
assertEq(wasmEvalText('(module (func (result ' + type + ') (' + type + '.const ' + str + ')) (export "" 0))')(), expect);
}

View File

@ -3,11 +3,6 @@ load(libdir + "wasm.js");
if (!wasmIsSupported())
quit();
function mismatchError(actual, expect) {
var str = "type mismatch: expression has type " + actual + " but expected " + expect;
return RegExp(str);
}
function testConversion(resultType, opcode, paramType, op, expect) {
assertEq(wasmEvalText('(module (func (param ' + paramType + ') (result ' + resultType + ') (' + resultType + '.' + opcode + '/' + paramType + ' (get_local 0))) (export "" 0))')(op), expect);

View File

@ -3,11 +3,6 @@ load(libdir + "wasm.js");
if (!wasmIsSupported())
quit();
function mismatchError(actual, expect) {
var str = "type mismatch: expression has type " + actual + " but expected " + expect;
return RegExp(str);
}
function testLoad(type, ext, base, offset, align, expect) {
assertEq(wasmEvalText(
'(module' +
@ -131,3 +126,12 @@ testStore('i32', '16', 0, 0, 0, 0x2345);
testLoadError('i32', '', 0, 0, 3, /memory access alignment must be a power of two/);
testStoreError('i32', '', 0, 0, 3, /memory access alignment must be a power of two/);
assertErrorMessage(() => wasmEvalText('(module (memory 0x10000) (func (f64.store offset=0 (i32.const 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f64"));
assertErrorMessage(() => wasmEvalText('(module (memory 0x10000) (func (f64.store offset=0 (i32.const 0) (f32.const 0))))'), TypeError, mismatchError("f32", "f64"));
assertErrorMessage(() => wasmEvalText('(module (memory 0x10000) (func (f32.store offset=0 (i32.const 0) (i32.const 0))))'), TypeError, mismatchError("i32", "f32"));
assertErrorMessage(() => wasmEvalText('(module (memory 0x10000) (func (f32.store offset=0 (i32.const 0) (f64.const 0))))'), TypeError, mismatchError("f64", "f32"));
assertErrorMessage(() => wasmEvalText('(module (memory 0x10000) (func (i32.store offset=0 (i32.const 0) (f32.const 0))))'), TypeError, mismatchError("f32", "i32"));
assertErrorMessage(() => wasmEvalText('(module (memory 0x10000) (func (i32.store offset=0 (i32.const 0) (f64.const 0))))'), TypeError, mismatchError("f64", "i32"));