зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536062: Make sure that dead-code doesn't prevent ion compilation of wasm modules; r=lth
This also fixes-up a few places in text-to-binary where no error messages were generated, resulting in incorrect out-of-memory messages. Differential Revision: https://phabricator.services.mozilla.com/D23838 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
618c926865
Коммит
acb6fa936f
|
@ -463,3 +463,22 @@ let glutenFreeBaguette = new Baguette("calories-free bread");
|
|||
exports.set_mut(glutenFreeBaguette);
|
||||
assertEq(exports.get_mut(), glutenFreeBaguette);
|
||||
assertEq(exports.get_mut().calories, "calories-free bread");
|
||||
|
||||
// Make sure that dead code doesn't prevent compilation.
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(func
|
||||
(return)
|
||||
(ref.null)
|
||||
(drop)
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(func (param anyref)
|
||||
(return)
|
||||
(ref.is_null (get_local 0))
|
||||
(drop)
|
||||
)
|
||||
)`);
|
||||
|
|
|
@ -434,3 +434,51 @@ assertErrorMessage(() => wasmEvalText(
|
|||
SyntaxError,
|
||||
/parsing wasm text/);
|
||||
|
||||
// Make sure that dead code doesn't prevent compilation.
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(table (export "t") 10 anyref)
|
||||
(func (param i32)
|
||||
(return)
|
||||
(table.get (get_local 0))
|
||||
(drop)
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(table (export "t") 10 anyref)
|
||||
(func (param i32) (param anyref)
|
||||
(return)
|
||||
(table.grow (get_local 1))
|
||||
(drop)
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(table (export "t") 10 anyref)
|
||||
(func (param i32) (param anyref)
|
||||
(return)
|
||||
(table.set (get_local 0) (get_local 1))
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(table (export "t") 10 anyref)
|
||||
(func
|
||||
(return)
|
||||
(table.size)
|
||||
(drop)
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(table (export "t") 10 anyref)
|
||||
(func
|
||||
(return)
|
||||
(table.copy (i32.const 0) (i32.const 1))
|
||||
)
|
||||
)`);
|
||||
|
|
|
@ -1229,3 +1229,33 @@ function checkRange(arr, minIx, maxIxPlusOne, expectedValue)
|
|||
checkRange(b, 64827, 64834, 26);
|
||||
checkRange(b, 64834, 65536, 0);
|
||||
}
|
||||
|
||||
// Make sure dead code doesn't prevent compilation.
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(memory 0 10)
|
||||
(data (i32.const 0))
|
||||
(func
|
||||
(return)
|
||||
(memory.init 0)
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(memory 0 10)
|
||||
(func
|
||||
(return)
|
||||
(memory.fill)
|
||||
)
|
||||
)`);
|
||||
|
||||
wasmEvalText(
|
||||
`(module
|
||||
(table (export "t") 10 funcref)
|
||||
(elem (i32.const 0) 0)
|
||||
(func
|
||||
(return)
|
||||
(elem.drop 0)
|
||||
)
|
||||
)`);
|
||||
|
|
|
@ -2922,7 +2922,7 @@ static bool EmitMemOrTableCopy(FunctionCompiler& f, bool isMem) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -2982,7 +2982,7 @@ static bool EmitDataOrElemDrop(FunctionCompiler& f, bool isData) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3023,7 +3023,7 @@ static bool EmitMemFill(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3068,7 +3068,7 @@ static bool EmitMemOrTableInit(FunctionCompiler& f, bool isMem) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3133,7 +3133,7 @@ static bool EmitTableGet(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3189,7 +3189,7 @@ static bool EmitTableGrow(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3239,7 +3239,7 @@ static bool EmitTableSet(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3287,7 +3287,7 @@ static bool EmitTableSize(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode();
|
||||
|
@ -3328,7 +3328,7 @@ static bool EmitRefNull(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
MDefinition* nullVal = f.nullRefConstant();
|
||||
|
@ -3346,7 +3346,7 @@ static bool EmitRefIsNull(FunctionCompiler& f) {
|
|||
}
|
||||
|
||||
if (f.inDeadCode()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
MDefinition* nullVal = f.nullRefConstant();
|
||||
|
|
|
@ -3701,6 +3701,9 @@ static AstDataOrElemDrop* ParseDataOrElemDrop(WasmParseContext& c,
|
|||
bool isData) {
|
||||
WasmToken segIndexTok;
|
||||
if (!c.ts.getIf(WasmToken::Index, &segIndexTok)) {
|
||||
UniqueChars msg = JS_smprintf("expected %s segment reference",
|
||||
isData ? "data" : "element");
|
||||
c.ts.generateError(c.ts.peek(), msg.get(), c.error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -3742,6 +3745,8 @@ static AstMemOrTableInit* ParseMemOrTableInit(WasmParseContext& c,
|
|||
WasmToken segIndexTok;
|
||||
if (isMem) {
|
||||
if (!c.ts.getIf(WasmToken::Index, &segIndexTok)) {
|
||||
c.ts.generateError(c.ts.peek(), "expected data segment reference",
|
||||
c.error);
|
||||
return nullptr;
|
||||
}
|
||||
segIndex = segIndexTok.index();
|
||||
|
|
Загрузка…
Ссылка в новой задаче