Allow negative literals in asm->wasm non-conversion operations.
This allows expressions like: (x + y) & -1 [intish] & [signed] The previous conversion condition was too strict (intended to forbid non-int expression conversion). Expressing in a different way. BUG= https://code.google.com/p/v8/issues/detail?id=4203 TEST=mjsunit/asm-wasm R=aseemgarg@chromium.org,titzer@chromium.org LOG=N Review URL: https://codereview.chromium.org/1717213002 Cr-Commit-Position: refs/heads/master@{#34228}
This commit is contained in:
parent
b3de78c191
commit
c8c5b3fddf
@ -1113,7 +1113,7 @@ void AsmTyper::VisitIntegerBitwiseOperator(BinaryOperation* expr,
|
|||||||
right_type = left_type;
|
right_type = left_type;
|
||||||
}
|
}
|
||||||
if (!conversion) {
|
if (!conversion) {
|
||||||
if (!left_type->Is(right_type) || !right_type->Is(left_type)) {
|
if (!left_type->Is(cache_.kAsmInt) || !right_type->Is(cache_.kAsmInt)) {
|
||||||
FAIL(expr, "ill-typed bitwise operation");
|
FAIL(expr, "ill-typed bitwise operation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1472,3 +1472,54 @@ TestForeignVariables();
|
|||||||
_WASMEXP_.instantiateModuleFromAsm(Module.toString());
|
_WASMEXP_.instantiateModuleFromAsm(Module.toString());
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
(function TestAndNegative() {
|
||||||
|
function Module() {
|
||||||
|
"use asm";
|
||||||
|
function func() {
|
||||||
|
var x = 1;
|
||||||
|
var y = 2;
|
||||||
|
var z = 0;
|
||||||
|
z = x + y & -1;
|
||||||
|
return z | 0;
|
||||||
|
}
|
||||||
|
return {func: func};
|
||||||
|
}
|
||||||
|
|
||||||
|
var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString());
|
||||||
|
assertEquals(3, m.func());
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
(function TestNegativeDouble() {
|
||||||
|
function Module() {
|
||||||
|
"use asm";
|
||||||
|
function func() {
|
||||||
|
var x = -(34359738368.25);
|
||||||
|
var y = -2.5;
|
||||||
|
return +(x + y);
|
||||||
|
}
|
||||||
|
return {func: func};
|
||||||
|
}
|
||||||
|
|
||||||
|
var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString());
|
||||||
|
assertEquals(-34359738370.75, m.func());
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
(function TestBadAndDouble() {
|
||||||
|
function Module() {
|
||||||
|
"use asm";
|
||||||
|
function func() {
|
||||||
|
var x = 1.0;
|
||||||
|
var y = 2.0;
|
||||||
|
return (x & y) | 0;
|
||||||
|
}
|
||||||
|
return {func: func};
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThrows(function() {
|
||||||
|
_WASMEXP_.instantiateModuleFromAsm(Module.toString());
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user