From 4bf037bebdc37671ca292dc8f500e1bede077163 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 7 Mar 2023 23:30:49 -0800 Subject: [PATCH] Update documentation about RJIT --- doc/rjit/rjit.md | 28 ++++++++++------------------ rjit.c | 4 +++- ruby.c | 6 +++--- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/doc/rjit/rjit.md b/doc/rjit/rjit.md index 1f847f61d5..22cd54dc4c 100644 --- a/doc/rjit/rjit.md +++ b/doc/rjit/rjit.md @@ -4,17 +4,10 @@ This document has some tips that might be useful when you work on RJIT. ## Supported platforms -The following platforms are either tested on CI or assumed to work. +The following platforms are assumed to work. `linux-x86_64` is tested on CI. -* OS: Linux, macOS -* Arch: x86\_64, aarch64, arm64, i686, i386 - -### Not supported - -The RJIT support for the following platforms is no longer maintained. - -* OS: Windows (mswin, MinGW), Solaris -* Arch: SPARC, s390x +* OS: Linux, macOS, BSD +* Arch: x86\_64 ## Developing RJIT @@ -25,15 +18,14 @@ If you see an "RJIT bindgen" GitHub Actions failure, please commit the `git diff For doing the same thing locally, run `make rjit-bindgen` after installing libclang. macOS seems to have libclang by default. On Ubuntu, you can install it with `apt install libclang1`. -### Always run make install +### --enable-rjit -Always run `make install` before running RJIT. It could easily cause a SEGV if you don't. -RJIT looks for the installed header for security reasons. +On supported platforms, `--enable-rjit` is set by default. You usually don't need to specify this. +You may still manually pass `--enable-rjit` to try RJIT on unsupported platforms. -### --rjit-debug vs --rjit-debug=-ggdb3 +### --enable-rjit=dev -`--rjit-debug=[flags]` allows you to specify arbitrary flags while keeping other compiler flags like `-O3`, -which is useful for profiling benchmarks. +`--enable-rjit=dev` makes the interpreter slower, but enables the following two features: -`--rjit-debug` alone, on the other hand, disables `-O3` and adds debug flags. -If you're debugging RJIT, what you need to use is not `--rjit-debug=-ggdb3` but `--rjit-debug`. +* `--rjit-dump-disasm`: Dump all JIT code. +* `--rjit-stats`: Print RJIT stats. diff --git a/rjit.c b/rjit.c index defc037169..1997db76ba 100644 --- a/rjit.c +++ b/rjit.c @@ -225,9 +225,11 @@ rjit_setup_options(const char *s, struct rjit_options *rjit_opt) #define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc) const struct ruby_opt_message rjit_option_messages[] = { +#if RJIT_STATS M("--rjit-stats", "", "Enable collecting RJIT statistics"), +#endif M("--rjit-call-threshold=num", "", "Number of calls to trigger JIT (default: " STRINGIZE(DEFAULT_CALL_THRESHOLD) ")"), -#if RUBY_DEBUG +#ifdef HAVE_LIBCAPSTONE M("--rjit-dump-disasm", "", "Dump all JIT code"), #endif {0} diff --git a/ruby.c b/ruby.c index 72b69e71a2..2aa3ab8c32 100644 --- a/ruby.c +++ b/ruby.c @@ -286,11 +286,11 @@ usage(const char *name, int help, int highlight, int columns) M("-W[level=2|:category]", "", "set warning level; 0=silence, 1=medium, 2=verbose"), M("-x[directory]", "", "strip off text before #!ruby line and perhaps cd to directory"), M("--jit", "", "enable JIT for the platform, same as " PLATFORM_JIT_OPTION), -#if USE_RJIT - M("--rjit", "", "enable C compiler-based JIT compiler (experimental)"), -#endif #if USE_YJIT M("--yjit", "", "enable in-process JIT compiler"), +#endif +#if USE_RJIT + M("--rjit", "", "enable pure-Ruby JIT compiler (experimental)"), #endif M("-h", "", "show this message, --help for more info"), };