Remove __wbindgen_global_argument_ptr intrinsic

We don't actually need this since we can simply pass in a number like 8
for the return pointer all the time. There's no need to allocate more
space in static data for a return pointer tha may not even get used!
This commit is contained in:
Alex Crichton 2019-06-25 05:24:08 -07:00
parent e16dd15697
commit eb550f5b4f
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;

View File

@ -1017,20 +1017,6 @@ pub mod __rt {
}
}
pub const GLOBAL_STACK_CAP: usize = 16;
// Increase the alignment to 8 here because this can be used as a
// BigUint64Array pointer base which requires alignment 8
#[repr(align(8))]
struct GlobalData([u32; GLOBAL_STACK_CAP]);
static mut GLOBAL_STACK: GlobalData = GlobalData([0; GLOBAL_STACK_CAP]);
#[no_mangle]
pub unsafe extern "C" fn __wbindgen_global_argument_ptr() -> *mut u32 {
GLOBAL_STACK.0.as_mut_ptr()
}
/// This is a curious function necessary to get wasm-bindgen working today,
/// and it's a bit of an unfortunate hack.
///