I think func_builder.ins().store(mem_flags, r_ptr, val1, *r0 as i32 * MEM_CELL_SIZE);
got the order of the pointer and the value wrong. Same for func_builder.ins().store(mem_flags, r_ptr, constants[*c], *r0 as i32 * MEM_CELL_SIZE);
.
By the way use CallConv::SystemV instead of CallConv::Fast. The latter is currently identical to the former, but unlike the former it is explicitly not guaranteed to be stable between Cranelift versions, nor guaranteed to be identical to any call conv that Rust can call, so you can't use it for functions that need to be called from Rust as opposed to from other Cranelift compiled code.
Also it seems like you are forgetting to pass the length argument when calling the compiled function.
oh shoot it was that simple? :)
Last updated: Dec 23 2024 at 13:07 UTC