Add support for panicking/returning err back to llvm

This commit is contained in:
Lachlan Sneff
2019-04-10 14:17:10 -07:00
parent 6848e81a77
commit 1cb3fbea0a
3 changed files with 19 additions and 9 deletions

View File

@ -61,15 +61,15 @@ struct UncatchableException : WasmException
struct UserException : UncatchableException
{
public:
UserException(std::string msg) : msg(msg) {}
UserException(size_t data, size_t vtable) : data(data), vtable(vtable) {}
virtual std::string description() const noexcept override
{
return std::string("user exception: ") + msg;
return "user exception";
}
private:
std::string msg;
// The parts of a `Box<dyn Any>`.
size_t data, vtable;
};
struct WasmTrap : UncatchableException
@ -176,6 +176,12 @@ extern "C"
delete module;
}
// Throw a fat pointer that's assumed to be `*mut dyn Any` on the rust
// side.
[[noreturn]] void throw_any(size_t data, size_t vtable) {
throw UserException(data, vtable);
}
bool invoke_trampoline(
trampoline_t trampoline,
void *ctx,