Skip to content

Commit

Permalink
Update documentation about RJIT
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Mar 8, 2023
1 parent e93e780 commit 4bf037b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
28 changes: 10 additions & 18 deletions doc/rjit/rjit.md
Expand Up @@ -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

Expand All @@ -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.
4 changes: 3 additions & 1 deletion rjit.c
Expand Up @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions ruby.c
Expand Up @@ -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"),
};
Expand Down

0 comments on commit 4bf037b

Please sign in to comment.