Thanks to visit codestin.com
Credit goes to github.com

Skip to content

YJIT: Support Rust 1.58.1 for --yjit-stats on Arm #6410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ yjit_task:
matrix:
- CC: clang-12
configure: --enable-yjit=dev
rustup_init: --default-toolchain=1.58.1
- CC: gcc-11
configure: --enable-yjit
id_script: id
Expand All @@ -107,7 +108,7 @@ yjit_task:
install_rust_script:
- sudo apt-get update -y
- sudo apt-get install -y curl
- "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
- "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y $rustup_init"
autogen_script: ./autogen.sh
configure_script: >-
source $HOME/.cargo/env && ./configure -C
Expand Down
35 changes: 28 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3748,23 +3748,44 @@ AS_CASE(["${YJIT_SUPPORT}"],
],
[dev], [
rb_rust_target_subdir=debug
CARGO_BUILD_ARGS='--features stats,disasm,asm_comments'
CARGO_BUILD_ARGS='--features disasm,asm_comments'
AC_DEFINE(RUBY_DEBUG, 1)
],
[dev_nodebug], [
rb_rust_target_subdir=dev_nodebug
CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm,asm_comments'
CARGO_BUILD_ARGS='--profile dev_nodebug --features disasm,asm_comments'
],
[stats], [
rb_rust_target_subdir=stats
CARGO_BUILD_ARGS='--profile stats --features stats'
CARGO_BUILD_ARGS='--profile stats'
])

AS_IF([test -n "${CARGO_BUILD_ARGS}"], [
AC_CHECK_TOOL(CARGO, [cargo], [no])
AS_IF([test x"$CARGO" = "xno"],
AC_MSG_ERROR([cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install])
]))
AC_CHECK_TOOL(CARGO, [cargo], [no])
AS_IF([test x"$CARGO" = "xno"],
AC_MSG_ERROR([cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install])
])

# Insn::IncrCounter uses ldaddal, which works only on ARMv8.1+.
AC_CACHE_CHECK(yjit stats are broken, rb_cv_broken_yjit_stats, [
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[]], [[
@%:@ifdef __aarch64__
asm volatile(".arch armv8-a+lse\n"
"ldaddal xzr, xzr, @<:@sp@:>@");
@%:@endif
]])],
[rb_cv_broken_yjit_stats=no],
[rb_cv_broken_yjit_stats=yes],
[rb_cv_broken_yjit_stats=yes]
)
])
# This won't enable stats in release builds because we don't use cargo
# for release builds, use rustc directly
AS_IF([test "$rb_cv_broken_yjit_stats" = no], [
CARGO_BUILD_ARGS="${CARGO_BUILD_ARGS} --features stats"
])
)

YJIT_LIBS="yjit/target/${rb_rust_target_subdir}/libyjit.a"
YJIT_OBJ='yjit.$(OBJEXT)'
Expand Down
14 changes: 1 addition & 13 deletions yjit/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,7 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> {

("greedy-versioning", "") => unsafe { OPTIONS.greedy_versioning = true },
("no-type-prop", "") => unsafe { OPTIONS.no_type_prop = true },

("stats", "") => {
// Insn::IncrCounter uses ldaddal, which works only on ARMv8.1+.
#[cfg(feature = "stats")]
#[cfg(target_arch = "aarch64")]
if !std::arch::is_aarch64_feature_detected!("lse") {
eprintln!("Your processor does not support --yjit-stats. Aborting.");
std::process::exit(1);
}

unsafe { OPTIONS.gen_stats = true }
},

("stats", "") => unsafe { OPTIONS.gen_stats = true },
("trace-exits", "") => unsafe { OPTIONS.gen_trace_exits = true; OPTIONS.gen_stats = true },
("dump-insns", "") => unsafe { OPTIONS.dump_insns = true },
("verify-ctx", "") => unsafe { OPTIONS.verify_ctx = true },
Expand Down