-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
There were a number of breaking changes in 0.23.0. Here is a diff of the header files, with unrelated changes removed (a number of prototypes were changed from foo() to foo(void) and there were some comment changes.
diff -ur 0.22.1/wasm.h 0.23.0/wasm.h
--- 0.22.1/wasm.h 2021-04-02 09:44:25.677514318 -0600
+++ 0.23.0/wasm.h 2021-04-02 09:39:12.647901076 -0600
@@ -107,6 +107,12 @@
static inline void wasm_name_new_from_string(
own wasm_name_t* out, const char* s
) {
+ wasm_name_new(out, strlen(s), s);
+}
+
+static inline void wasm_name_new_from_string_nt(
+ own wasm_name_t* out, const char* s
+) {
wasm_name_new(out, strlen(s) + 1, s);
}
@@ -408,9 +414,9 @@
WASM_DECLARE_REF(func)
typedef own wasm_trap_t* (*wasm_func_callback_t)(
- const wasm_val_t args[], wasm_val_t results[]);
+ const wasm_val_vec_t* args, own wasm_val_vec_t* results);
typedef own wasm_trap_t* (*wasm_func_callback_with_env_t)(
- void* env, const wasm_val_t args[], wasm_val_t results[]);
+ void* env, const wasm_val_vec_t* args, wasm_val_vec_t* results);
WASM_API_EXTERN own wasm_func_t* wasm_func_new(
wasm_store_t*, const wasm_functype_t*, wasm_func_callback_t);
@@ -423,7 +429,7 @@
WASM_API_EXTERN size_t wasm_func_result_arity(const wasm_func_t*);
WASM_API_EXTERN own wasm_trap_t* wasm_func_call(
- const wasm_func_t*, const wasm_val_t args[], wasm_val_t results[]);
+ const wasm_func_t*, const wasm_val_vec_t* args, wasm_val_vec_t* results);
// Global Instances
@@ -510,7 +516,7 @@
WASM_DECLARE_REF(instance)
WASM_API_EXTERN own wasm_instance_t* wasm_instance_new(
- wasm_store_t*, const wasm_module_t*, const wasm_extern_t* const imports[],
+ wasm_store_t*, const wasm_module_t*, const wasm_extern_vec_t* imports,
own wasm_trap_t**
);
@@ -520,6 +526,12 @@
///////////////////////////////////////////////////////////////////////////////
// Convenience
+// Vectors
+
+#define WASM_EMPTY_VEC {0, NULL}
+#define WASM_ARRAY_VEC(array) {sizeof(array)/sizeof(*(array)), array}
+
+
// Value Type construction short-hands
static inline own wasm_valtype_t* wasm_valtype_new_i32(void) {
@@ -692,6 +704,13 @@
#endif
}
+#define WASM_I32_VAL(i) {.kind = WASM_I32, .of = {.i32 = i}}
+#define WASM_I64_VAL(i) {.kind = WASM_I64, .of = {.i64 = i}}
+#define WASM_F32_VAL(z) {.kind = WASM_F32, .of = {.f32 = z}}
+#define WASM_F64_VAL(z) {.kind = WASM_F64, .of = {.f64 = z}}
+#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .of = {.ref = r}}
+#define WASM_INIT_VAL {.kind = WASM_ANYREF, .of = {.ref = NULL}}
+
///////////////////////////////////////////////////////////////////////////////
diff -ur 0.22.1/wasmtime.h 0.23.0/wasmtime.h
--- 0.22.1/wasmtime.h 2021-04-02 09:46:35.136611494 -0600
+++ 0.23.0/wasmtime.h 2021-04-02 09:39:12.647901076 -0600
@@ -153,6 +153,15 @@
WASMTIME_CONFIG_PROP(void, interruptable, bool)
/**
+ * \brief Whether or not fuel is enabled for generated code.
+ *
+ * This setting is `false` by default. When enabled it will enable fuel counting
+ * meaning that fuel will be consumed every time a wasm instruction is executed,
+ * and trap when reaching zero.
+ */
+WASMTIME_CONFIG_PROP(void, consume_fuel, bool)
+
+/**
* \brief Configures the maximum stack size, in bytes, that JIT code can use.
*
* This setting is 2MB by default. Configuring this setting will limit the
@@ -275,6 +284,14 @@
WASMTIME_CONFIG_PROP(void, dynamic_memory_guard_size, uint64_t)
/**
+ * \brief Configures the maximum number of instances that can be created.
+ *
+ * For more information see the Rust documentation at
+ * https://bytecodealliance.github.io/wasmtime/api/wasmtime/struct.Config.html#method.max_instances.
+ */
+WASMTIME_CONFIG_PROP(void, max_instances, size_t)
+
+/**
* \brief Enables Wasmtime's cache and loads configuration from the specified
* path.
*
@@ -527,7 +544,7 @@
* argument is a #wasmtime_caller_t which allows learning information about the
* caller.
*/
-typedef own wasm_trap_t* (*wasmtime_func_callback_t)(const wasmtime_caller_t* caller, const wasm_val_t args[], wasm_val_t results[]);
+typedef own wasm_trap_t* (*wasmtime_func_callback_t)(const wasmtime_caller_t* caller, const wasm_val_vec_t *args, wasm_val_vec_t *results);
/**
* \brief Callback signature for #wasmtime_func_new_with_env.
@@ -536,7 +553,7 @@
* first argument is a #wasmtime_caller_t which allows learning information
* about the caller.
*/
-typedef own wasm_trap_t* (*wasmtime_func_callback_with_env_t)(const wasmtime_caller_t* caller, void* env, const wasm_val_t args[], wasm_val_t results[]);
+typedef own wasm_trap_t* (*wasmtime_func_callback_with_env_t)(const wasmtime_caller_t* caller, void* env, const wasm_val_vec_t *args, wasm_val_vec_t *results);
/**
* \brief Creates a new host-defined function.
@@ -628,6 +645,35 @@
WASM_API_EXTERN own wasmtime_interrupt_handle_t *wasmtime_interrupt_handle_new(wasm_store_t *store);
/**
+ * \brief Adds fuel to this Store for wasm to consume while executing.
+ *
+ * For this method to work fuel consumption must be enabled via
+ * #wasmtime_config_consume_fuel_set. By default a Store starts with 0 fuel
+ * for wasm to execute with (meaning it will immediately trap).
+ * This function must be called for the store to have
+ * some fuel to allow WebAssembly to execute.
+ *
+ * Note that at this time when fuel is entirely consumed it will cause
+ * wasm to trap. More usages of fuel are planned for the future.
+ *
+ * If fuel is not enabled within this store then an error is returned. If fuel
+ * is successfully added then NULL is returned.
+ */
+WASM_API_EXTERN own wasmtime_error_t *wasmtime_store_add_fuel(wasm_store_t *store, uint64_t fuel);
+
+/**
+ * \brief Returns the amount of fuel consumed by this store's execution so far.
+ *
+ * If fuel consumption is not enabled via #wasmtime_config_consume_fuel_set
+ * then this function will return false. Otherwise true is returned and the
+ * fuel parameter is filled in with fuel consuemd so far.
+ *
+ * Also note that fuel, if enabled, must be originally configured via
+ * #wasmtime_store_add_fuel.
+ */
+WASM_API_EXTERN bool wasmtime_store_fuel_consumed(wasm_store_t *store, uint64_t *fuel);
+
+/**
* \brief Requests that WebAssembly code running in the store attached to this
* interrupt handle is interrupted.
*
@@ -696,10 +742,8 @@
*/
WASM_API_EXTERN own wasmtime_error_t *wasmtime_func_call(
wasm_func_t *func,
- const wasm_val_t *args,
- size_t num_args,
- wasm_val_t *results,
- size_t num_results,
+ const wasm_val_vec_t *args,
+ wasm_val_vec_t *results,
own wasm_trap_t **trap
);
@@ -757,8 +801,7 @@
WASM_API_EXTERN own wasmtime_error_t *wasmtime_instance_new(
wasm_store_t *store,
const wasm_module_t *module,
- const wasm_extern_t* const imports[],
- size_t num_imports,
+ const wasm_extern_vec_t* imports,
own wasm_instance_t **instance,
own wasm_trap_t **trap
);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels