Skip to content

Commit

Permalink
Ever-so-slightly tweak call_builtin macro. (bytecodealliance#153)
Browse files Browse the repository at this point in the history
This patch improves the local names used within the `call_builtin` ever-so-slightly.
  • Loading branch information
dhil authored Apr 4, 2024
1 parent 6b66235 commit 84b551e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions crates/cranelift/src/wasmfx/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ use cranelift_frontend::FunctionBuilder;
#[allow(unused_macros)]
macro_rules! call_builtin {
( $builder:ident, $env:ident, $f:ident( $($args:expr),* ) ) => (
let _fname = $env.builtin_functions.$f(&mut $builder.func);
let _vmctx_libcall_arg = $env.vmctx_val(&mut $builder.cursor());
let _call_inst = $builder.ins().call(_fname, &[_vmctx_libcall_arg, $( $args ), * ]);
{
let fname = $env.builtin_functions.$f(&mut $builder.func);
let vmctx = $env.vmctx_val(&mut $builder.cursor());
$builder.ins().call(fname, &[vmctx, $( $args ), * ]);
}
);
( $builder:ident, $env:ident, let $name:ident = $f:ident( $($args:expr),* ) )=> (
let _fname = $env.builtin_functions.$f(&mut $builder.func);
let _vmctx_libcall_arg = $env.vmctx_val(&mut $builder.cursor());
let _call_inst = $builder.ins().call(_fname, &[_vmctx_libcall_arg, $( $args ), * ]);
let $name = *$builder.func.dfg.inst_results(_call_inst).first().unwrap();
let $name = {
let fname = $env.builtin_functions.$f(&mut $builder.func);
let vmctx = $env.vmctx_val(&mut $builder.cursor());
let call_inst = $builder.ins().call(fname, &[vmctx, $( $args ), * ]);
*$builder.func.dfg.inst_results(call_inst).first().unwrap()
};
);
}

Expand Down

0 comments on commit 84b551e

Please sign in to comment.