1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
* Move allocation into Assembler::pos_marker

We wanted to do this to begin with but didn't because we were confused
about the lifetime parameter. It's actually talking about the lifetime
of the references that the closure captures. Since all of our usages
capture no references (they use `move`), it's fine to put a `+ 'static`
here.

* Use optional token syntax for calling convention macro

* Explicitly request C ABI on ARM

It looks like the Rust calling convention for functions are the same as
the C ABI for now and it's unlikely to change, but it's easy for us to
be explicit here. I also tried saying `extern "aapcs"` but that
unfortunately doesn't work.
This commit is contained in:
Alan Wu 2022-07-28 11:08:30 -04:00 committed by Takashi Kokubun
parent 6ab71a8598
commit 869b0ba6e0
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD
4 changed files with 10 additions and 12 deletions

View file

@ -796,9 +796,9 @@ impl Assembler
}
//pub fn pos_marker<F: FnMut(CodePtr)>(&mut self, marker_fn: F)
pub fn pos_marker(&mut self, marker_fn: PosMarkerFn)
pub fn pos_marker(&mut self, marker_fn: impl Fn(CodePtr) + 'static)
{
self.push_insn(Op::PosMarker, vec![], None, None, Some(marker_fn));
self.push_insn(Op::PosMarker, vec![], None, None, Some(Box::new(marker_fn)));
}
}

View file

@ -297,9 +297,9 @@ fn jit_prepare_routine_call(
/// Record the current codeblock write position for rewriting into a jump into
/// the outlined block later. Used to implement global code invalidation.
fn record_global_inval_patch(asm: &mut Assembler, outline_block_target_pos: CodePtr) {
asm.pos_marker(Box::new(move |code_ptr| {
asm.pos_marker(move |code_ptr| {
CodegenGlobals::push_global_inval_patch(code_ptr, outline_block_target_pos);
}));
});
}
/// Verify the ctx's types and mappings against the compile-time stack, self,

View file

@ -1814,10 +1814,10 @@ impl Assembler
// so that we can move the closure below
let branchref = branchref.clone();
self.pos_marker(Box::new(move |code_ptr| {
self.pos_marker(move |code_ptr| {
let mut branch = branchref.borrow_mut();
branch.start_addr = Some(code_ptr);
}));
});
}
// Mark the end position of a patchable branch in the machine code
@ -1827,10 +1827,10 @@ impl Assembler
// so that we can move the closure below
let branchref = branchref.clone();
self.pos_marker(Box::new(move |code_ptr| {
self.pos_marker(move |code_ptr| {
let mut branch = branchref.borrow_mut();
branch.end_addr = Some(code_ptr);
}));
});
}
}

View file

@ -122,14 +122,12 @@ yjit_print_iseq(const rb_iseq_t *iseq)
#[cfg(target_arch = "aarch64")]
macro_rules! c_callable {
(fn $f:ident $args:tt -> $ret:ty $body:block) => { fn $f $args -> $ret $body };
(fn $f:ident $args:tt $body:block) => { fn $f $args $body };
(fn $f:ident $args:tt $(-> $ret:ty)? $body:block) => { extern "C" fn $f $args $(-> $ret)? $body };
}
#[cfg(target_arch = "x86_64")]
macro_rules! c_callable {
(fn $f:ident $args:tt -> $ret:ty $body:block) => { extern "sysv64" fn $f $args -> $ret $body };
(fn $f:ident $args:tt $body:block) => { extern "sysv64" fn $f $args $body };
(fn $f:ident $args:tt $(-> $ret:ty)? $body:block) => { extern "sysv64" fn $f $args $(-> $ret)? $body };
}
pub(crate) use c_callable;