Merge pull request #1625 from alexcrichton/less-return-ptr

Remove `__wbindgen_global_argument_ptr` intrinsic
This commit is contained in:
Alex Crichton
2019-06-26 13:36:57 +02:00
committed by GitHub
3 changed files with 11 additions and 38 deletions

View File

@ -118,14 +118,20 @@ impl<'a, 'b> Builder<'a, 'b> {
if incoming_args {
let mut webidl_params = webidl.params.iter();
// If we're returning via an out pointer then it's guaranteed to be the
// first argument. This isn't an argument of the function shim we're
// generating so synthesize the parameter and its value.
// If we're returning via an out pointer then it's guaranteed to be
// the first argument. This isn't an argument of the function shim
// we're generating so synthesize the parameter and its value.
//
// For the actual value of the return pointer we just pick the first
// properly aligned nonzero address. We use the address for a
// BigInt64Array sometimes which means it needs to be 8-byte
// aligned. Otherwise valid code is unlikely to ever be working
// around address 8, so this should be a safe address to use for
// returning data through.
if binding.return_via_outptr.is_some() {
drop(webidl_params.next());
self.cx.expose_global_argument_ptr()?;
self.args_prelude
.push_str("const retptr = globalArgumentPtr();\n");
.push_str("const retptr = 8;\n");
arg_names.push("retptr".to_string());
}

View File

@ -1558,25 +1558,6 @@ impl<'a> Context<'a> {
})
}
fn expose_global_argument_ptr(&mut self) -> Result<(), Error> {
if !self.should_write_global("global_argument_ptr") {
return Ok(());
}
self.require_internal_export("__wbindgen_global_argument_ptr")?;
self.global(
"
let cachedGlobalArgumentPtr = null;
function globalArgumentPtr() {
if (cachedGlobalArgumentPtr === null) {
cachedGlobalArgumentPtr = wasm.__wbindgen_global_argument_ptr();
}
return cachedGlobalArgumentPtr;
}
",
);
Ok(())
}
fn expose_get_inherited_descriptor(&mut self) {
if !self.should_write_global("get_inherited_descriptor") {
return;