Remove the module linking implementation in Wasmtime (#3958)

* Remove the module linking implementation in Wasmtime

This commit removes the experimental implementation of the module
linking WebAssembly proposal from Wasmtime. The module linking is no
longer intended for core WebAssembly but is instead incorporated into
the component model now at this point. This means that very large parts
of Wasmtime's implementation of module linking are no longer applicable
and would change greatly with an implementation of the component model.

The main purpose of this is to remove Wasmtime's reliance on the support
for module-linking in `wasmparser` and tooling crates. With this
reliance removed we can move over to the `component-model` branch of
`wasmparser` and use the updated support for the component model.
Additionally given the trajectory of the component model proposal the
embedding API of Wasmtime will not look like what it looks like today
for WebAssembly. For example the core wasm `Instance` will not change
and instead a `Component` is likely to be added instead.

Some more rationale for this is in #3941, but the basic idea is that I
feel that it's not going to be viable to develop support for the
component model on a non-`main` branch of Wasmtime. Additionaly I don't
think it's viable, for the same reasons as `wasm-tools`, to support the
old module linking proposal and the new component model at the same
time.

This commit takes a moment to not only delete the existing module
linking implementation but some abstractions are also simplified. For
example module serialization is a bit simpler that there's only one
module. Additionally instantiation is much simpler since the only
initializer we have to deal with are imports and nothing else.

Closes #3941

* Fix doc link

* Update comments
This commit is contained in:
Alex Crichton
2022-03-23 14:57:34 -05:00
committed by GitHub
parent 6a60e8363f
commit 76b82910c9
51 changed files with 400 additions and 4555 deletions

View File

@@ -185,14 +185,6 @@ WASMTIME_CONFIG_PROP(void, wasm_multi_value, bool)
*/
WASMTIME_CONFIG_PROP(void, wasm_multi_memory, bool)
/**
* \brief Configures whether the WebAssembly module linking proposal is
* enabled.
*
* This setting is `false` by default.
*/
WASMTIME_CONFIG_PROP(void, wasm_module_linking, bool)
/**
* \brief Configures whether the WebAssembly memory64 proposal is
* enabled.

View File

@@ -56,20 +56,6 @@ typedef struct wasmtime_memory {
size_t index;
} wasmtime_memory_t;
/// \brief Representation of a instance in Wasmtime.
///
/// Instances are represented with a 64-bit identifying integer in Wasmtime.
/// They do not have any destructor associated with them. Instances cannot
/// interoperate between #wasmtime_store_t instances and if the wrong instance
/// is passed to the wrong store then it may trigger an assertion to abort the
/// process.
typedef struct wasmtime_instance {
/// Internal identifier of what store this belongs to, never zero.
uint64_t store_id;
/// Internal index within the store.
size_t index;
} wasmtime_instance_t;
/// \brief Representation of a global in Wasmtime.
///
/// Globals are represented with a 64-bit identifying integer in Wasmtime.
@@ -99,12 +85,6 @@ typedef uint8_t wasmtime_extern_kind_t;
/// \brief Value of #wasmtime_extern_kind_t meaning that #wasmtime_extern_t is a
/// memory
#define WASMTIME_EXTERN_MEMORY 3
/// \brief Value of #wasmtime_extern_kind_t meaning that #wasmtime_extern_t is
/// an instance
#define WASMTIME_EXTERN_INSTANCE 4
/// \brief Value of #wasmtime_extern_kind_t meaning that #wasmtime_extern_t is
/// a module
#define WASMTIME_EXTERN_MODULE 5
/**
* \typedef wasmtime_extern_union_t
@@ -125,13 +105,6 @@ typedef union wasmtime_extern_union {
wasmtime_table_t table;
/// Field used if #wasmtime_extern_t::kind is #WASMTIME_EXTERN_MEMORY
wasmtime_memory_t memory;
/// Field used if #wasmtime_extern_t::kind is #WASMTIME_EXTERN_INSTANCE
wasmtime_instance_t instance;
/// Field used if #wasmtime_extern_t::kind is #WASMTIME_EXTERN_MODULE
///
/// Note that this may be an owned pointer depending on the ownership of the
/// #wasmtime_extern_t container value.
wasmtime_module_t *module;
} wasmtime_extern_union_t;
/**

View File

@@ -16,39 +16,19 @@
extern "C" {
#endif
/**
* \brief An opaque object representing the type of an instance.
*/
typedef struct wasmtime_instancetype wasmtime_instancetype_t;
/// \brief Deletes an instance type
WASM_API_EXTERN void wasmtime_instancetype_delete(wasmtime_instancetype_t *ty);
/**
* \brief Returns the list of exports that this instance type provides.
*
* This function does not take ownership of the provided instance type but
* ownership of `out` is passed to the caller. Note that `out` is treated as
* uninitialized when passed to this function.
*/
WASM_API_EXTERN void wasmtime_instancetype_exports(const wasmtime_instancetype_t*, wasm_exporttype_vec_t* out);
/**
* \brief Converts a #wasmtime_instancetype_t to a #wasm_externtype_t
*
* The returned value is owned by the #wasmtime_instancetype_t argument and should not
* be deleted.
*/
WASM_API_EXTERN wasm_externtype_t* wasmtime_instancetype_as_externtype(wasmtime_instancetype_t*);
/**
* \brief Attempts to convert a #wasm_externtype_t to a #wasmtime_instancetype_t
*
* The returned value is owned by the #wasmtime_instancetype_t argument and should not
* be deleted. Returns `NULL` if the provided argument is not a
* #wasmtime_instancetype_t.
*/
WASM_API_EXTERN wasmtime_instancetype_t* wasmtime_externtype_as_instancetype(wasm_externtype_t*);
/// \brief Representation of a instance in Wasmtime.
///
/// Instances are represented with a 64-bit identifying integer in Wasmtime.
/// They do not have any destructor associated with them. Instances cannot
/// interoperate between #wasmtime_store_t instances and if the wrong instance
/// is passed to the wrong store then it may trigger an assertion to abort the
/// process.
typedef struct wasmtime_instance {
/// Internal identifier of what store this belongs to, never zero.
uint64_t store_id;
/// Internal index within the store.
size_t index;
} wasmtime_instance_t;
/**
* \brief Instantiate a wasm module.
@@ -91,16 +71,6 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_instance_new(
wasm_trap_t **trap
);
/**
* \brief Returns the type of the specified instance.
*
* The returned type is owned by the caller.
*/
WASM_API_EXTERN wasmtime_instancetype_t *wasmtime_instance_type(
const wasmtime_context_t *store,
const wasmtime_instance_t *instance
);
/**
* \brief Get an export by name from an instance.
*

View File

@@ -14,51 +14,6 @@
extern "C" {
#endif
/**
* \brief An opaque object representing the type of a module.
*/
typedef struct wasmtime_moduletype wasmtime_moduletype_t;
/**
* \brief Deletes a module type.
*/
WASM_API_EXTERN void wasmtime_moduletype_delete(wasmtime_moduletype_t *ty);
/**
* \brief Returns the list of imports that this module type requires.
*
* This function does not take ownership of the provided module type but
* ownership of `out` is passed to the caller. Note that `out` is treated as
* uninitialized when passed to this function.
*/
WASM_API_EXTERN void wasmtime_moduletype_imports(const wasmtime_moduletype_t*, wasm_importtype_vec_t* out);
/**
* \brief Returns the list of exports that this module type provides.
*
* This function does not take ownership of the provided module type but
* ownership of `out` is passed to the caller. Note that `out` is treated as
* uninitialized when passed to this function.
*/
WASM_API_EXTERN void wasmtime_moduletype_exports(const wasmtime_moduletype_t*, wasm_exporttype_vec_t* out);
/**
* \brief Converts a #wasmtime_moduletype_t to a #wasm_externtype_t
*
* The returned value is owned by the #wasmtime_moduletype_t argument and should not
* be deleted.
*/
WASM_API_EXTERN wasm_externtype_t* wasmtime_moduletype_as_externtype(wasmtime_moduletype_t*);
/**
* \brief Attempts to convert a #wasm_externtype_t to a #wasmtime_moduletype_t
*
* The returned value is owned by the #wasmtime_moduletype_t argument and
* should not be deleted. Returns `NULL` if the provided argument is not a
* #wasmtime_moduletype_t.
*/
WASM_API_EXTERN wasmtime_moduletype_t* wasmtime_externtype_as_moduletype(wasm_externtype_t*);
/**
* \typedef wasmtime_module_t
* \brief Convenience alias for #wasmtime_module
@@ -122,14 +77,6 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_module_validate(
size_t wasm_len
);
/**
* \brief Returns the type of this module.
*
* The returned #wasmtime_moduletype_t is expected to be deallocated by the
* caller.
*/
WASM_API_EXTERN wasmtime_moduletype_t* wasmtime_module_type(const wasmtime_module_t*);
/**
* \brief This function serializes compiled module artifacts as blob data.
*