Implement WASI preview 2 plugin RFC by jeffcharles · Pull Request #958 · bytecodealliance/javy

Description of the change

This implements #962 to have plugins target WASI preview 2. This would represent a breaking change for the Javy plugin API in the following ways:

  • plugins now need to be compiled to WASI preview 2 instead of WASI preview 1 and export particular functions with particular types in their WIT definitions
  • compile_src: func(bytecode_ptr: u32, bytecode_len: u32) -> () becomes compile-src: func(bytecode: list<u8>) -> result<list<u8>, string>
  • initialize_runtime: func() -> () becomes initialize-runtime: func() -> ()
  • invoke: func(bytecode_ptr: u32, bytecode_len: u32, fn_name_ptr: u32, fn_name_len: u32) -> () becomes invoke: func(bytecode: list<u8>, function: option<string>);
  • canonical_abi_realloc(old_ptr: u32, old_size: u32, alignment: u32, new_size: u32) becomes cabi_realloc(old_ptr: u32, old_size: u32, alignment: u32, new_size: u32)

Why am I making this change?

WASI preview 1 will be deprecated at some point in the future. We should use WASI preview 2 to ensure we can continue to compile Javy.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-plugin do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.