mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Merge pull request #1306 from alexcrichton/encode-into-shared
Fix `passStringToWasm` with shared memory
This commit is contained in:
commit
18440a562e
@ -1211,21 +1211,20 @@ impl<'a> Context<'a> {
|
||||
debug
|
||||
);
|
||||
|
||||
// Looks like `encodeInto` doesn't currently work when the memory passed
|
||||
// in is backed by a `SharedArrayBuffer`, so force usage of `encode` if
|
||||
// a `SharedArrayBuffer` is in use.
|
||||
let shared = self.module.memories.get(self.memory).shared;
|
||||
|
||||
match self.config.encode_into {
|
||||
EncodeInto::Never => {
|
||||
self.global(&format!(
|
||||
"function passStringToWasm(arg) {{ {} }}",
|
||||
use_encode,
|
||||
));
|
||||
}
|
||||
EncodeInto::Always => {
|
||||
EncodeInto::Always if !shared => {
|
||||
self.require_internal_export("__wbindgen_realloc")?;
|
||||
self.global(&format!(
|
||||
"function passStringToWasm(arg) {{ {} }}",
|
||||
use_encode_into,
|
||||
));
|
||||
}
|
||||
EncodeInto::Test => {
|
||||
EncodeInto::Test if !shared => {
|
||||
self.require_internal_export("__wbindgen_realloc")?;
|
||||
self.global(&format!(
|
||||
"
|
||||
@ -1240,6 +1239,12 @@ impl<'a> Context<'a> {
|
||||
use_encode,
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
self.global(&format!(
|
||||
"function passStringToWasm(arg) {{ {} }}",
|
||||
use_encode,
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user