mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-25 11:02:11 +03:00
Move __wbindgen_global_argument_ptr around (#494)
Make sure it's in the same module as our "link hack" to ensure it's always linked in. Closes #492
This commit is contained in:
parent
c26caf6354
commit
9218c40613
@ -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)
|
||||
|
14
src/lib.rs
14
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.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user