@@ -47,12 +47,40 @@ enum wasmtime_trap_code_enum {
47
47
WASMTIME_TRAP_CODE_UNREACHABLE_CODE_REACHED ,
48
48
/// Execution has potentially run too long and may be interrupted.
49
49
WASMTIME_TRAP_CODE_INTERRUPT ,
50
+ /// When the `component-model` feature is enabled this trap represents a
51
+ /// function that was `canon lift`'d, then `canon lower`'d, then called.
52
+ /// This combination of creation of a function in the component model
53
+ /// generates a function that always traps and, when called, produces this
54
+ /// flavor of trap.
55
+ WASMTIME_TRAP_CODE_ALWAYS_TRAP_ADAPTER ,
50
56
/// Execution has run out of the configured fuel amount.
51
57
WASMTIME_TRAP_CODE_OUT_OF_FUEL ,
58
+ /// Used to indicate that a trap was raised by atomic wait operations on non
59
+ /// shared memory.
60
+ WASMTIME_TRAP_CODE_ATOMIC_WAIT_NON_SHARED_MEMORY ,
61
+ /// Call to a null reference.
62
+ WASMTIME_TRAP_CODE_NULL_REFERENCE ,
63
+ /// Attempt to access beyond the bounds of an array.
64
+ WASMTIME_TRAP_CODE_ARRAY_OUT_OF_BOUNDS ,
65
+ /// Attempted an allocation that was too large to succeed.
66
+ WASMTIME_TRAP_CODE_ALLOCATION_TOO_LARGE ,
67
+ /// Attempted to cast a reference to a type that it is not an instance of.
68
+ WASMTIME_TRAP_CODE_CAST_FAILURE ,
69
+ /// When the `component-model` feature is enabled this trap represents a
70
+ /// scenario where one component tried to call another component but it
71
+ /// would have violated the reentrance rules of the component model,
72
+ /// triggering a trap instead.
73
+ WASMTIME_TRAP_CODE_CANNOT_ENTER_COMPONENT ,
74
+ /// Async-lifted export failed to produce a result by calling `task.return`
75
+ /// before returning `STATUS_DONE` and/or after all host tasks completed.
76
+ WASMTIME_TRAP_CODE_NO_ASYNC_RESULT ,
77
+ /// A Pulley opcode was executed at runtime when the opcode was disabled at
78
+ /// compile time.
79
+ WASMTIME_TRAP_CODE_DISABLED_OPCODE ,
52
80
};
53
81
54
82
/**
55
- * \brief Creates a new trap.
83
+ * \brief Creates a new trap with the given message .
56
84
*
57
85
* \param msg the message to associate with this trap
58
86
* \param msg_len the byte length of `msg`
@@ -61,6 +89,15 @@ enum wasmtime_trap_code_enum {
61
89
*/
62
90
WASM_API_EXTERN wasm_trap_t * wasmtime_trap_new (const char * msg , size_t msg_len );
63
91
92
+ /**
93
+ * \brief Creates a new trap from the given trap code.
94
+ *
95
+ * \param code the trap code to associate with this trap
96
+ *
97
+ * The #wasm_trap_t returned is owned by the caller.
98
+ */
99
+ WASM_API_EXTERN wasm_trap_t * wasmtime_trap_new_code (wasmtime_trap_code_t code );
100
+
64
101
/**
65
102
* \brief Attempts to extract the trap code from this trap.
66
103
*
0 commit comments