1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

YJIT: Try cfg!(target_feature = "lse")

This commit is contained in:
Takashi Kokubun 2022-09-23 06:52:26 +09:00
parent 3a524f619b
commit 4e2a9ca9a9
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD
5 changed files with 5 additions and 37 deletions

View file

@ -3761,27 +3761,10 @@ AS_CASE(["${YJIT_SUPPORT}"],
])
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])
])
# 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]
)
])
AS_IF([test "$rb_cv_broken_yjit_stats" = yes], [AC_DEFINE(BROKEN_YJIT_STATS, 1)])
)
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])
]))
YJIT_LIBS="yjit/target/${rb_rust_target_subdir}/libyjit.a"
YJIT_OBJ='yjit.$(OBJEXT)'

10
yjit.c
View file

@ -998,16 +998,6 @@ rb_yjit_invalidate_all_method_lookup_assumptions(void)
// method caches, so we do nothing here for now.
}
bool
rb_yjit_stats_supported(void)
{
#if defined(BROKEN_YJIT_STATS)
return false;
#else
return true;
#endif
}
// Primitives used by yjit.rb
VALUE rb_yjit_stats_enabled_p(rb_execution_context_t *ec, VALUE self);
VALUE rb_yjit_trace_exit_locations_enabled_p(rb_execution_context_t *ec, VALUE self);

View file

@ -275,7 +275,6 @@ fn main() {
.allowlist_function("rb_ENCODING_GET")
.allowlist_function("rb_yjit_exit_locations_dict")
.allowlist_function("rb_yjit_icache_invalidate")
.allowlist_function("rb_yjit_stats_supported")
// from vm_sync.h
.allowlist_function("rb_vm_barrier")

View file

@ -1296,6 +1296,3 @@ extern "C" {
line: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn rb_yjit_stats_supported() -> bool;
}

View file

@ -1,5 +1,4 @@
use std::ffi::CStr;
use crate::cruby::rb_yjit_stats_supported;
// Command-line options
#[derive(Clone, PartialEq, Eq, Debug)]
@ -154,7 +153,7 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> {
("no-type-prop", "") => unsafe { OPTIONS.no_type_prop = true },
("stats", "") => {
if unsafe { !rb_yjit_stats_supported() } {
if cfg!(target_arch = "aarch64") && !cfg!(target_feature = "lse") {
eprintln!("Your processor does not support --yjit-stats. Aborting.");
std::process::exit(1);
}