diff --git a/crates/cli-support/src/js/binding.rs b/crates/cli-support/src/js/binding.rs index c011a9bb..602d133f 100644 --- a/crates/cli-support/src/js/binding.rs +++ b/crates/cli-support/src/js/binding.rs @@ -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()); } diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 01d10087..1307ad8a 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -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; diff --git a/src/lib.rs b/src/lib.rs index 969269ed..487652f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. ///