Ensure that JsValue isn't considered Send

The `JsValue` type wraps a slab/heap of js objects which is managed by
the wasm-bindgen shim, and everything here is not actually able to cross
any thread boundaries. When wasm actually has threads, for example, each
thread will have to have its own slab of objects generated by
wasm-bindgen, and indices in one slab aren't valid in any other slabs.

This is technically a breaking change because `JsValue` was previously
`Send` and `Sync`, but I'm hoping that in practice this isn't actually a
breaking change because nothing in wasm can be using threads which in
theory shouldn't activate the `Send` and/or `Sync` bounds.
This commit is contained in:
Alex Crichton
2018-10-10 12:50:54 -07:00
parent 70e13705b4
commit e46537e6c2
4 changed files with 46 additions and 56 deletions

View File

@ -1042,11 +1042,9 @@ impl ToTokens for ast::ImportStatic {
fn init() -> #ty {
panic!("cannot access imported statics on non-wasm targets")
}
static mut _VAL: ::wasm_bindgen::__rt::core::cell::UnsafeCell<Option<#ty>> =
::wasm_bindgen::__rt::core::cell::UnsafeCell::new(None);
thread_local!(static _VAL: #ty = init(););
::wasm_bindgen::JsStatic {
__inner: unsafe { &_VAL },
__init: init,
__inner: &_VAL,
}
};
}).to_tokens(into);