1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-06-23 01:31:34 +00:00

Don't use the global stack for string lengths

This commit updates the `Abi` associated type for all slice types to a
`WasmSlice` type, an aggregate of two `u32` integers. This translates to an ABI
where when passed as a function argument it expands to two integer arguments,
and when passed as a return value it passes a return pointer as the first
argument to get filled in.

This is hopefully more forwards-compatible with the host bindings proposal which
uses this strategy for passing string arguments at least. It's a little sketchy
what we're doing as there's not really a stable ABI yet, but hopefully this'll
all be relatively stable for awhile!
This commit is contained in:
Alex Crichton
2018-05-02 21:03:50 -07:00
parent 4304a262c6
commit 139b7a1aae
5 changed files with 137 additions and 105 deletions
crates/cli-support/src/js
src
tests/all

@ -1318,21 +1318,6 @@ impl<'a> Context<'a> {
}
}
fn expose_set_global_argument(&mut self) -> Result<(), Error> {
if !self.exposed_globals.insert("set_global_argument") {
return Ok(());
}
self.expose_uint32_memory();
self.expose_global_argument_ptr()?;
self.global("
function setGlobalArgument(arg, i) {
const idx = globalArgumentPtr() / 4 + i;
getUint32Memory()[idx] = arg;
}
");
Ok(())
}
fn expose_get_global_argument(&mut self) -> Result<(), Error> {
if !self.exposed_globals.insert("get_global_argument") {
return Ok(());