mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-14 09:21:20 +00:00
Implement InternalEvent::Breakpoint in the llvm backend.
Enable now-working metering unit tests when run with the llvm backend.
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <llvm/ExecutionEngine/RuntimeDyld.h>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
|
||||
#include <llvm/ExecutionEngine/RuntimeDyld.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -77,6 +78,19 @@ struct UserException : UncatchableException
|
||||
box_any_t error_data;
|
||||
};
|
||||
|
||||
struct BreakpointException : UncatchableException
|
||||
{
|
||||
public:
|
||||
BreakpointException(uintptr_t callback) : callback(callback) {}
|
||||
|
||||
virtual std::string description() const noexcept override
|
||||
{
|
||||
return "breakpoint exception";
|
||||
}
|
||||
|
||||
uintptr_t callback;
|
||||
};
|
||||
|
||||
struct WasmTrap : UncatchableException
|
||||
{
|
||||
public:
|
||||
@ -166,6 +180,8 @@ struct WasmModule
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void callback_trampoline(void *, void *);
|
||||
|
||||
result_t module_load(const uint8_t *mem_ptr, size_t mem_size, callbacks_t callbacks, WasmModule **module_out)
|
||||
{
|
||||
*module_out = new WasmModule(mem_ptr, mem_size, callbacks);
|
||||
@ -192,6 +208,12 @@ extern "C"
|
||||
throw UserException(data, vtable);
|
||||
}
|
||||
|
||||
// Throw a pointer that's assumed to be codegen::BreakpointHandler on the
|
||||
// rust side.
|
||||
[[noreturn]] void throw_breakpoint(uintptr_t callback) {
|
||||
throw BreakpointException(callback);
|
||||
}
|
||||
|
||||
bool invoke_trampoline(
|
||||
trampoline_t trampoline,
|
||||
void *ctx,
|
||||
@ -217,6 +239,10 @@ extern "C"
|
||||
*user_error = e.error_data;
|
||||
return false;
|
||||
}
|
||||
catch (const BreakpointException &e) {
|
||||
callback_trampoline(user_error, (void *)e.callback);
|
||||
return false;
|
||||
}
|
||||
catch (const WasmException &e)
|
||||
{
|
||||
*trap_out = WasmTrap::Type::Unknown;
|
||||
@ -233,4 +259,4 @@ extern "C"
|
||||
{
|
||||
return module->get_func(llvm::StringRef(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user