Add an explicit trap code for wasm unreachable.

This commit is contained in:
Dan Gohman
2019-01-06 13:00:08 -08:00
parent 2f0e0dd995
commit 50a045363c
2 changed files with 9 additions and 4 deletions

View File

@@ -108,9 +108,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
// We do nothing
}
Operator::Unreachable => {
// We use `trap user0` to indicate a user-generated trap.
// We could make the trap code configurable if need be.
builder.ins().trap(ir::TrapCode::User(0));
builder.ins().trap(ir::TrapCode::UnreachableCodeReached);
state.reachable = false;
}
/***************************** Control flow blocks **********************************