ruby-changes:73230
From: Alan <ko1@a...>
Date: Tue, 30 Aug 2022 01:03:22 +0900 (JST)
Subject: [ruby-changes:73230] 869b0ba6e0 (master): Minor cleanups (https://github.com/Shopify/ruby/pull/345)
https://git.ruby-lang.org/ruby.git/commit/?id=869b0ba6e0 From 869b0ba6e00168d739830af766c3abb0dec01f12 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Thu, 28 Jul 2022 11:08:30 -0400 Subject: Minor cleanups (https://github.com/Shopify/ruby/pull/345) * 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. --- yjit/src/backend/ir.rs | 4 ++-- yjit/src/codegen.rs | 4 ++-- yjit/src/core.rs | 8 ++++---- yjit/src/utils.rs | 6 ++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs index dc0e450df4..ce82161693 100644 --- a/yjit/src/backend/ir.rs +++ b/yjit/src/backend/ir.rs @@ -796,9 +796,9 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L796 } //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))); } } diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index b34cc7409a..93d835d7f1 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -297,9 +297,9 @@ fn jit_prepare_routine_call( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L297 /// 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, diff --git a/yjit/src/core.rs b/yjit/src/core.rs index 1afa5c537a..3b33360b90 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -1814,10 +1814,10 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1814 // 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 https://github.com/ruby/ruby/blob/trunk/yjit/src/core.rs#L1827 // 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); - })); + }); } } diff --git a/yjit/src/utils.rs b/yjit/src/utils.rs index 5f42ba1fdb..bea57e4fc2 100644 --- a/yjit/src/utils.rs +++ b/yjit/src/utils.rs @@ -122,14 +122,12 @@ yjit_print_iseq(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/yjit/src/utils.rs#L122 #[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; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/