summaryrefslogtreecommitdiff
path: root/wasm2c/wasm-rt.h
diff options
context:
space:
mode:
Diffstat (limited to 'wasm2c/wasm-rt.h')
-rw-r--r--wasm2c/wasm-rt.h86
1 files changed, 26 insertions, 60 deletions
diff --git a/wasm2c/wasm-rt.h b/wasm2c/wasm-rt.h
index 03f78834..9fd12dee 100644
--- a/wasm2c/wasm-rt.h
+++ b/wasm2c/wasm-rt.h
@@ -318,37 +318,7 @@ bool wasm_rt_is_initialized(void);
void wasm_rt_free(void);
/**
- * Stop execution immediately and jump back to the call to `wasm_rt_impl_try`.
- * The result of `wasm_rt_impl_try` will be the provided trap reason.
- *
- * This is typically called by the generated code, and not the embedder.
- */
-WASM_RT_NO_RETURN void wasm_rt_trap(wasm_rt_trap_t);
-
-/**
- * Return a human readable error string based on a trap type.
- */
-const char* wasm_rt_strerror(wasm_rt_trap_t trap);
-
-/**
- * A tag is represented as an arbitrary pointer.
- */
-typedef const void* wasm_rt_tag_t;
-
-/**
- * Set the active exception to given tag, size, and contents.
- */
-void wasm_rt_load_exception(const wasm_rt_tag_t tag,
- uint32_t size,
- const void* values);
-
-/**
- * Throw the active exception.
- */
-WASM_RT_NO_RETURN void wasm_rt_throw(void);
-
-/**
- * A hardened jmp_buf that allows us to checks if it is initialized before use
+ * A hardened jmp_buf that allows checking for initialization before use
*/
typedef struct {
/* Is the jmp buf intialized? */
@@ -357,44 +327,40 @@ typedef struct {
jmp_buf buffer;
} wasm_rt_jmp_buf;
-/**
- * The type of an unwind target if an exception is thrown and caught.
- */
-#define WASM_RT_UNWIND_TARGET wasm_rt_jmp_buf
+#if WASM_RT_INSTALL_SIGNAL_HANDLER && !defined(_WIN32)
+#define WASM_RT_SETJMP_SETBUF(buf) sigsetjmp(buf, 1)
+#else
+#define WASM_RT_SETJMP_SETBUF(buf) setjmp(buf)
+#endif
-/**
- * Get the current unwind target if an exception is thrown.
- */
-WASM_RT_UNWIND_TARGET* wasm_rt_get_unwind_target(void);
+#define WASM_RT_SETJMP(buf) \
+ ((buf).initialized = true, WASM_RT_SETJMP_SETBUF((buf).buffer))
-/**
- * Set the unwind target if an exception is thrown.
- */
-void wasm_rt_set_unwind_target(WASM_RT_UNWIND_TARGET* target);
+#if WASM_RT_INSTALL_SIGNAL_HANDLER && !defined(_WIN32)
+#define WASM_RT_LONGJMP_UNCHECKED(buf, val) siglongjmp(buf, val)
+#else
+#define WASM_RT_LONGJMP_UNCHECKED(buf, val) longjmp(buf, val)
+#endif
-/**
- * Tag of the active exception.
- */
-wasm_rt_tag_t wasm_rt_exception_tag(void);
+#define WASM_RT_LONGJMP(buf, val) \
+ /* Abort on failure as this may be called in the trap handler */ \
+ if (!((buf).initialized)) \
+ abort(); \
+ (buf).initialized = false; \
+ WASM_RT_LONGJMP_UNCHECKED((buf).buffer, val)
/**
- * Size of the active exception.
+ * Stop execution immediately and jump back to the call to `wasm_rt_impl_try`.
+ * The result of `wasm_rt_impl_try` will be the provided trap reason.
+ *
+ * This is typically called by the generated code, and not the embedder.
*/
-uint32_t wasm_rt_exception_size(void);
+WASM_RT_NO_RETURN void wasm_rt_trap(wasm_rt_trap_t);
/**
- * Contents of the active exception.
+ * Return a human readable error string based on a trap type.
*/
-void* wasm_rt_exception(void);
-
-#if WASM_RT_INSTALL_SIGNAL_HANDLER && !defined(_WIN32)
-#define WASM_RT_SETJMP_SETBUF(buf) sigsetjmp(buf, 1)
-#else
-#define WASM_RT_SETJMP_SETBUF(buf) setjmp(buf)
-#endif
-
-#define WASM_RT_SETJMP(buf) \
- ((buf).initialized = true, WASM_RT_SETJMP_SETBUF((buf).buffer))
+const char* wasm_rt_strerror(wasm_rt_trap_t trap);
#define wasm_rt_try(target) WASM_RT_SETJMP(target)