@@ -35,6 +35,40 @@ WASMI_CONFIG_PROP(void, consume_fuel, bool)
3535 */
3636WASMI_CONFIG_PROP (void , ignore_custom_sections , bool )
3737
38+ /**
39+ * \brief Sets the maximum recursion depth of the engine's stack during execution.
40+ *
41+ * An execution traps if it exceeds this limit.
42+ */
43+ WASMI_CONFIG_PROP (void , set_max_recursion_depth , size_t )
44+
45+ /**
46+ * \brief Sets the minimum (or initial) height of the engine's value stack in bytes.
47+ *
48+ * Lower initial heights may improve memory consumption.
49+ * Higher initial heights may improve cold start times.
50+ *
51+ * Note: Panics if value is greater than the current maximum height of the value stack.
52+ */
53+ WASMI_CONFIG_PROP (void , set_min_stack_height , size_t )
54+
55+ /**
56+ * \brief Sets the maximum height of the engine's value stack in bytes.
57+ *
58+ * An execution traps if it exceeds this limit.
59+ *
60+ * Note: Panics if value is less than the current minimum height of the value stack.
61+ */
62+ WASMI_CONFIG_PROP (void , set_max_stack_height , size_t )
63+
64+ /**
65+ * \brief Sets the maximum number of cached stacks for reuse.
66+ *
67+ * A higher value may improve execution performance.
68+ * A lower value may improve memory consumption.
69+ */
70+ WASMI_CONFIG_PROP (void , set_max_cached_stacks , size_t )
71+
3872/**
3973 * \brief Whether or not to Wasm mutable-globals proposal is enabled.
4074 *
@@ -92,6 +126,52 @@ WASMI_CONFIG_PROP(void, wasm_tail_call, bool)
92126 */
93127WASMI_CONFIG_PROP (void , wasm_extended_const , bool )
94128
129+ /**
130+ * \brief Whether or not to Wasm multi-memory proposal is enabled.
131+ *
132+ * Default value: `true`
133+ */
134+ WASMI_CONFIG_PROP (void , wasm_multi_memory , bool )
135+
136+ /**
137+ * \brief Whether or not to Wasm custom-page-sizes proposal is enabled.
138+ *
139+ * Default value: `false`
140+ */
141+ WASMI_CONFIG_PROP (void , wasm_custom_page_sizes , bool )
142+
143+ /**
144+ * \brief Whether or not to Wasm memory64 proposal is enabled.
145+ *
146+ * Default value: `true`
147+ */
148+ WASMI_CONFIG_PROP (void , wasm_memory64 , bool )
149+
150+ /**
151+ * \brief Whether or not to Wasm wide-arithmetic proposal is enabled.
152+ *
153+ * Default value: `false`
154+ */
155+ WASMI_CONFIG_PROP (void , wasm_wide_arithmetic , bool )
156+
157+ /**
158+ * \brief Whether or not to Wasm simd proposal is enabled.
159+ *
160+ * Only available when compiled with the `simd` feature.
161+ *
162+ * Default value: `true` (when feature enabled)
163+ */
164+ WASMI_CONFIG_PROP (void , wasm_simd , bool )
165+
166+ /**
167+ * \brief Whether or not to Wasm relaxed-simd proposal is enabled.
168+ *
169+ * Only available when compiled with the `simd` feature.
170+ *
171+ * Default value: `true` (when feature enabled)
172+ */
173+ WASMI_CONFIG_PROP (void , wasm_relaxed_simd , bool )
174+
95175/**
96176 * \brief Whether or not to floating Wasm point types and operations are
97177 * enabled.
@@ -125,6 +205,58 @@ WASMI_CONFIG_PROP(void, compilation_mode, enum wasmi_compilation_mode_enum)
125205
126206#undef WASMI_CONFIG_PROP
127207
208+ /**
209+ * \brief Enforced limits for Wasm module parsing and compilation.
210+ *
211+ * Opaque type representing limits that can be enforced on Wasm modules.
212+ */
213+ typedef struct wasmi_enforced_limits_t wasmi_enforced_limits_t ;
214+
215+ /**
216+ * \brief Creates a new enforced limits object with strict preset values.
217+ *
218+ * This set of strict enforced rules can be used to safeguard against
219+ * malicious actors trying to attack the Wasmi compilation procedures.
220+ *
221+ * The strict limits are:
222+ * - max_globals: 1000
223+ * - max_functions: 10,000
224+ * - max_tables: 100
225+ * - max_element_segments: 1000
226+ * - max_memories: 1
227+ * - max_data_segments: 1000
228+ * - max_params: 32
229+ * - max_results: 32
230+ * - min_avg_bytes_per_function: 40 (enforced at 1000+ total bytes)
231+ *
232+ * The returned object must be freed using wasmi_enforced_limits_delete().
233+ *
234+ * \return A new enforced limits object with strict preset values
235+ */
236+ WASM_API_EXTERN wasmi_enforced_limits_t * wasmi_enforced_limits_strict ();
237+
238+ /**
239+ * \brief Deletes an enforced limits object.
240+ *
241+ * \param limits The enforced limits object to delete
242+ */
243+ WASM_API_EXTERN void wasmi_enforced_limits_delete (wasmi_enforced_limits_t * limits );
244+
245+ /**
246+ * \brief Sets the enforced limits for the configuration.
247+ *
248+ * By default no limits are enforced. Use this function to apply a set of
249+ * enforced limits (such as those created by wasmi_enforced_limits_strict())
250+ * to the configuration.
251+ *
252+ * \param config The configuration to modify
253+ * \param limits The enforced limits to apply
254+ */
255+ WASM_API_EXTERN void wasmi_config_enforced_limits_set (
256+ wasm_config_t * config ,
257+ const wasmi_enforced_limits_t * limits
258+ );
259+
128260#ifdef __cplusplus
129261} // extern "C"
130262#endif
0 commit comments