diff --git a/src/convert.rs b/src/convert.rs index 5d2771e44..127d109e7 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -446,15 +446,6 @@ pub struct GlobalStack { next: usize, } -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]); - impl GlobalStack { #[inline] pub unsafe fn new() -> GlobalStack { @@ -465,20 +456,18 @@ impl GlobalStack { impl Stack for GlobalStack { #[inline] fn push(&mut self, val: u32) { + use __rt::{ + __wbindgen_global_argument_ptr as global_ptr, + GLOBAL_STACK_CAP, + }; unsafe { assert!(self.next < GLOBAL_STACK_CAP); - GLOBAL_STACK.0[self.next] = val; + *global_ptr().offset(self.next as isize) = val; self.next += 1; } } } -#[doc(hidden)] -#[no_mangle] -pub unsafe extern "C" fn __wbindgen_global_argument_ptr() -> *mut u32 { - GLOBAL_STACK.0.as_mut_ptr() -} - macro_rules! stack_closures { ($( ($($var:ident)*) )*) => ($( impl<'a, 'b, $($var,)* R> IntoWasmAbi for &'a (Fn($($var),*) -> R + 'b) diff --git a/src/lib.rs b/src/lib.rs index ab833c609..3d53bee42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -687,6 +687,20 @@ 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. ///