mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 20:41:24 +00:00
Merge pull request #1625 from alexcrichton/less-return-ptr
Remove `__wbindgen_global_argument_ptr` intrinsic
This commit is contained in:
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user