[Wasm] Require location for buildUnreachable and fix all usages

This commit is contained in:
Zalim Bashorov
2022-12-09 18:50:43 +01:00
parent 36d4e29253
commit ce265c049a
4 changed files with 33 additions and 19 deletions
@@ -36,8 +36,8 @@ abstract class WasmExpressionBuilder {
buildInstr(WasmOp.I32_CONST, location, WasmImmediate.SymbolI32(value))
}
fun buildUnreachable() {
buildInstr(WasmOp.UNREACHABLE)
fun buildUnreachable(location: SourceLocation) {
buildInstr(WasmOp.UNREACHABLE, location)
}
@Suppress("UNUSED_PARAMETER")
@@ -191,3 +191,16 @@ abstract class WasmExpressionBuilder {
buildInstr(WasmOp.PSEUDO_COMMENT_GROUP_END)
}
}
fun WasmExpressionBuilder.buildUnreachableForVerifier() {
buildUnreachable(SourceLocation.NoLocation("This instruction should never be reached, but required for wasm verifier"))
}
fun WasmExpressionBuilder.buildUnreachableAfterNothingType() {
buildUnreachable(
SourceLocation.NoLocation(
"The unreachable instruction after an expression with Nothing type to make sure that " +
"execution doesn't come here (or it fails fast if so). It also might be required for wasm verifier."
)
)
}