Closed douchuan closed 4 years ago
My mistake, just ignore it.
The exact bug is: can't get the second arg's val .
I declare extensions like this:
mod env {
extern "C" {
pub fn add_u32(a: u32, b: u32) -> u32;
}
}
and, used it like this:
wasm3::make_func_wrapper!(add_u32_wrap: add_u32(a: u32, b: u32) -> u32);
fn add_u32(a: u32, b: u32) -> u32 {
a + b
}
the 'b''s value isn't right.
I check wasm3 code, found:
m3_compile.c, CompileCallArgsAndReturn, say:
u32 slotsPerArg = sizeof (u64) / sizeof (m3slot_t);
// args are 64-bit aligned
u16 argTop = topSlot + numArgs * slotsPerArg;
so, the value SIZE_IN_SLOT_COUNT of u32/i32/f32, should be '2'
Ah yes, I also noticed this probably earlier today, https://github.com/Veykril/wasm3-rs/issues/12. Can you try with default features off and see if the problem persists?
[dependencies.wasm3]
git = "https://github.com/Veykril/wasm3-rs"
default-features = false
it's ok with 'default-features = false'
Thanks, it worked for me, great work.
Aight, thanks for confirming 😄
What exactly does this fix?
ptr::add
work in units of T, so this change offsets the pointer bysize_of::<u32/u64> * size_of::<ParamterType>
which is very much wrong to my knowledge.