Skip to content

Commit

Permalink
s/MJIT/RJIT/
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Mar 7, 2023
1 parent eaccdc1 commit 2e87554
Show file tree
Hide file tree
Showing 87 changed files with 744 additions and 744 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compilers.yml
Expand Up @@ -197,7 +197,7 @@ jobs:
# - { name: VM_DEBUG_BP_CHECK, env: { cppflags: '-DVM_DEBUG_BP_CHECK' } }
# - { name: VM_DEBUG_VERIFY_METHOD_CACHE, env: { cppflags: '-DVM_DEBUG_VERIFY_METHOD_CACHE' } }

- { name: MJIT_FORCE_ENABLE, env: { cppflags: '-DMJIT_FORCE_ENABLE' } }
- { name: RJIT_FORCE_ENABLE, env: { cppflags: '-DRJIT_FORCE_ENABLE' } }
- { name: YJIT_FORCE_ENABLE, env: { cppflags: '-DYJIT_FORCE_ENABLE' } }

name: ${{ matrix.entry.name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rjit-bindgen.yml
@@ -1,4 +1,4 @@
name: MJIT bindgen
name: RJIT bindgen
on:
push:
paths-ignore:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rjit.yml
@@ -1,4 +1,4 @@
name: MJIT
name: RJIT
on:
push:
paths-ignore:
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
payload: |
{
"ci": "GitHub Actions",
"env": "MJIT / ${{ matrix.run_opts }}",
"env": "RJIT / ${{ matrix.run_opts }}",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"commit": "${{ github.sha }}",
"branch": "${{ github.ref_name }}"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -238,7 +238,7 @@ lcov*.info
# /win32/
/win32/*.ico

# MJIT
# RJIT
/include/ruby-*/*/rb_mjit_min_header-*.h
/lib/ruby_vm/mjit/instruction.rb
/lib/ruby_vm/rjit/instruction.rb
Expand Down
2 changes: 1 addition & 1 deletion README.ja.md
@@ -1,5 +1,5 @@
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
[![Actions Status: MJIT](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MJIT")
[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,5 +1,5 @@
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
[![Actions Status: MJIT](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MJIT")
[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
Expand Down
2 changes: 1 addition & 1 deletion bootstraptest/runner.rb
Expand Up @@ -669,7 +669,7 @@ def assert_normal_exit(testsrc, *rest, timeout: nil, **opt)

def assert_finish(timeout_seconds, testsrc, message = '')
add_assertion testsrc, -> as do
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait
timeout_seconds *= 3
end

Expand Down
2 changes: 1 addition & 1 deletion bootstraptest/test_gc.rb
Expand Up @@ -14,7 +14,7 @@
o.send(meth)
end
end
}, '[ruby-dev:39453]' unless ENV.fetch('RUN_OPTS', '').include?('mjit') # speed up MJIT CI
}, '[ruby-dev:39453]' unless ENV.fetch('RUN_OPTS', '').include?('mjit') # speed up RJIT CI

assert_normal_exit %q{
a = []
Expand Down
6 changes: 3 additions & 3 deletions bootstraptest/test_yjit.rb
Expand Up @@ -2244,7 +2244,7 @@ def events.compiled(obj)
events.compiled(events)
events
} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods

# test enabling a TracePoint that targets a particular line in a C method call
assert_equal '[true]', %q{
Expand Down Expand Up @@ -2326,7 +2326,7 @@ def shouldnt_compile
tp.enable { shouldnt_compile }
events
} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods

# test enabling c_return tracing before compiling
assert_equal '[[:c_return, :itself, main]]', %q{
Expand All @@ -2341,7 +2341,7 @@ def shouldnt_compile
tp.enable { shouldnt_compile }
events
} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods

# test c_call invalidation
assert_equal '[[:c_call, :itself]]', %q{
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Expand Up @@ -360,7 +360,7 @@ ruby.imp: $(COMMONOBJS)
$(NM) -Pgp $(COMMONOBJS) | \
awk 'BEGIN{print "#!"}; $$2~/^[A-TV-Z]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \
($(CHDIR) $(srcdir) && \
exec sed -n '/^MJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
exec sed -n '/^RJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
} | \
sort -u -o $@

Expand Down
44 changes: 22 additions & 22 deletions configure.ac
Expand Up @@ -405,19 +405,19 @@ AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)
AC_SUBST(CSRCFLAG)

: ${MJIT_CC=$CC}
: ${RJIT_CC=$CC}
AS_IF([test "x$cross_compiling" = xno], [
AC_PATH_PROG([MJIT_CC], ${MJIT_CC})
AC_PATH_PROG([RJIT_CC], ${RJIT_CC})
# if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache)
AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null &&
echo $MJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` MJIT_CC=`which $CC`])
echo $RJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` RJIT_CC=`which $CC`])
AS_CASE([$target_os],
[*mingw*], [command -v cygpath > /dev/null && MJIT_CC=`cygpath -ma $MJIT_CC`])
[*mingw*], [command -v cygpath > /dev/null && RJIT_CC=`cygpath -ma $RJIT_CC`])
shift 2
MJIT_CC="$MJIT_CC${1+ }$*"
RJIT_CC="$RJIT_CC${1+ }$*"
])

AS_CASE(["$build_os"],
Expand Down Expand Up @@ -1236,7 +1236,7 @@ main()
AS_CASE(["$target_cpu"], [powerpc64*], [
ac_cv_func___builtin_setjmp=no
])
# With gcc-8's -fcf-protection, MJIT's __builtin_longjmp fails.
# With gcc-8's -fcf-protection, RJIT's __builtin_longjmp fails.
AS_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no])
AS_IF([test "$cf_protection" = yes], [
ac_cv_func___builtin_setjmp=no
Expand Down Expand Up @@ -2927,14 +2927,14 @@ LIBEXT=a

AC_SUBST(DLDFLAGS)dnl
AC_SUBST(ARCH_FLAG)dnl
AC_SUBST(MJIT_CC)dnl
AC_SUBST(RJIT_CC)dnl
AS_CASE(["$GCC:$target_os"],
[yes:aix*], [mjit_std_cflag="-std=gnu99"],
[mjit_std_cflag=])
AC_SUBST(MJIT_CFLAGS, [${MJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
AC_SUBST(MJIT_OPTFLAGS, [${MJIT_OPTFLAGS-'$(optflags)'}])dnl
AC_SUBST(MJIT_DEBUGFLAGS, [${MJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
AC_SUBST(MJIT_LDSHARED)dnl
AC_SUBST(RJIT_CFLAGS, [${RJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
AC_SUBST(RJIT_OPTFLAGS, [${RJIT_OPTFLAGS-'$(optflags)'}])dnl
AC_SUBST(RJIT_DEBUGFLAGS, [${RJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
AC_SUBST(RJIT_LDSHARED)dnl

AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
Expand Down Expand Up @@ -3727,13 +3727,13 @@ AC_SUBST(INSTALLDOC)

AC_ARG_ENABLE(jit-support,
AS_HELP_STRING([--disable-jit-support], [disable JIT features]),
[MJIT_SUPPORT=$enableval],
[RJIT_SUPPORT=$enableval],
[AS_CASE(["$target_os"],
[wasi | mingw* | solaris*], [MJIT_SUPPORT=no],
[MJIT_SUPPORT=yes]
[wasi | mingw* | solaris*], [RJIT_SUPPORT=no],
[RJIT_SUPPORT=yes]
)])

AC_SUBST(MJIT_SUPPORT)
AC_SUBST(RJIT_SUPPORT)

AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix

Expand Down Expand Up @@ -3835,15 +3835,15 @@ AS_CASE(["${YJIT_SUPPORT}"],
AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT])
])
AC_DEFINE(USE_YJIT, 1)
AC_DEFINE(USE_MJIT, 1)
AC_DEFINE(USE_RJIT, 1)
], [
AC_DEFINE(USE_YJIT, 0)
AC_DEFINE(USE_MJIT, 0)
AC_DEFINE(USE_RJIT, 0)
])
# If YJIT links capstone, libcapstone stops working on the C side.
# capstone should be linked for MJIT only when YJIT doesn't.
AS_IF([test x"$MJIT_SUPPORT" = "xyes" -a -z "$CARGO_BUILD_ARGS" ], [
# capstone should be linked for RJIT only when YJIT doesn't.
AS_IF([test x"$RJIT_SUPPORT" = "xyes" -a -z "$CARGO_BUILD_ARGS" ], [
AC_CHECK_LIB([capstone], [cs_disasm])
])
Expand Down Expand Up @@ -4054,7 +4054,7 @@ AS_IF([test "${universal_binary-no}" = yes ], [
[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no]))
])
: ${MJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(MJIT_CC)|g']`}
: ${RJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(RJIT_CC)|g']`}
MAINLIBS="$LIBS"
LIBS=$ORIG_LIBS
Expand Down Expand Up @@ -4541,7 +4541,7 @@ config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags"
config_summary "strip command" "$STRIP"
config_summary "install doc" "$DOCTARGETS"
config_summary "MJIT support" "$MJIT_SUPPORT"
config_summary "RJIT support" "$RJIT_SUPPORT"
config_summary "YJIT support" "$YJIT_SUPPORT"
config_summary "man page type" "$MANTYPE"
config_summary "search path" "$search_path"
Expand Down
2 changes: 1 addition & 1 deletion defs/gmake.mk
Expand Up @@ -13,7 +13,7 @@ endif

ifneq ($(filter darwin%,$(target_os)),)
# Remove debug option not to generate thousands of .dSYM
MJIT_DEBUGFLAGS := $(filter-out -g%,$(MJIT_DEBUGFLAGS))
RJIT_DEBUGFLAGS := $(filter-out -g%,$(RJIT_DEBUGFLAGS))

INSTRUBY_ENV += SDKROOT=
endif
Expand Down
16 changes: 8 additions & 8 deletions doc/rjit/rjit.md
@@ -1,6 +1,6 @@
# MJIT
# RJIT

This document has some tips that might be useful when you work on MJIT.
This document has some tips that might be useful when you work on RJIT.

## Supported platforms

Expand All @@ -11,29 +11,29 @@ The following platforms are either tested on CI or assumed to work.

### Not supported

The MJIT support for the following platforms is no longer maintained.
The RJIT support for the following platforms is no longer maintained.

* OS: Windows (mswin, MinGW), Solaris
* Arch: SPARC, s390x

## Developing MJIT
## Developing RJIT

### Bindgen

If you see an "MJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.
If you see an "RJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.

For doing the same thing locally, run `make mjit-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

Always run `make install` before running MJIT. It could easily cause a SEGV if you don't.
MJIT looks for the installed header for security reasons.
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.

### --mjit-debug vs --mjit-debug=-ggdb3

`--mjit-debug=[flags]` allows you to specify arbitrary flags while keeping other compiler flags like `-O3`,
which is useful for profiling benchmarks.

`--mjit-debug` alone, on the other hand, disables `-O3` and adds debug flags.
If you're debugging MJIT, what you need to use is not `--mjit-debug=-ggdb3` but `--mjit-debug`.
If you're debugging RJIT, what you need to use is not `--mjit-debug=-ggdb3` but `--mjit-debug`.
2 changes: 1 addition & 1 deletion inits.c
Expand Up @@ -105,7 +105,7 @@ rb_call_builtin_inits(void)
BUILTIN(yjit);
BUILTIN(nilclass);
BUILTIN(marshal);
#if USE_MJIT
#if USE_RJIT
BUILTIN(mjit_c);
BUILTIN(mjit);
#endif
Expand Down
2 changes: 1 addition & 1 deletion internal/cmdlineopt.h
Expand Up @@ -23,7 +23,7 @@ typedef struct ruby_cmdline_options {
ruby_features_t features;
ruby_features_t warn;
unsigned int dump;
#if USE_MJIT
#if USE_RJIT
struct mjit_options mjit;
#endif

Expand Down
6 changes: 3 additions & 3 deletions iseq.c
Expand Up @@ -164,7 +164,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
if (iseq && ISEQ_BODY(iseq)) {
iseq_clear_ic_references(iseq);
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
mjit_free_iseq(iseq); /* Notify MJIT */
mjit_free_iseq(iseq); /* Notify RJIT */
#if USE_YJIT
rb_yjit_iseq_free(body->yjit_payload);
#endif
Expand Down Expand Up @@ -356,15 +356,15 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
}

if (reference_updating) {
#if USE_MJIT
#if USE_RJIT
rb_mjit_iseq_update_references(body);
#endif
#if USE_YJIT
rb_yjit_iseq_update_references(body->yjit_payload);
#endif
}
else {
#if USE_MJIT
#if USE_RJIT
rb_mjit_iseq_mark(body->mjit_blocks);
#endif
#if USE_YJIT
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_vm/rjit/assembler.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module RubyVM::MJIT
module RubyVM::RJIT
# 8-bit memory access
class BytePtr < Data.define(:reg, :disp); end

Expand Down Expand Up @@ -905,7 +905,7 @@ def new_label(name)
Label.new(id: @label_id += 1, name:)
end

# @param [RubyVM::MJIT::Assembler::Label] label
# @param [RubyVM::RJIT::Assembler::Label] label
def write_label(label)
@labels[label] = @bytes.size
end
Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_vm/rjit/block.rb
@@ -1,10 +1,10 @@
class RubyVM::MJIT::Block < Struct.new(
class RubyVM::RJIT::Block < Struct.new(
:iseq, # @param ``
:pc, # @param [Integer] Starting PC
:ctx, # @param [RubyVM::MJIT::Context] **Starting** Context (TODO: freeze?)
:ctx, # @param [RubyVM::RJIT::Context] **Starting** Context (TODO: freeze?)
:start_addr, # @param [Integer] Starting address of this block's JIT code
:entry_exit, # @param [Integer] Address of entry exit (optional)
:incoming, # @param [Array<RubyVM::MJIT::BranchStub>] Incoming branches
:incoming, # @param [Array<RubyVM::RJIT::BranchStub>] Incoming branches
:invalidated, # @param [TrueClass,FalseClass] true if already invalidated
)
def initialize(incoming: [], invalidated: false, **) = super
Expand Down
8 changes: 4 additions & 4 deletions lib/ruby_vm/rjit/branch_stub.rb
@@ -1,14 +1,14 @@
module RubyVM::MJIT
module RubyVM::RJIT
# Branch shapes
Next0 = :Next0 # target0 is a fallthrough
Next1 = :Next1 # target1 is a fallthrough
Default = :Default # neither targets is a fallthrough

class BranchStub < Struct.new(
:iseq, # @param [RubyVM::MJIT::CPointer::Struct_rb_iseq_struct] Branch target ISEQ
:iseq, # @param [RubyVM::RJIT::CPointer::Struct_rb_iseq_struct] Branch target ISEQ
:shape, # @param [Symbol] Next0, Next1, or Default
:target0, # @param [RubyVM::MJIT::BranchTarget] First branch target
:target1, # @param [RubyVM::MJIT::BranchTarget,NilClass] Second branch target (optional)
:target0, # @param [RubyVM::RJIT::BranchTarget] First branch target
:target1, # @param [RubyVM::RJIT::BranchTarget,NilClass] Second branch target (optional)
:compile, # @param [Proc] A callback to (re-)generate this branch stub
:start_addr, # @param [Integer] Stub source start address to be re-generated
:end_addr, # @param [Integer] Stub source end address to be re-generated
Expand Down

0 comments on commit 2e87554

Please sign in to comment.