Skip to content

Commit

Permalink
fix: Revert mangle-symbols feature
Browse files Browse the repository at this point in the history
  • Loading branch information
xdoardo committed Nov 27, 2024
1 parent 37a8116 commit 9ce88ee
Show file tree
Hide file tree
Showing 26 changed files with 5 additions and 172 deletions.
1 change: 0 additions & 1 deletion crates/c_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ doctest = false
[features]
default = ["std"]
std = []
mangle-symbols = []
13 changes: 0 additions & 13 deletions crates/c_api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ wasmi_c_api_macros::declare_own!(wasm_config_t);
/// Wraps [`wasmi::Config::default`].
///
/// [`wasm_engine_new_with_config`]: crate::wasm_engine_new_with_config
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_config_new() -> Box<wasm_config_t> {
Box::new(wasm_config_t {
inner: Config::default(),
Expand All @@ -32,7 +31,6 @@ pub extern "C" fn wasm_config_new() -> Box<wasm_config_t> {
/// Wraps [`wasmi::Config::wasm_multi_value`]
///
/// [`mutable-global`]: <https://github.com/WebAssembly/mutable-global>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_mutable_globals_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_mutable_global(enable);
}
Expand All @@ -42,7 +40,6 @@ pub extern "C" fn wasmi_config_wasm_mutable_globals_set(c: &mut wasm_config_t, e
/// Wraps [`wasmi::Config::wasm_multi_value`]
///
/// [`multi-value`]: <https://github.com/WebAssembly/multi-value>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_multi_value_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_multi_value(enable);
}
Expand All @@ -52,7 +49,6 @@ pub extern "C" fn wasmi_config_wasm_multi_value_set(c: &mut wasm_config_t, enabl
/// Wraps [`wasmi::Config::wasm_sign_extension`]
///
/// [`sign-extension-ops`]: <https://github.com/WebAssembly/sign-extension-ops>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_sign_extension_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_sign_extension(enable);
}
Expand All @@ -62,7 +58,6 @@ pub extern "C" fn wasmi_config_wasm_sign_extension_set(c: &mut wasm_config_t, en
/// Wraps [`wasmi::Config::wasm_saturating_float_to_int`]
///
/// [`nontrapping-float-to-int-conversions`]: <https://github.com/WebAssembly/nontrapping-float-to-int-conversions>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_saturating_float_to_int_set(
c: &mut wasm_config_t,
enable: bool,
Expand All @@ -75,7 +70,6 @@ pub extern "C" fn wasmi_config_wasm_saturating_float_to_int_set(
/// Wraps [`wasmi::Config::wasm_bulk_memory`]
///
/// [`bulk-memory-operations`]: <https://github.com/WebAssembly/bulk-memory-operations>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_bulk_memory_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_bulk_memory(enable);
}
Expand All @@ -85,7 +79,6 @@ pub extern "C" fn wasmi_config_wasm_bulk_memory_set(c: &mut wasm_config_t, enabl
/// Wraps [`wasmi::Config::wasm_reference_types`]
///
/// [`reference-types`]: <https://github.com/WebAssembly/reference-types>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_reference_types_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_reference_types(enable);
}
Expand All @@ -95,7 +88,6 @@ pub extern "C" fn wasmi_config_wasm_reference_types_set(c: &mut wasm_config_t, e
/// Wraps [`wasmi::Config::wasm_tail_call`]
///
/// [`tail-call`]: <https://github.com/WebAssembly/tail-call>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_tail_call_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_tail_call(enable);
}
Expand All @@ -105,23 +97,20 @@ pub extern "C" fn wasmi_config_wasm_tail_call_set(c: &mut wasm_config_t, enable:
/// Wraps [`wasmi::Config::wasm_extended_const`]
///
/// [`extended-const`]: <https://github.com/WebAssembly/extended-const>
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_wasm_extended_const_set(c: &mut wasm_config_t, enable: bool) {
c.inner.wasm_extended_const(enable);
}

/// Enables or disables support for floating point numbers for the config.
///
/// Wraps [`wasmi::Config::floats`]
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_floats_set(config: &mut wasm_config_t, enable: bool) {
config.inner.floats(enable);
}

/// Enables or disables fuel consumption for the config.
///
/// Wraps [`wasmi::Config::consume_fuel`]
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_consume_fuel_set(config: &mut wasm_config_t, enable: bool) {
config.inner.consume_fuel(enable);
}
Expand All @@ -140,7 +129,6 @@ pub enum wasmi_compilation_mode_t {
/// Sets the compilation mode for the config.
///
/// Wraps [`wasmi::Config::compilation_mode`]
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_compilation_mode_set(
config: &mut wasm_config_t,
mode: wasmi_compilation_mode_t,
Expand All @@ -156,7 +144,6 @@ pub extern "C" fn wasmi_config_compilation_mode_set(
/// Enables or disables processing of Wasm custom sections.
///
/// Wraps [`wasmi::Config::ignore_custom_sections`]
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_config_ignore_custom_sections_set(
config: &mut wasm_config_t,
enable: bool,
Expand Down
3 changes: 0 additions & 3 deletions crates/c_api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ wasmi_c_api_macros::declare_own!(wasm_engine_t);
/// The returned [`wasm_engine_t`] must be freed using [`wasm_engine_delete`].
///
/// Wraps [`wasmi::Engine::default`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
Box::new(wasm_engine_t {
inner: Engine::default(),
Expand All @@ -30,7 +29,6 @@ pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
/// The returned [`wasm_engine_t`] must be freed using [`wasm_engine_delete`].
///
/// Wraps [`wasmi::Engine::new`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_engine_new_with_config(config: Box<wasm_config_t>) -> Box<wasm_engine_t> {
Box::new(wasm_engine_t {
inner: Engine::new(&config.inner),
Expand All @@ -42,7 +40,6 @@ pub extern "C" fn wasm_engine_new_with_config(config: Box<wasm_config_t>) -> Box
/// The cloned [`wasm_engine_t`] has to be freed with [`wasm_engine_delete`] after use.
///
/// Wraps [`wasmi::Engine::clone`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasmi_engine_clone(engine: &wasm_engine_t) -> Box<wasm_engine_t> {
Box::new(engine.clone())
}
10 changes: 0 additions & 10 deletions crates/c_api/src/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub struct wasm_extern_t {
wasmi_c_api_macros::declare_ref!(wasm_extern_t);

/// Returns the [`wasm_extern_kind`] of the [`wasm_extern_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_kind(e: &wasm_extern_t) -> wasm_externkind_t {
match e.which {
Extern::Func(_) => wasm_externkind_t::WASM_EXTERN_FUNC,
Expand All @@ -38,7 +37,6 @@ pub extern "C" fn wasm_extern_kind(e: &wasm_extern_t) -> wasm_externkind_t {
///
/// It is the caller's responsibility not to alias the [`wasm_extern_t`]
/// with its underlying, internal [`WasmStoreRef`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externtype_t> {
Box::new(wasm_externtype_t::from_extern_type(
e.which.ty(e.store.context()),
Expand All @@ -48,63 +46,55 @@ pub unsafe extern "C" fn wasm_extern_type(e: &wasm_extern_t) -> Box<wasm_externt
/// Returns the [`wasm_extern_t`] as reference to mutable [`wasm_func_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_func_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_func(e: &mut wasm_extern_t) -> Option<&mut wasm_func_t> {
wasm_func_t::try_from_mut(e)
}

/// Returns the [`wasm_extern_t`] as reference to shared [`wasm_func_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_func_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_func_const(e: &wasm_extern_t) -> Option<&wasm_func_t> {
wasm_func_t::try_from(e)
}

/// Returns the [`wasm_extern_t`] as reference to mutable [`wasm_global_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_global_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_global(e: &mut wasm_extern_t) -> Option<&mut wasm_global_t> {
wasm_global_t::try_from_mut(e)
}

/// Returns the [`wasm_extern_t`] as reference to shared [`wasm_global_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_global_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_global_const(e: &wasm_extern_t) -> Option<&wasm_global_t> {
wasm_global_t::try_from(e)
}

/// Returns the [`wasm_extern_t`] as reference to mutable [`wasm_table_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_table_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_table(e: &mut wasm_extern_t) -> Option<&mut wasm_table_t> {
wasm_table_t::try_from_mut(e)
}

/// Returns the [`wasm_extern_t`] as reference to shared [`wasm_table_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_table_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_table_const(e: &wasm_extern_t) -> Option<&wasm_table_t> {
wasm_table_t::try_from(e)
}

/// Returns the [`wasm_extern_t`] as reference to mutable [`wasm_memory_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_memory_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_memory(e: &mut wasm_extern_t) -> Option<&mut wasm_memory_t> {
wasm_memory_t::try_from_mut(e)
}

/// Returns the [`wasm_extern_t`] as reference to shared [`wasm_memory_t`] if possible.
///
/// Returns `None` if `e` is not a [`wasm_memory_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_extern_as_memory_const(e: &wasm_extern_t) -> Option<&wasm_memory_t> {
wasm_memory_t::try_from(e)
}
1 change: 0 additions & 1 deletion crates/c_api/src/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ wasmi_c_api_macros::declare_ref!(wasm_foreign_t);
/// # Note
///
/// This API is unsupported and will panic upon use.
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_foreign_new(_store: &crate::wasm_store_t) -> Box<wasm_foreign_t> {
unimplemented!("wasm_foreign_new")
}
5 changes: 0 additions & 5 deletions crates/c_api/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ wasmi_c_api_macros::declare_own!(wasm_frame_t);
/// # Note
///
/// This API is unsupported and will panic upon use.
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_frame_func_index(_frame: &wasm_frame_t<'_>) -> u32 {
unimplemented!("wasm_frame_func_index")
}
Expand All @@ -26,7 +25,6 @@ pub extern "C" fn wasm_frame_func_index(_frame: &wasm_frame_t<'_>) -> u32 {
/// # Note
///
/// This API is unsupported and will panic upon use.
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_frame_func_offset(_frame: &wasm_frame_t<'_>) -> usize {
unimplemented!("wasm_frame_func_offset")
}
Expand All @@ -36,7 +34,6 @@ pub extern "C" fn wasm_frame_func_offset(_frame: &wasm_frame_t<'_>) -> usize {
/// # Note
///
/// This API is unsupported and will panic upon use.
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_frame_instance(_arg1: *const wasm_frame_t<'_>) -> *mut wasm_instance_t {
unimplemented!("wasm_frame_instance")
}
Expand All @@ -46,7 +43,6 @@ pub extern "C" fn wasm_frame_instance(_arg1: *const wasm_frame_t<'_>) -> *mut wa
/// # Note
///
/// This API is unsupported and will panic upon use.
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_frame_module_offset(_frame: &wasm_frame_t<'_>) -> usize {
unimplemented!("wasm_frame_module_offset")
}
Expand All @@ -56,7 +52,6 @@ pub extern "C" fn wasm_frame_module_offset(_frame: &wasm_frame_t<'_>) -> usize {
/// # Note
///
/// This API is unsupported and will panic upon use.
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_frame_copy<'a>(_frame: &wasm_frame_t<'a>) -> Box<wasm_frame_t<'a>> {
unimplemented!("wasm_frame_copy")
}
8 changes: 0 additions & 8 deletions crates/c_api/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ unsafe fn create_function(
///
/// It is the caller's responsibility not to alias the [`wasm_functype_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_func_new(
store: &mut wasm_store_t,
ty: &wasm_functype_t,
Expand All @@ -140,7 +139,6 @@ pub unsafe extern "C" fn wasm_func_new(
///
/// It is the caller's responsibility not to alias the [`wasm_functype_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_func_new_with_env(
store: &mut wasm_store_t,
ty: &wasm_functype_t,
Expand Down Expand Up @@ -183,7 +181,6 @@ fn prepare_params_and_results(
///
/// It is the caller's responsibility not to alias the [`wasm_func_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_func_call(
func: &mut wasm_func_t,
params: *const wasm_val_vec_t,
Expand Down Expand Up @@ -247,7 +244,6 @@ fn error_from_panic(panic: Box<dyn Any + Send>) -> Error {
///
/// It is the caller's responsibility not to alias the [`wasm_func_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_func_type(f: &wasm_func_t) -> Box<wasm_functype_t> {
Box::new(wasm_functype_t::new(f.func().ty(f.inner.store.context())))
}
Expand All @@ -262,7 +258,6 @@ pub unsafe extern "C" fn wasm_func_type(f: &wasm_func_t) -> Box<wasm_functype_t>
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
///
/// [`FuncType::params`]: wasmi::FuncType::params
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_func_param_arity(f: &wasm_func_t) -> usize {
f.func().ty(f.inner.store.context()).params().len()
}
Expand All @@ -277,19 +272,16 @@ pub unsafe extern "C" fn wasm_func_param_arity(f: &wasm_func_t) -> usize {
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
///
/// [`FuncType::results`]: wasmi::FuncType::results
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_func_result_arity(f: &wasm_func_t) -> usize {
f.func().ty(f.inner.store.context()).results().len()
}

/// Returns the [`wasm_func_t`] as mutable reference to [`wasm_extern_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_func_as_extern(f: &mut wasm_func_t) -> &mut wasm_extern_t {
&mut f.inner
}

/// Returns the [`wasm_func_t`] as shared reference to [`wasm_extern_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_func_as_extern_const(f: &wasm_func_t) -> &wasm_extern_t {
&f.inner
}
6 changes: 0 additions & 6 deletions crates/c_api/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ impl wasm_global_t {
///
/// It is the caller's responsibility not to alias the [`wasm_global_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_global_new(
store: &mut wasm_store_t,
ty: &wasm_globaltype_t,
Expand All @@ -69,13 +68,11 @@ pub unsafe extern "C" fn wasm_global_new(
}

/// Returns the [`wasm_global_t`] as mutable reference to [`wasm_extern_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_global_as_extern(g: &mut wasm_global_t) -> &mut wasm_extern_t {
&mut g.inner
}

/// Returns the [`wasm_global_t`] as shared reference to [`wasm_extern_t`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub extern "C" fn wasm_global_as_extern_const(g: &wasm_global_t) -> &wasm_extern_t {
&g.inner
}
Expand All @@ -88,7 +85,6 @@ pub extern "C" fn wasm_global_as_extern_const(g: &wasm_global_t) -> &wasm_extern
///
/// It is the caller's responsibility not to alias the [`wasm_global_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_global_type(g: &wasm_global_t) -> Box<wasm_globaltype_t> {
let globaltype = g.global().ty(g.inner.store.context());
Box::new(wasm_globaltype_t::new(globaltype))
Expand All @@ -102,7 +98,6 @@ pub unsafe extern "C" fn wasm_global_type(g: &wasm_global_t) -> Box<wasm_globalt
///
/// It is the caller's responsibility not to alias the [`wasm_global_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_global_get(g: &mut wasm_global_t, out: &mut MaybeUninit<wasm_val_t>) {
let global = g.global();
crate::initialize(
Expand All @@ -120,7 +115,6 @@ pub unsafe extern "C" fn wasm_global_get(g: &mut wasm_global_t, out: &mut MaybeU
/// - It is the caller's responsibility that `val` matches the type of `g`.
/// - It is the caller's responsibility not to alias the [`wasm_global_t`]
/// with its underlying, internal [`WasmStoreRef`](crate::WasmStoreRef).
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_global_set(g: &mut wasm_global_t, val: &wasm_val_t) {
let global = g.global();
drop(global.set(g.inner.store.context_mut(), val.to_val()));
Expand Down
2 changes: 0 additions & 2 deletions crates/c_api/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl wasm_instance_t {
/// with its underlying, internal [`WasmStoreRef`].
///
/// [Wasm core specification]: https://webassembly.github.io/spec/core/exec/modules.html#exec-instantiation
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_instance_new(
store: &mut wasm_store_t,
wasm_module: &wasm_module_t,
Expand Down Expand Up @@ -79,7 +78,6 @@ pub unsafe extern "C" fn wasm_instance_new(
///
/// It is the caller's responsibility not to alias the [`wasm_instance_t`]
/// with its underlying, internal [`WasmStoreRef`].
#[cfg_attr(not(feature = "mangle-symbols"), no_mangle)]
pub unsafe extern "C" fn wasm_instance_exports(
instance: &mut wasm_instance_t,
out: &mut wasm_extern_vec_t,
Expand Down
Loading

0 comments on commit 9ce88ee

Please sign in to comment.