This commit is contained in:
Takashi Kokubun 2023-03-06 23:15:30 -08:00
Родитель eaccdc1941
Коммит 2e875549a9
87 изменённых файлов: 744 добавлений и 744 удалений

2
.github/workflows/compilers.yml поставляемый
Просмотреть файл

@ -197,7 +197,7 @@ jobs:
# - { name: VM_DEBUG_BP_CHECK, env: { cppflags: '-DVM_DEBUG_BP_CHECK' } } # - { 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: 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: YJIT_FORCE_ENABLE, env: { cppflags: '-DYJIT_FORCE_ENABLE' } }
name: ${{ matrix.entry.name }} name: ${{ matrix.entry.name }}

2
.github/workflows/rjit-bindgen.yml поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
name: MJIT bindgen name: RJIT bindgen
on: on:
push: push:
paths-ignore: paths-ignore:

4
.github/workflows/rjit.yml поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
name: MJIT name: RJIT
on: on:
push: push:
paths-ignore: paths-ignore:
@ -112,7 +112,7 @@ jobs:
payload: | payload: |
{ {
"ci": "GitHub Actions", "ci": "GitHub Actions",
"env": "MJIT / ${{ matrix.run_opts }}", "env": "RJIT / ${{ matrix.run_opts }}",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"commit": "${{ github.sha }}", "commit": "${{ github.sha }}",
"branch": "${{ github.ref_name }}" "branch": "${{ github.ref_name }}"

2
.gitignore поставляемый
Просмотреть файл

@ -238,7 +238,7 @@ lcov*.info
# /win32/ # /win32/
/win32/*.ico /win32/*.ico
# MJIT # RJIT
/include/ruby-*/*/rb_mjit_min_header-*.h /include/ruby-*/*/rb_mjit_min_header-*.h
/lib/ruby_vm/mjit/instruction.rb /lib/ruby_vm/mjit/instruction.rb
/lib/ruby_vm/rjit/instruction.rb /lib/ruby_vm/rjit/instruction.rb

Просмотреть файл

@ -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: 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: 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") [![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) [![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)

Просмотреть файл

@ -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: 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: 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") [![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) [![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)

Просмотреть файл

@ -669,7 +669,7 @@ end
def assert_finish(timeout_seconds, testsrc, message = '') def assert_finish(timeout_seconds, testsrc, message = '')
add_assertion testsrc, -> as do 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 timeout_seconds *= 3
end end

Просмотреть файл

@ -14,7 +14,7 @@ ms = "a".."k"
o.send(meth) o.send(meth)
end end
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{ assert_normal_exit %q{
a = [] a = []

Просмотреть файл

@ -2244,7 +2244,7 @@ assert_equal '[[:c_return, :String, :string_alias, "events_to_str"]]', %q{
events.compiled(events) events.compiled(events)
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 # test enabling a TracePoint that targets a particular line in a C method call
assert_equal '[true]', %q{ assert_equal '[true]', %q{
@ -2326,7 +2326,7 @@ assert_equal '[[:c_call, :itself]]', %q{
tp.enable { shouldnt_compile } tp.enable { shouldnt_compile }
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 c_return tracing before compiling # test enabling c_return tracing before compiling
assert_equal '[[:c_return, :itself, main]]', %q{ assert_equal '[[:c_return, :itself, main]]', %q{
@ -2341,7 +2341,7 @@ assert_equal '[[:c_return, :itself, main]]', %q{
tp.enable { shouldnt_compile } tp.enable { shouldnt_compile }
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 c_call invalidation # test c_call invalidation
assert_equal '[[:c_call, :itself]]', %q{ assert_equal '[[:c_call, :itself]]', %q{

Просмотреть файл

@ -360,7 +360,7 @@ ruby.imp: $(COMMONOBJS)
$(NM) -Pgp $(COMMONOBJS) | \ $(NM) -Pgp $(COMMONOBJS) | \
awk 'BEGIN{print "#!"}; $$2~/^[A-TV-Z]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \ awk 'BEGIN{print "#!"}; $$2~/^[A-TV-Z]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \
($(CHDIR) $(srcdir) && \ ($(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 $@ sort -u -o $@

Просмотреть файл

@ -405,19 +405,19 @@ AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG) AC_SUBST(COUTFLAG)
AC_SUBST(CSRCFLAG) AC_SUBST(CSRCFLAG)
: ${MJIT_CC=$CC} : ${RJIT_CC=$CC}
AS_IF([test "x$cross_compiling" = xno], [ 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) # if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache)
AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null && AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null &&
echo $MJIT_CC | grep ^/usr/lib/ccache > /dev/null], [ echo $RJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` MJIT_CC=`which $CC`]) PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` RJIT_CC=`which $CC`])
AS_CASE([$target_os], 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 shift 2
MJIT_CC="$MJIT_CC${1+ }$*" RJIT_CC="$RJIT_CC${1+ }$*"
]) ])
AS_CASE(["$build_os"], AS_CASE(["$build_os"],
@ -1236,7 +1236,7 @@ main()
AS_CASE(["$target_cpu"], [powerpc64*], [ AS_CASE(["$target_cpu"], [powerpc64*], [
ac_cv_func___builtin_setjmp=no 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_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no])
AS_IF([test "$cf_protection" = yes], [ AS_IF([test "$cf_protection" = yes], [
ac_cv_func___builtin_setjmp=no ac_cv_func___builtin_setjmp=no
@ -2927,14 +2927,14 @@ LIBEXT=a
AC_SUBST(DLDFLAGS)dnl AC_SUBST(DLDFLAGS)dnl
AC_SUBST(ARCH_FLAG)dnl AC_SUBST(ARCH_FLAG)dnl
AC_SUBST(MJIT_CC)dnl AC_SUBST(RJIT_CC)dnl
AS_CASE(["$GCC:$target_os"], AS_CASE(["$GCC:$target_os"],
[yes:aix*], [mjit_std_cflag="-std=gnu99"], [yes:aix*], [mjit_std_cflag="-std=gnu99"],
[mjit_std_cflag=]) [mjit_std_cflag=])
AC_SUBST(MJIT_CFLAGS, [${MJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl AC_SUBST(RJIT_CFLAGS, [${RJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
AC_SUBST(MJIT_OPTFLAGS, [${MJIT_OPTFLAGS-'$(optflags)'}])dnl AC_SUBST(RJIT_OPTFLAGS, [${RJIT_OPTFLAGS-'$(optflags)'}])dnl
AC_SUBST(MJIT_DEBUGFLAGS, [${MJIT_DEBUGFLAGS-'$(debugflags)'}])dnl AC_SUBST(RJIT_DEBUGFLAGS, [${RJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
AC_SUBST(MJIT_LDSHARED)dnl AC_SUBST(RJIT_LDSHARED)dnl
AC_SUBST(STATIC)dnl AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl AC_SUBST(CCDLFLAGS)dnl
@ -3727,13 +3727,13 @@ AC_SUBST(INSTALLDOC)
AC_ARG_ENABLE(jit-support, AC_ARG_ENABLE(jit-support,
AS_HELP_STRING([--disable-jit-support], [disable JIT features]), AS_HELP_STRING([--disable-jit-support], [disable JIT features]),
[MJIT_SUPPORT=$enableval], [RJIT_SUPPORT=$enableval],
[AS_CASE(["$target_os"], [AS_CASE(["$target_os"],
[wasi | mingw* | solaris*], [MJIT_SUPPORT=no], [wasi | mingw* | solaris*], [RJIT_SUPPORT=no],
[MJIT_SUPPORT=yes] [RJIT_SUPPORT=yes]
)]) )])
AC_SUBST(MJIT_SUPPORT) AC_SUBST(RJIT_SUPPORT)
AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix
@ -3835,15 +3835,15 @@ AS_CASE(["${YJIT_SUPPORT}"],
AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT]) AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT])
]) ])
AC_DEFINE(USE_YJIT, 1) AC_DEFINE(USE_YJIT, 1)
AC_DEFINE(USE_MJIT, 1) AC_DEFINE(USE_RJIT, 1)
], [ ], [
AC_DEFINE(USE_YJIT, 0) 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. # If YJIT links capstone, libcapstone stops working on the C side.
# capstone should be linked for MJIT only when YJIT doesn't. # capstone should be linked for RJIT only when YJIT doesn't.
AS_IF([test x"$MJIT_SUPPORT" = "xyes" -a -z "$CARGO_BUILD_ARGS" ], [ AS_IF([test x"$RJIT_SUPPORT" = "xyes" -a -z "$CARGO_BUILD_ARGS" ], [
AC_CHECK_LIB([capstone], [cs_disasm]) AC_CHECK_LIB([capstone], [cs_disasm])
]) ])
@ -4054,7 +4054,7 @@ AS_IF([test "${universal_binary-no}" = yes ], [
[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no])) [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" MAINLIBS="$LIBS"
LIBS=$ORIG_LIBS LIBS=$ORIG_LIBS
@ -4541,7 +4541,7 @@ config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags" config_summary "warnflags" "$warnflags"
config_summary "strip command" "$STRIP" config_summary "strip command" "$STRIP"
config_summary "install doc" "$DOCTARGETS" 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 "YJIT support" "$YJIT_SUPPORT"
config_summary "man page type" "$MANTYPE" config_summary "man page type" "$MANTYPE"
config_summary "search path" "$search_path" config_summary "search path" "$search_path"

Просмотреть файл

@ -13,7 +13,7 @@ endif
ifneq ($(filter darwin%,$(target_os)),) ifneq ($(filter darwin%,$(target_os)),)
# Remove debug option not to generate thousands of .dSYM # 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= INSTRUBY_ENV += SDKROOT=
endif endif

Просмотреть файл

@ -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 ## Supported platforms
@ -11,24 +11,24 @@ The following platforms are either tested on CI or assumed to work.
### Not supported ### 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 * OS: Windows (mswin, MinGW), Solaris
* Arch: SPARC, s390x * Arch: SPARC, s390x
## Developing MJIT ## Developing RJIT
### Bindgen ### 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. 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`. 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
Always run `make install` before running MJIT. It could easily cause a SEGV if you don't. Always run `make install` before running RJIT. It could easily cause a SEGV if you don't.
MJIT looks for the installed header for security reasons. RJIT looks for the installed header for security reasons.
### --mjit-debug vs --mjit-debug=-ggdb3 ### --mjit-debug vs --mjit-debug=-ggdb3
@ -36,4 +36,4 @@ MJIT looks for the installed header for security reasons.
which is useful for profiling benchmarks. which is useful for profiling benchmarks.
`--mjit-debug` alone, on the other hand, disables `-O3` and adds debug flags. `--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`.

Просмотреть файл

@ -105,7 +105,7 @@ rb_call_builtin_inits(void)
BUILTIN(yjit); BUILTIN(yjit);
BUILTIN(nilclass); BUILTIN(nilclass);
BUILTIN(marshal); BUILTIN(marshal);
#if USE_MJIT #if USE_RJIT
BUILTIN(mjit_c); BUILTIN(mjit_c);
BUILTIN(mjit); BUILTIN(mjit);
#endif #endif

Просмотреть файл

@ -23,7 +23,7 @@ typedef struct ruby_cmdline_options {
ruby_features_t features; ruby_features_t features;
ruby_features_t warn; ruby_features_t warn;
unsigned int dump; unsigned int dump;
#if USE_MJIT #if USE_RJIT
struct mjit_options mjit; struct mjit_options mjit;
#endif #endif

6
iseq.c
Просмотреть файл

@ -164,7 +164,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
if (iseq && ISEQ_BODY(iseq)) { if (iseq && ISEQ_BODY(iseq)) {
iseq_clear_ic_references(iseq); iseq_clear_ic_references(iseq);
struct rb_iseq_constant_body *const body = ISEQ_BODY(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 #if USE_YJIT
rb_yjit_iseq_free(body->yjit_payload); rb_yjit_iseq_free(body->yjit_payload);
#endif #endif
@ -356,7 +356,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
} }
if (reference_updating) { if (reference_updating) {
#if USE_MJIT #if USE_RJIT
rb_mjit_iseq_update_references(body); rb_mjit_iseq_update_references(body);
#endif #endif
#if USE_YJIT #if USE_YJIT
@ -364,7 +364,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
#endif #endif
} }
else { else {
#if USE_MJIT #if USE_RJIT
rb_mjit_iseq_mark(body->mjit_blocks); rb_mjit_iseq_mark(body->mjit_blocks);
#endif #endif
#if USE_YJIT #if USE_YJIT

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module RubyVM::MJIT module RubyVM::RJIT
# 8-bit memory access # 8-bit memory access
class BytePtr < Data.define(:reg, :disp); end class BytePtr < Data.define(:reg, :disp); end
@ -905,7 +905,7 @@ module RubyVM::MJIT
Label.new(id: @label_id += 1, name:) Label.new(id: @label_id += 1, name:)
end end
# @param [RubyVM::MJIT::Assembler::Label] label # @param [RubyVM::RJIT::Assembler::Label] label
def write_label(label) def write_label(label)
@labels[label] = @bytes.size @labels[label] = @bytes.size
end end

Просмотреть файл

@ -1,10 +1,10 @@
class RubyVM::MJIT::Block < Struct.new( class RubyVM::RJIT::Block < Struct.new(
:iseq, # @param `` :iseq, # @param ``
:pc, # @param [Integer] Starting PC :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 :start_addr, # @param [Integer] Starting address of this block's JIT code
:entry_exit, # @param [Integer] Address of entry exit (optional) :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 :invalidated, # @param [TrueClass,FalseClass] true if already invalidated
) )
def initialize(incoming: [], invalidated: false, **) = super def initialize(incoming: [], invalidated: false, **) = super

Просмотреть файл

@ -1,14 +1,14 @@
module RubyVM::MJIT module RubyVM::RJIT
# Branch shapes # Branch shapes
Next0 = :Next0 # target0 is a fallthrough Next0 = :Next0 # target0 is a fallthrough
Next1 = :Next1 # target1 is a fallthrough Next1 = :Next1 # target1 is a fallthrough
Default = :Default # neither targets is a fallthrough Default = :Default # neither targets is a fallthrough
class BranchStub < Struct.new( 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 :shape, # @param [Symbol] Next0, Next1, or Default
:target0, # @param [RubyVM::MJIT::BranchTarget] First branch target :target0, # @param [RubyVM::RJIT::BranchTarget] First branch target
:target1, # @param [RubyVM::MJIT::BranchTarget,NilClass] Second branch target (optional) :target1, # @param [RubyVM::RJIT::BranchTarget,NilClass] Second branch target (optional)
:compile, # @param [Proc] A callback to (re-)generate this branch stub :compile, # @param [Proc] A callback to (re-)generate this branch stub
:start_addr, # @param [Integer] Stub source start address to be re-generated :start_addr, # @param [Integer] Stub source start address to be re-generated
:end_addr, # @param [Integer] Stub source end address to be re-generated :end_addr, # @param [Integer] Stub source end address to be re-generated

Просмотреть файл

@ -1,4 +1,4 @@
module RubyVM::MJIT module RubyVM::RJIT
# Every class under this namespace is a pointer. Even if the type is # Every class under this namespace is a pointer. Even if the type is
# immediate, it shouldn't be dereferenced until `*` is called. # immediate, it shouldn't be dereferenced until `*` is called.
module CPointer module CPointer
@ -7,7 +7,7 @@ module RubyVM::MJIT
class Struct class Struct
# @param name [String] # @param name [String]
# @param sizeof [Integer] # @param sizeof [Integer]
# @param members [Hash{ Symbol => [RubyVM::MJIT::CType::*, Integer, TrueClass] }] # @param members [Hash{ Symbol => [RubyVM::RJIT::CType::*, Integer, TrueClass] }]
def initialize(addr, sizeof, members) def initialize(addr, sizeof, members)
@addr = addr @addr = addr
@sizeof = sizeof @sizeof = sizeof
@ -48,7 +48,7 @@ module RubyVM::MJIT
end end
# @param size [Integer] # @param size [Integer]
# @param members [Hash{ Symbol => [Integer, RubyVM::MJIT::CType::*] }] # @param members [Hash{ Symbol => [Integer, RubyVM::RJIT::CType::*] }]
def self.define(size, members) def self.define(size, members)
Class.new(self) do Class.new(self) do
# Return the size of this type # Return the size of this type
@ -103,7 +103,7 @@ module RubyVM::MJIT
class Union class Union
# @param _name [String] To be used when it starts defining a union pointer class # @param _name [String] To be used when it starts defining a union pointer class
# @param sizeof [Integer] # @param sizeof [Integer]
# @param members [Hash{ Symbol => RubyVM::MJIT::CType::* }] # @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
def initialize(addr, sizeof, members) def initialize(addr, sizeof, members)
@addr = addr @addr = addr
@sizeof = sizeof @sizeof = sizeof
@ -128,7 +128,7 @@ module RubyVM::MJIT
end end
# @param sizeof [Integer] # @param sizeof [Integer]
# @param members [Hash{ Symbol => RubyVM::MJIT::CType::* }] # @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
def self.define(sizeof, members) def self.define(sizeof, members)
Class.new(self) do Class.new(self) do
# Return the size of this type # Return the size of this type
@ -242,7 +242,7 @@ module RubyVM::MJIT
attr_reader :type attr_reader :type
# @param addr [Integer] # @param addr [Integer]
# @param type [Class] RubyVM::MJIT::CType::* # @param type [Class] RubyVM::RJIT::CType::*
def initialize(addr, type) def initialize(addr, type)
@addr = addr @addr = addr
@type = type @type = type
@ -267,7 +267,7 @@ module RubyVM::MJIT
# Array set # Array set
# @param index [Integer] # @param index [Integer]
# @param value [Integer, RubyVM::MJIT::CPointer::Struct] an address itself or an object that return an address with to_i # @param value [Integer, RubyVM::RJIT::CPointer::Struct] an address itself or an object that return an address with to_i
def []=(index, value) def []=(index, value)
Fiddle::Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP)[0, Fiddle::SIZEOF_VOIDP] = Fiddle::Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP)[0, Fiddle::SIZEOF_VOIDP] =
[value.to_i].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP]) [value.to_i].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP])
@ -292,7 +292,7 @@ module RubyVM::MJIT
# Type-level []=: Used by struct fields # Type-level []=: Used by struct fields
# @param addr [Integer] # @param addr [Integer]
# @param value [Integer, RubyVM::MJIT::CPointer::Struct] an address itself, or an object that return an address with to_i # @param value [Integer, RubyVM::RJIT::CPointer::Struct] an address itself, or an object that return an address with to_i
define_singleton_method(:[]=) do |addr, value| define_singleton_method(:[]=) do |addr, value|
value = value.to_i value = value.to_i
Fiddle::Pointer.new(addr)[0, Fiddle::SIZEOF_VOIDP] = [value].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP]) Fiddle::Pointer.new(addr)[0, Fiddle::SIZEOF_VOIDP] = [value].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP])

Просмотреть файл

@ -2,11 +2,11 @@ require 'fiddle'
require 'fiddle/pack' require 'fiddle/pack'
require_relative 'c_pointer' require_relative 'c_pointer'
module RubyVM::MJIT module RubyVM::RJIT
module CType module CType
module Struct module Struct
# @param name [String] # @param name [String]
# @param members [Hash{ Symbol => [Integer, RubyVM::MJIT::CType::*] }] # @param members [Hash{ Symbol => [Integer, RubyVM::RJIT::CType::*] }]
def self.new(name, sizeof, **members) def self.new(name, sizeof, **members)
name = members.keys.join('_') if name.empty? name = members.keys.join('_') if name.empty?
CPointer.with_class_name('Struct', name) do CPointer.with_class_name('Struct', name) do
@ -17,7 +17,7 @@ module RubyVM::MJIT
module Union module Union
# @param name [String] # @param name [String]
# @param members [Hash{ Symbol => RubyVM::MJIT::CType::* }] # @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
def self.new(name, sizeof, **members) def self.new(name, sizeof, **members)
name = members.keys.join('_') if name.empty? name = members.keys.join('_') if name.empty?
CPointer.with_class_name('Union', name) do CPointer.with_class_name('Union', name) do

Просмотреть файл

@ -1,4 +1,4 @@
module RubyVM::MJIT module RubyVM::RJIT
class CodeBlock class CodeBlock
# @param mem_block [Integer] JIT buffer address # @param mem_block [Integer] JIT buffer address
# @param mem_size [Integer] JIT buffer size # @param mem_size [Integer] JIT buffer size
@ -11,7 +11,7 @@ module RubyVM::MJIT
@outlined = outlined @outlined = outlined
end end
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def write(asm) def write(asm)
return 0 if @write_pos + asm.size >= @mem_size return 0 if @write_pos + asm.size >= @mem_size

Просмотреть файл

@ -9,7 +9,7 @@ require 'ruby_vm/mjit/instruction'
require 'ruby_vm/mjit/invariants' require 'ruby_vm/mjit/invariants'
require 'ruby_vm/mjit/jit_state' require 'ruby_vm/mjit/jit_state'
module RubyVM::MJIT module RubyVM::RJIT
# Compilation status # Compilation status
KeepCompiling = :KeepCompiling KeepCompiling = :KeepCompiling
CantCompile = :CantCompile CantCompile = :CantCompile
@ -55,8 +55,8 @@ module RubyVM::MJIT
end end
# Compile an ISEQ from its entry point. # Compile an ISEQ from its entry point.
# @param iseq `RubyVM::MJIT::CPointer::Struct_rb_iseq_t` # @param iseq `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
# @param cfp `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` # @param cfp `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t`
def compile(iseq, cfp) def compile(iseq, cfp)
# TODO: Support has_opt # TODO: Support has_opt
return if iseq.body.param.flags.has_opt return if iseq.body.param.flags.has_opt
@ -73,8 +73,8 @@ module RubyVM::MJIT
end end
# Compile a branch stub. # Compile a branch stub.
# @param branch_stub [RubyVM::MJIT::BranchStub] # @param branch_stub [RubyVM::RJIT::BranchStub]
# @param cfp `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` # @param cfp `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t`
# @param target0_p [TrueClass,FalseClass] # @param target0_p [TrueClass,FalseClass]
# @return [Integer] The starting address of the compiled branch stub # @return [Integer] The starting address of the compiled branch stub
def branch_stub_hit(branch_stub, cfp, target0_p) def branch_stub_hit(branch_stub, cfp, target0_p)
@ -127,14 +127,14 @@ module RubyVM::MJIT
exit 1 exit 1
end end
# @param iseq `RubyVM::MJIT::CPointer::Struct_rb_iseq_t` # @param iseq `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
# @param pc [Integer] # @param pc [Integer]
def invalidate_blocks(iseq, pc) def invalidate_blocks(iseq, pc)
list_blocks(iseq, pc).each do |block| list_blocks(iseq, pc).each do |block|
invalidate_block(block) invalidate_block(block)
end end
# If they were the ISEQ's first blocks, re-compile MJIT entry as well # If they were the ISEQ's first blocks, re-compile RJIT entry as well
if iseq.body.iseq_encoded.to_i == pc if iseq.body.iseq_encoded.to_i == pc
iseq.body.jit_func = 0 iseq.body.jit_func = 0
iseq.body.total_calls = 0 iseq.body.total_calls = 0
@ -191,9 +191,9 @@ module RubyVM::MJIT
# Callee-saved: rbx, rsp, rbp, r12, r13, r14, r15 # Callee-saved: rbx, rsp, rbp, r12, r13, r14, r15
# Caller-saved: rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11 # Caller-saved: rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11
# #
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def compile_prologue(asm) def compile_prologue(asm)
asm.comment('MJIT entry point') asm.comment('RJIT entry point')
# Save callee-saved registers used by JITed code # Save callee-saved registers used by JITed code
asm.push(CFP) asm.push(CFP)
@ -212,7 +212,7 @@ module RubyVM::MJIT
asm.mov([CFP, C.rb_control_frame_t.offsetof(:jit_return)], :rax) asm.mov([CFP, C.rb_control_frame_t.offsetof(:jit_return)], :rax)
end end
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def compile_block(asm, jit:, pc: jit.iseq.body.iseq_encoded.to_i, ctx: Context.new) def compile_block(asm, jit:, pc: jit.iseq.body.iseq_encoded.to_i, ctx: Context.new)
# Mark the block start address and prepare an exit code storage # Mark the block start address and prepare an exit code storage
block = Block.new(iseq: jit.iseq, pc:, ctx: ctx.dup) block = Block.new(iseq: jit.iseq, pc:, ctx: ctx.dup)
@ -276,18 +276,18 @@ module RubyVM::MJIT
end end
# @param [Integer] pc # @param [Integer] pc
# @param [RubyVM::MJIT::Context] ctx # @param [RubyVM::RJIT::Context] ctx
# @return [RubyVM::MJIT::Block,NilClass] # @return [RubyVM::RJIT::Block,NilClass]
def find_block(iseq, pc, ctx) def find_block(iseq, pc, ctx)
mjit_blocks(iseq)[pc][ctx] mjit_blocks(iseq)[pc][ctx]
end end
# @param [RubyVM::MJIT::Block] block # @param [RubyVM::RJIT::Block] block
def set_block(iseq, block) def set_block(iseq, block)
mjit_blocks(iseq)[block.pc][block.ctx] = block mjit_blocks(iseq)[block.pc][block.ctx] = block
end end
# @param [RubyVM::MJIT::Block] block # @param [RubyVM::RJIT::Block] block
def remove_block(iseq, block) def remove_block(iseq, block)
mjit_blocks(iseq)[block.pc].delete(block.ctx) mjit_blocks(iseq)[block.pc].delete(block.ctx)
end end

Просмотреть файл

@ -1,4 +1,4 @@
module RubyVM::MJIT module RubyVM::RJIT
class Context < Struct.new( class Context < Struct.new(
:stack_size, # @param [Integer] The number of values on the stack :stack_size, # @param [Integer] The number of values on the stack
:sp_offset, # @param [Integer] JIT sp offset relative to the interpreter's sp :sp_offset, # @param [Integer] JIT sp offset relative to the interpreter's sp

Просмотреть файл

@ -1,8 +1,8 @@
module RubyVM::MJIT module RubyVM::RJIT
class ExitCompiler class ExitCompiler
# Used for invalidating a block on entry. # Used for invalidating a block on entry.
# @param pc [Integer] # @param pc [Integer]
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def compile_entry_exit(pc, ctx, asm, cause:) def compile_entry_exit(pc, ctx, asm, cause:)
# Increment per-insn exit counter # Increment per-insn exit counter
incr_insn_exit(pc, asm) incr_insn_exit(pc, asm)
@ -21,7 +21,7 @@ module RubyVM::MJIT
end end
# Set to cfp->jit_return by default for leave insn # Set to cfp->jit_return by default for leave insn
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def compile_leave_exit(asm) def compile_leave_exit(asm)
asm.comment('default cfp->jit_return') asm.comment('default cfp->jit_return')
@ -35,7 +35,7 @@ module RubyVM::MJIT
end end
# Fire cfunc events on invalidation by TracePoint # Fire cfunc events on invalidation by TracePoint
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def compile_full_cfunc_return(asm) def compile_full_cfunc_return(asm)
# This chunk of code expects REG_EC to be filled properly and # This chunk of code expects REG_EC to be filled properly and
# RAX to contain the return value of the C method. # RAX to contain the return value of the C method.
@ -56,9 +56,9 @@ module RubyVM::MJIT
asm.ret asm.ret
end end
# @param jit [RubyVM::MJIT::JITState] # @param jit [RubyVM::RJIT::JITState]
# @param ctx [RubyVM::MJIT::Context] # @param ctx [RubyVM::RJIT::Context]
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def compile_side_exit(pc, ctx, asm) def compile_side_exit(pc, ctx, asm)
# Increment per-insn exit counter # Increment per-insn exit counter
incr_insn_exit(pc, asm) incr_insn_exit(pc, asm)
@ -76,9 +76,9 @@ module RubyVM::MJIT
asm.ret asm.ret
end end
# @param ctx [RubyVM::MJIT::Context] # @param ctx [RubyVM::RJIT::Context]
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
# @param branch_stub [RubyVM::MJIT::BranchStub] # @param branch_stub [RubyVM::RJIT::BranchStub]
# @param target0_p [TrueClass,FalseClass] # @param target0_p [TrueClass,FalseClass]
def compile_branch_stub(ctx, asm, branch_stub, target0_p) def compile_branch_stub(ctx, asm, branch_stub, target0_p)
# Call rb_mjit_branch_stub_hit # Call rb_mjit_branch_stub_hit
@ -102,7 +102,7 @@ module RubyVM::MJIT
end end
# @param pc [Integer] # @param pc [Integer]
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def incr_insn_exit(pc, asm) def incr_insn_exit(pc, asm)
if C.mjit_opts.stats if C.mjit_opts.stats
insn = Compiler.decode_insn(C.VALUE.new(pc).*) insn = Compiler.decode_insn(C.VALUE.new(pc).*)
@ -112,9 +112,9 @@ module RubyVM::MJIT
end end
end end
# @param jit [RubyVM::MJIT::JITState] # @param jit [RubyVM::RJIT::JITState]
# @param ctx [RubyVM::MJIT::Context] # @param ctx [RubyVM::RJIT::Context]
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def save_pc_and_sp(pc, ctx, asm, reset_sp_offset: true) def save_pc_and_sp(pc, ctx, asm, reset_sp_offset: true)
# Update pc (TODO: manage PC offset?) # Update pc (TODO: manage PC offset?)
asm.comment("save PC#{' and SP' if ctx.sp_offset != 0} to CFP") asm.comment("save PC#{' and SP' if ctx.sp_offset != 0} to CFP")

Просмотреть файл

@ -1,4 +1,4 @@
module RubyVM::MJIT module RubyVM::RJIT
module Hooks # :nodoc: all module Hooks # :nodoc: all
def self.on_bop_redefined(_redefined_flag, _bop) def self.on_bop_redefined(_redefined_flag, _bop)
# C.mjit_cancel_all("BOP is redefined") # C.mjit_cancel_all("BOP is redefined")

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,13 +1,13 @@
require 'set' require 'set'
module RubyVM::MJIT module RubyVM::RJIT
class Invariants class Invariants
class << self class << self
# Called by RubyVM::MJIT::Compiler to lazily initialize this # Called by RubyVM::RJIT::Compiler to lazily initialize this
# @param cb [CodeBlock] # @param cb [CodeBlock]
# @param ocb [CodeBlock] # @param ocb [CodeBlock]
# @param compiler [RubyVM::MJIT::Compiler] # @param compiler [RubyVM::RJIT::Compiler]
# @param exit_compiler [RubyVM::MJIT::ExitCompiler] # @param exit_compiler [RubyVM::RJIT::ExitCompiler]
def initialize(cb, ocb, compiler, exit_compiler) def initialize(cb, ocb, compiler, exit_compiler)
@cb = cb @cb = cb
@ocb = ocb @ocb = ocb
@ -21,7 +21,7 @@ module RubyVM::MJIT
# freeze # workaround a binding.irb issue. TODO: resurrect this # freeze # workaround a binding.irb issue. TODO: resurrect this
end end
# @param jit [RubyVM::MJIT::JITState] # @param jit [RubyVM::RJIT::JITState]
# @param klass [Integer] # @param klass [Integer]
# @param op [Integer] # @param op [Integer]
def assume_bop_not_redefined(jit, klass, op) def assume_bop_not_redefined(jit, klass, op)
@ -32,7 +32,7 @@ module RubyVM::MJIT
true true
end end
# @param jit [RubyVM::MJIT::JITState] # @param jit [RubyVM::RJIT::JITState]
def assume_method_lookup_stable(jit, cme) def assume_method_lookup_stable(jit, cme)
ensure_block_entry_exit(jit, cause: 'assume_method_lookup_stable') ensure_block_entry_exit(jit, cause: 'assume_method_lookup_stable')
@cme_blocks[cme.to_i] << jit.block @cme_blocks[cme.to_i] << jit.block
@ -45,7 +45,7 @@ module RubyVM::MJIT
end end
end end
# @param asm [RubyVM::MJIT::Assembler] # @param asm [RubyVM::RJIT::Assembler]
def record_global_inval_patch(asm, target) def record_global_inval_patch(asm, target)
asm.pos_marker do |address| asm.pos_marker do |address|
if @patches.key?(address) if @patches.key?(address)
@ -103,8 +103,8 @@ module RubyVM::MJIT
invalidate_all invalidate_all
end end
# @param jit [RubyVM::MJIT::JITState] # @param jit [RubyVM::RJIT::JITState]
# @param block [RubyVM::MJIT::Block] # @param block [RubyVM::RJIT::Block]
def ensure_block_entry_exit(jit, cause:) def ensure_block_entry_exit(jit, cause:)
block = jit.block block = jit.block
if block.entry_exit.nil? if block.entry_exit.nil?

Просмотреть файл

@ -1,9 +1,9 @@
module RubyVM::MJIT module RubyVM::RJIT
class JITState < Struct.new( class JITState < Struct.new(
:iseq, # @param `RubyVM::MJIT::CPointer::Struct_rb_iseq_t` :iseq, # @param `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
:pc, # @param [Integer] The JIT target PC :pc, # @param [Integer] The JIT target PC
:cfp, # @param `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before MJIT is called) :cfp, # @param `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before RJIT is called)
:block, # @param [RubyVM::MJIT::Block] :block, # @param [RubyVM::RJIT::Block]
:side_exits, # @param [Hash{ Integer => Integer }] { PC => address } :side_exits, # @param [Hash{ Integer => Integer }] { PC => address }
:record_boundary_patch_point, # @param [TrueClass,FalseClass] :record_boundary_patch_point, # @param [TrueClass,FalseClass]
) )

Просмотреть файл

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module RubyVM::MJIT module RubyVM::RJIT
def self.runtime_stats def self.runtime_stats
stats = {} stats = {}
@ -32,7 +32,7 @@ module RubyVM::MJIT
def print_stats def print_stats
stats = runtime_stats stats = runtime_stats
$stderr.puts("***MJIT: Printing MJIT statistics on exit***") $stderr.puts("***RJIT: Printing RJIT statistics on exit***")
print_counters(stats, prefix: 'send_', prompt: 'method call exit reasons') print_counters(stats, prefix: 'send_', prompt: 'method call exit reasons')
print_counters(stats, prefix: 'invokesuper_', prompt: 'invokesuper exit reasons') print_counters(stats, prefix: 'invokesuper_', prompt: 'invokesuper exit reasons')

Просмотреть файл

@ -1079,7 +1079,7 @@ void rb_sigwait_sleep(const rb_thread_t *, int fd, const rb_hrtime_t *);
void rb_sigwait_fd_put(const rb_thread_t *, int fd); void rb_sigwait_fd_put(const rb_thread_t *, int fd);
void rb_thread_sleep_interruptible(void); void rb_thread_sleep_interruptible(void);
#if USE_MJIT #if USE_RJIT
static struct waitpid_state mjit_waitpid_state; static struct waitpid_state mjit_waitpid_state;
// variables shared with thread.c // variables shared with thread.c
@ -1095,7 +1095,7 @@ waitpid_signal(struct waitpid_state *w)
rb_threadptr_interrupt(rb_ec_thread_ptr(w->ec)); rb_threadptr_interrupt(rb_ec_thread_ptr(w->ec));
return TRUE; return TRUE;
} }
#if USE_MJIT #if USE_RJIT
else if (w == &mjit_waitpid_state && w->ret) { /* mjit_add_waiting_pid */ else if (w == &mjit_waitpid_state && w->ret) { /* mjit_add_waiting_pid */
mjit_waitpid_finished = true; mjit_waitpid_finished = true;
mjit_waitpid_status = w->status; mjit_waitpid_status = w->status;
@ -1197,7 +1197,7 @@ waitpid_state_init(struct waitpid_state *w, rb_pid_t pid, int options)
w->status = 0; w->status = 0;
} }
#if USE_MJIT #if USE_RJIT
/* /*
* must be called with vm->waitpid_lock held, this is not interruptible * must be called with vm->waitpid_lock held, this is not interruptible
*/ */
@ -4187,8 +4187,8 @@ retry_fork_async_signal_safe(struct rb_process_status *status, int *ep,
} }
} }
#if USE_MJIT #if USE_RJIT
// This is used to create MJIT's child Ruby process // This is used to create RJIT's child Ruby process
pid_t pid_t
rb_mjit_fork(void) rb_mjit_fork(void)
{ {
@ -4267,7 +4267,7 @@ fork_check_err(struct rb_process_status *status, int (*chfunc)(void*, char *, si
* The "async_signal_safe" name is a lie, but it is used by pty.c and * The "async_signal_safe" name is a lie, but it is used by pty.c and
* maybe other exts. fork() is not async-signal-safe due to pthread_atfork * maybe other exts. fork() is not async-signal-safe due to pthread_atfork
* and future POSIX revisions will remove it from a list of signal-safe * and future POSIX revisions will remove it from a list of signal-safe
* functions. rb_waitpid is not async-signal-safe since MJIT, either. * functions. rb_waitpid is not async-signal-safe since RJIT, either.
* For our purposes, we do not need async-signal-safety, here * For our purposes, we do not need async-signal-safety, here
*/ */
rb_pid_t rb_pid_t
@ -4297,7 +4297,7 @@ rb_fork_ruby2(struct rb_process_status *status)
while (1) { while (1) {
prefork(); prefork();
if (mjit_enabled) mjit_pause(false); // Don't leave locked mutex to child. Note: child_handler must be enabled to pause MJIT. if (mjit_enabled) mjit_pause(false); // Don't leave locked mutex to child. Note: child_handler must be enabled to pause RJIT.
disable_child_handler_before_fork(&old); disable_child_handler_before_fork(&old);
before_fork_ruby(); before_fork_ruby();
pid = rb_fork(); pid = rb_fork();
@ -4719,7 +4719,7 @@ rb_execarg_spawn(VALUE execarg_obj, char *errmsg, size_t errmsg_buflen)
struct rb_execarg *eargp = rb_execarg_get(execarg_obj); struct rb_execarg *eargp = rb_execarg_get(execarg_obj);
/* /*
* Prevent a race with MJIT where the compiler process where * Prevent a race with RJIT where the compiler process where
* can hold an FD of ours in between vfork + execve * can hold an FD of ours in between vfork + execve
*/ */
if (!eargp->waitpid_state && mjit_enabled) { if (!eargp->waitpid_state && mjit_enabled) {

Просмотреть файл

@ -39,7 +39,7 @@ static void
ASSERT_ractor_unlocking(rb_ractor_t *r) ASSERT_ractor_unlocking(rb_ractor_t *r)
{ {
#if RACTOR_CHECK_MODE > 0 #if RACTOR_CHECK_MODE > 0
// GET_EC is NULL in an MJIT worker // GET_EC is NULL in an RJIT worker
if (rb_current_execution_context(false) != NULL && r->sync.locked_by == rb_ractor_self(GET_RACTOR())) { if (rb_current_execution_context(false) != NULL && r->sync.locked_by == rb_ractor_self(GET_RACTOR())) {
rb_bug("recursive ractor locking"); rb_bug("recursive ractor locking");
} }
@ -50,7 +50,7 @@ static void
ASSERT_ractor_locking(rb_ractor_t *r) ASSERT_ractor_locking(rb_ractor_t *r)
{ {
#if RACTOR_CHECK_MODE > 0 #if RACTOR_CHECK_MODE > 0
// GET_EC is NULL in an MJIT worker // GET_EC is NULL in an RJIT worker
if (rb_current_execution_context(false) != NULL && r->sync.locked_by != rb_ractor_self(GET_RACTOR())) { if (rb_current_execution_context(false) != NULL && r->sync.locked_by != rb_ractor_self(GET_RACTOR())) {
rp(r->sync.locked_by); rp(r->sync.locked_by);
rb_bug("ractor lock is not acquired."); rb_bug("ractor lock is not acquired.");
@ -67,7 +67,7 @@ ractor_lock(rb_ractor_t *r, const char *file, int line)
rb_native_mutex_lock(&r->sync.lock); rb_native_mutex_lock(&r->sync.lock);
#if RACTOR_CHECK_MODE > 0 #if RACTOR_CHECK_MODE > 0
if (rb_current_execution_context(false) != NULL) { // GET_EC is NULL in an MJIT worker if (rb_current_execution_context(false) != NULL) { // GET_EC is NULL in an RJIT worker
r->sync.locked_by = rb_ractor_self(GET_RACTOR()); r->sync.locked_by = rb_ractor_self(GET_RACTOR());
} }
#endif #endif

134
rjit.c
Просмотреть файл

@ -7,12 +7,12 @@
**********************************************************************/ **********************************************************************/
#include "ruby/internal/config.h" // defines USE_MJIT #include "ruby/internal/config.h" // defines USE_RJIT
// ISO C requires a translation unit to contain at least one declaration // ISO C requires a translation unit to contain at least one declaration
void rb_mjit(void) {} void rb_mjit(void) {}
#if USE_MJIT #if USE_RJIT
#include "constant.h" #include "constant.h"
#include "id_table.h" #include "id_table.h"
@ -59,12 +59,12 @@ void rb_mjit(void) {}
#include "ruby/util.h" #include "ruby/util.h"
// A copy of MJIT portion of MRI options since MJIT initialization. We // A copy of RJIT portion of MRI options since RJIT initialization. We
// need them as MJIT threads still can work when the most MRI data were // need them as RJIT threads still can work when the most MRI data were
// freed. // freed.
struct mjit_options mjit_opts; struct mjit_options mjit_opts;
// true if MJIT is enabled. // true if RJIT is enabled.
bool mjit_enabled = false; bool mjit_enabled = false;
bool mjit_stats_enabled = false; bool mjit_stats_enabled = false;
// true if JIT-ed code should be called. When `ruby_vm_event_enabled_global_flags & ISEQ_TRACE_EVENTS` // true if JIT-ed code should be called. When `ruby_vm_event_enabled_global_flags & ISEQ_TRACE_EVENTS`
@ -73,7 +73,7 @@ bool mjit_call_p = false;
// A flag to communicate that mjit_call_p should be disabled while it's temporarily false. // A flag to communicate that mjit_call_p should be disabled while it's temporarily false.
bool mjit_cancel_p = false; bool mjit_cancel_p = false;
// Print the arguments according to FORMAT to stderr only if MJIT // Print the arguments according to FORMAT to stderr only if RJIT
// verbose option value is more or equal to LEVEL. // verbose option value is more or equal to LEVEL.
PRINTF_ARGS(static void, 2, 3) PRINTF_ARGS(static void, 2, 3)
verbose(int level, const char *format, ...) verbose(int level, const char *format, ...)
@ -126,18 +126,18 @@ mjit_notify_waitpid(int exit_code)
// TODO: remove this function // TODO: remove this function
} }
// RubyVM::MJIT // RubyVM::RJIT
static VALUE rb_mMJIT = 0; static VALUE rb_mRJIT = 0;
// RubyVM::MJIT::C // RubyVM::RJIT::C
static VALUE rb_mMJITC = 0; static VALUE rb_mRJITC = 0;
// RubyVM::MJIT::Compiler // RubyVM::RJIT::Compiler
static VALUE rb_MJITCompiler = 0; static VALUE rb_RJITCompiler = 0;
// RubyVM::MJIT::CPointer::Struct_rb_iseq_t // RubyVM::RJIT::CPointer::Struct_rb_iseq_t
static VALUE rb_cMJITIseqPtr = 0; static VALUE rb_cRJITIseqPtr = 0;
// RubyVM::MJIT::CPointer::Struct_rb_control_frame_t // RubyVM::RJIT::CPointer::Struct_rb_control_frame_t
static VALUE rb_cMJITCfpPtr = 0; static VALUE rb_cRJITCfpPtr = 0;
// RubyVM::MJIT::Hooks // RubyVM::RJIT::Hooks
static VALUE rb_mMJITHooks = 0; static VALUE rb_mRJITHooks = 0;
void void
rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq) rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq)
@ -235,7 +235,7 @@ mjit_setup_options(const char *s, struct mjit_options *mjit_opt)
} }
else { else {
rb_raise(rb_eRuntimeError, rb_raise(rb_eRuntimeError,
"invalid MJIT option `%s' (--help will show valid MJIT options)", s); "invalid RJIT option `%s' (--help will show valid RJIT options)", s);
} }
} }
@ -248,7 +248,7 @@ const struct ruby_opt_message mjit_option_messages[] = {
M("--mjit-verbose=num", "", "Print JIT logs of level num or less to stderr (default: 0)"), M("--mjit-verbose=num", "", "Print JIT logs of level num or less to stderr (default: 0)"),
M("--mjit-max-cache=num", "", "Max number of methods to be JIT-ed in a cache (default: " STRINGIZE(DEFAULT_MAX_CACHE_SIZE) ")"), M("--mjit-max-cache=num", "", "Max number of methods to be JIT-ed in a cache (default: " STRINGIZE(DEFAULT_MAX_CACHE_SIZE) ")"),
M("--mjit-call-threshold=num", "", "Number of calls to trigger JIT (for testing, default: " STRINGIZE(DEFAULT_CALL_THRESHOLD) ")"), M("--mjit-call-threshold=num", "", "Number of calls to trigger JIT (for testing, default: " STRINGIZE(DEFAULT_CALL_THRESHOLD) ")"),
M("--mjit-stats", "", "Enable collecting MJIT statistics"), M("--mjit-stats", "", "Enable collecting RJIT statistics"),
{0} {0}
}; };
#undef M #undef M
@ -292,10 +292,10 @@ uint8_t *rb_mjit_mem_block = NULL;
// `rb_ec_ractor_hooks(ec)->events` is moved to this variable during compilation. // `rb_ec_ractor_hooks(ec)->events` is moved to this variable during compilation.
rb_event_flag_t rb_mjit_global_events = 0; rb_event_flag_t rb_mjit_global_events = 0;
// Basically mjit_opts.stats, but this becomes false during MJIT compilation. // Basically mjit_opts.stats, but this becomes false during RJIT compilation.
static bool mjit_stats_p = false; static bool mjit_stats_p = false;
#if MJIT_STATS #if RJIT_STATS
struct rb_mjit_runtime_counters rb_mjit_counters = { 0 }; struct rb_mjit_runtime_counters rb_mjit_counters = { 0 };
@ -311,7 +311,7 @@ rb_mjit_collect_vm_usage_insn(int insn)
extern VALUE rb_gc_enable(void); extern VALUE rb_gc_enable(void);
extern VALUE rb_gc_disable(void); extern VALUE rb_gc_disable(void);
#define WITH_MJIT_ISOLATED(stmt) do { \ #define WITH_RJIT_ISOLATED(stmt) do { \
VALUE was_disabled = rb_gc_disable(); \ VALUE was_disabled = rb_gc_disable(); \
rb_hook_list_t *global_hooks = rb_ec_ractor_hooks(GET_EC()); \ rb_hook_list_t *global_hooks = rb_ec_ractor_hooks(GET_EC()); \
rb_mjit_global_events = global_hooks->events; \ rb_mjit_global_events = global_hooks->events; \
@ -336,9 +336,9 @@ rb_mjit_bop_redefined(int redefined_flag, enum ruby_basic_operators bop)
static void static void
mjit_cme_invalidate(void *data) mjit_cme_invalidate(void *data)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
rb_funcall(rb_mMJITHooks, rb_intern("on_cme_invalidate"), 1, SIZET2NUM((size_t)data)); rb_funcall(rb_mRJITHooks, rb_intern("on_cme_invalidate"), 1, SIZET2NUM((size_t)data));
}); });
} }
@ -347,7 +347,7 @@ extern int rb_workqueue_register(unsigned flags, rb_postponed_job_func_t func, v
void void
rb_mjit_cme_invalidate(rb_callable_method_entry_t *cme) rb_mjit_cme_invalidate(rb_callable_method_entry_t *cme)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
// Asynchronously hook the Ruby code since running Ruby in the middle of cme invalidation is dangerous. // Asynchronously hook the Ruby code since running Ruby in the middle of cme invalidation is dangerous.
rb_workqueue_register(0, mjit_cme_invalidate, (void *)cme); rb_workqueue_register(0, mjit_cme_invalidate, (void *)cme);
} }
@ -362,12 +362,12 @@ rb_mjit_before_ractor_spawn(void)
static void static void
mjit_constant_state_changed(void *data) mjit_constant_state_changed(void *data)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
RB_VM_LOCK_ENTER(); RB_VM_LOCK_ENTER();
rb_vm_barrier(); rb_vm_barrier();
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
rb_funcall(rb_mMJITHooks, rb_intern("on_constant_state_changed"), 1, SIZET2NUM((size_t)data)); rb_funcall(rb_mRJITHooks, rb_intern("on_constant_state_changed"), 1, SIZET2NUM((size_t)data));
}); });
RB_VM_LOCK_LEAVE(); RB_VM_LOCK_LEAVE();
@ -376,7 +376,7 @@ mjit_constant_state_changed(void *data)
void void
rb_mjit_constant_state_changed(ID id) rb_mjit_constant_state_changed(ID id)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
// Asynchronously hook the Ruby code since this is hooked during a "Ruby critical section". // Asynchronously hook the Ruby code since this is hooked during a "Ruby critical section".
rb_workqueue_register(0, mjit_constant_state_changed, (void *)id); rb_workqueue_register(0, mjit_constant_state_changed, (void *)id);
} }
@ -384,13 +384,13 @@ rb_mjit_constant_state_changed(ID id)
void void
rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx) rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
RB_VM_LOCK_ENTER(); RB_VM_LOCK_ENTER();
rb_vm_barrier(); rb_vm_barrier();
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
rb_funcall(rb_mMJITHooks, rb_intern("on_constant_ic_update"), 3, rb_funcall(rb_mRJITHooks, rb_intern("on_constant_ic_update"), 3,
SIZET2NUM((size_t)iseq), SIZET2NUM((size_t)ic), UINT2NUM(insn_idx)); SIZET2NUM((size_t)iseq), SIZET2NUM((size_t)ic), UINT2NUM(insn_idx));
}); });
@ -400,18 +400,18 @@ rb_mjit_constant_ic_update(const rb_iseq_t *const iseq, IC ic, unsigned insn_idx
void void
rb_mjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events) rb_mjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
rb_funcall(rb_mMJITHooks, rb_intern("on_tracing_invalidate_all"), 1, UINT2NUM(new_iseq_events)); rb_funcall(rb_mRJITHooks, rb_intern("on_tracing_invalidate_all"), 1, UINT2NUM(new_iseq_events));
}); });
} }
static void static void
mjit_iseq_update_references(void *data) mjit_iseq_update_references(void *data)
{ {
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return; if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
rb_funcall(rb_mMJITHooks, rb_intern("on_update_references"), 0); rb_funcall(rb_mRJITHooks, rb_intern("on_update_references"), 0);
}); });
} }
@ -436,7 +436,7 @@ rb_mjit_iseq_mark(VALUE mjit_blocks)
if (!mjit_enabled) return; if (!mjit_enabled) return;
// Note: This wasn't enough for some reason. // Note: This wasn't enough for some reason.
// We actually rely on RubyVM::MJIT::GC_REFS to mark this. // We actually rely on RubyVM::RJIT::GC_REFS to mark this.
if (mjit_blocks) { if (mjit_blocks) {
rb_gc_mark_movable(mjit_blocks); rb_gc_mark_movable(mjit_blocks);
} }
@ -446,7 +446,7 @@ rb_mjit_iseq_mark(VALUE mjit_blocks)
VALUE VALUE
rb_mjit_iseq_new(rb_iseq_t *iseq) rb_mjit_iseq_new(rb_iseq_t *iseq)
{ {
return rb_funcall(rb_cMJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq)); return rb_funcall(rb_cRJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq));
} }
void void
@ -455,10 +455,10 @@ rb_mjit_compile(const rb_iseq_t *iseq)
RB_VM_LOCK_ENTER(); RB_VM_LOCK_ENTER();
rb_vm_barrier(); rb_vm_barrier();
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
VALUE iseq_ptr = rb_funcall(rb_cMJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq)); VALUE iseq_ptr = rb_funcall(rb_cRJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq));
VALUE cfp_ptr = rb_funcall(rb_cMJITCfpPtr, rb_intern("new"), 1, SIZET2NUM((size_t)GET_EC()->cfp)); VALUE cfp_ptr = rb_funcall(rb_cRJITCfpPtr, rb_intern("new"), 1, SIZET2NUM((size_t)GET_EC()->cfp));
rb_funcall(rb_MJITCompiler, rb_intern("compile"), 2, iseq_ptr, cfp_ptr); rb_funcall(rb_RJITCompiler, rb_intern("compile"), 2, iseq_ptr, cfp_ptr);
}); });
RB_VM_LOCK_LEAVE(); RB_VM_LOCK_LEAVE();
@ -475,9 +475,9 @@ rb_mjit_branch_stub_hit(VALUE branch_stub, int sp_offset, int target0_p)
rb_control_frame_t *cfp = GET_EC()->cfp; rb_control_frame_t *cfp = GET_EC()->cfp;
cfp->sp += sp_offset; // preserve stack values, also using the actual sp_offset to make jit.peek_at_stack work cfp->sp += sp_offset; // preserve stack values, also using the actual sp_offset to make jit.peek_at_stack work
WITH_MJIT_ISOLATED({ WITH_RJIT_ISOLATED({
VALUE cfp_ptr = rb_funcall(rb_cMJITCfpPtr, rb_intern("new"), 1, SIZET2NUM((size_t)cfp)); VALUE cfp_ptr = rb_funcall(rb_cRJITCfpPtr, rb_intern("new"), 1, SIZET2NUM((size_t)cfp));
result = rb_funcall(rb_MJITCompiler, rb_intern("branch_stub_hit"), 3, branch_stub, cfp_ptr, RBOOL(target0_p)); result = rb_funcall(rb_RJITCompiler, rb_intern("branch_stub_hit"), 3, branch_stub, cfp_ptr, RBOOL(target0_p));
}); });
cfp->sp -= sp_offset; // reset for consistency with the code without the stub cfp->sp -= sp_offset; // reset for consistency with the code without the stub
@ -496,10 +496,10 @@ mjit_mark(void)
RUBY_MARK_ENTER("mjit"); RUBY_MARK_ENTER("mjit");
// Pin object pointers used in this file // Pin object pointers used in this file
rb_gc_mark(rb_MJITCompiler); rb_gc_mark(rb_RJITCompiler);
rb_gc_mark(rb_cMJITIseqPtr); rb_gc_mark(rb_cRJITIseqPtr);
rb_gc_mark(rb_cMJITCfpPtr); rb_gc_mark(rb_cRJITCfpPtr);
rb_gc_mark(rb_mMJITHooks); rb_gc_mark(rb_mRJITHooks);
RUBY_MARK_LEAVE("mjit"); RUBY_MARK_LEAVE("mjit");
} }
@ -511,22 +511,22 @@ mjit_init(const struct mjit_options *opts)
mjit_opts = *opts; mjit_opts = *opts;
extern uint8_t* rb_yjit_reserve_addr_space(uint32_t mem_size); extern uint8_t* rb_yjit_reserve_addr_space(uint32_t mem_size);
rb_mjit_mem_block = rb_yjit_reserve_addr_space(MJIT_CODE_SIZE); rb_mjit_mem_block = rb_yjit_reserve_addr_space(RJIT_CODE_SIZE);
// MJIT doesn't support miniruby, but it might reach here by MJIT_FORCE_ENABLE. // RJIT doesn't support miniruby, but it might reach here by RJIT_FORCE_ENABLE.
rb_mMJIT = rb_const_get(rb_cRubyVM, rb_intern("MJIT")); rb_mRJIT = rb_const_get(rb_cRubyVM, rb_intern("RJIT"));
if (!rb_const_defined(rb_mMJIT, rb_intern("Compiler"))) { if (!rb_const_defined(rb_mRJIT, rb_intern("Compiler"))) {
verbose(1, "Disabling MJIT because RubyVM::MJIT::Compiler is not defined"); verbose(1, "Disabling RJIT because RubyVM::RJIT::Compiler is not defined");
mjit_enabled = false; mjit_enabled = false;
return; return;
} }
rb_mMJITC = rb_const_get(rb_mMJIT, rb_intern("C")); rb_mRJITC = rb_const_get(rb_mRJIT, rb_intern("C"));
VALUE rb_cMJITCompiler = rb_const_get(rb_mMJIT, rb_intern("Compiler")); VALUE rb_cRJITCompiler = rb_const_get(rb_mRJIT, rb_intern("Compiler"));
rb_MJITCompiler = rb_funcall(rb_cMJITCompiler, rb_intern("new"), 2, rb_RJITCompiler = rb_funcall(rb_cRJITCompiler, rb_intern("new"), 2,
SIZET2NUM((size_t)rb_mjit_mem_block), UINT2NUM(MJIT_CODE_SIZE)); SIZET2NUM((size_t)rb_mjit_mem_block), UINT2NUM(RJIT_CODE_SIZE));
rb_cMJITIseqPtr = rb_funcall(rb_mMJITC, rb_intern("rb_iseq_t"), 0); rb_cRJITIseqPtr = rb_funcall(rb_mRJITC, rb_intern("rb_iseq_t"), 0);
rb_cMJITCfpPtr = rb_funcall(rb_mMJITC, rb_intern("rb_control_frame_t"), 0); rb_cRJITCfpPtr = rb_funcall(rb_mRJITC, rb_intern("rb_control_frame_t"), 0);
rb_mMJITHooks = rb_const_get(rb_mMJIT, rb_intern("Hooks")); rb_mRJITHooks = rb_const_get(rb_mRJIT, rb_intern("Hooks"));
mjit_call_p = true; mjit_call_p = true;
mjit_stats_p = mjit_opts.stats; mjit_stats_p = mjit_opts.stats;
@ -546,7 +546,7 @@ mjit_finish(bool close_handle_p)
// TODO: implement // TODO: implement
} }
// Same as `RubyVM::MJIT::C.enabled?`, but this is used before mjit_init. // Same as `RubyVM::RJIT::C.enabled?`, but this is used before mjit_init.
static VALUE static VALUE
mjit_stats_enabled_p(rb_execution_context_t *ec, VALUE self) mjit_stats_enabled_p(rb_execution_context_t *ec, VALUE self)
{ {
@ -564,4 +564,4 @@ mjit_stop_stats(rb_execution_context_t *ec, VALUE self)
#include "mjit.rbinc" #include "mjit.rbinc"
#endif // USE_MJIT #endif // USE_RJIT

42
rjit.h
Просмотреть файл

@ -1,5 +1,5 @@
#ifndef RUBY_MJIT_H #ifndef RUBY_RJIT_H
#define RUBY_MJIT_H 1 #define RUBY_RJIT_H 1
/********************************************************************** /**********************************************************************
mjit.h - Interface to MRI method JIT compiler mjit.h - Interface to MRI method JIT compiler
@ -9,35 +9,35 @@
**********************************************************************/ **********************************************************************/
#include "ruby/internal/config.h" // defines USE_MJIT #include "ruby/internal/config.h" // defines USE_RJIT
#include "ruby/internal/stdbool.h" #include "ruby/internal/stdbool.h"
#include "vm_core.h" #include "vm_core.h"
# if USE_MJIT # if USE_RJIT
#ifndef MJIT_STATS #ifndef RJIT_STATS
# define MJIT_STATS RUBY_DEBUG # define RJIT_STATS RUBY_DEBUG
#endif #endif
#include "ruby.h" #include "ruby.h"
#include "vm_core.h" #include "vm_core.h"
// Special address values of a function generated from the // Special address values of a function generated from the
// corresponding iseq by MJIT: // corresponding iseq by RJIT:
enum rb_mjit_func_state { enum rb_mjit_func_state {
// ISEQ has not been compiled yet // ISEQ has not been compiled yet
MJIT_FUNC_NOT_COMPILED = 0, RJIT_FUNC_NOT_COMPILED = 0,
// ISEQ is already queued for the machine code generation but the // ISEQ is already queued for the machine code generation but the
// code is not ready yet for the execution // code is not ready yet for the execution
MJIT_FUNC_COMPILING = 1, RJIT_FUNC_COMPILING = 1,
// ISEQ included not compilable insn, some internal assertion failed // ISEQ included not compilable insn, some internal assertion failed
// or the unit is unloaded // or the unit is unloaded
MJIT_FUNC_FAILED = 2, RJIT_FUNC_FAILED = 2,
}; };
// Return true if jit_func is part of enum rb_mjit_func_state // Return true if jit_func is part of enum rb_mjit_func_state
#define MJIT_FUNC_STATE_P(jit_func) ((uintptr_t)(jit_func) <= (uintptr_t)MJIT_FUNC_FAILED) #define RJIT_FUNC_STATE_P(jit_func) ((uintptr_t)(jit_func) <= (uintptr_t)RJIT_FUNC_FAILED)
// MJIT options which can be defined on the MRI command line. // RJIT options which can be defined on the MRI command line.
struct mjit_options { struct mjit_options {
// Converted from "jit" feature flag to tell the enablement // Converted from "jit" feature flag to tell the enablement
// information to ruby_show_version(). // information to ruby_show_version().
@ -46,7 +46,7 @@ struct mjit_options {
// include the pre-compiled header, C code file generated for ISEQ, // include the pre-compiled header, C code file generated for ISEQ,
// and the corresponding object file. // and the corresponding object file.
bool save_temps; bool save_temps;
// Print MJIT warnings to stderr. // Print RJIT warnings to stderr.
bool warnings; bool warnings;
// Disable compiler optimization and add debug symbols. It can be // Disable compiler optimization and add debug symbols. It can be
// very slow. // very slow.
@ -57,17 +57,17 @@ struct mjit_options {
bool wait; bool wait;
// Number of calls to trigger JIT compilation. For testing. // Number of calls to trigger JIT compilation. For testing.
unsigned int call_threshold; unsigned int call_threshold;
// Collect MJIT statistics // Collect RJIT statistics
bool stats; bool stats;
// Force printing info about MJIT work of level VERBOSE or // Force printing info about RJIT work of level VERBOSE or
// less. 0=silence, 1=medium, 2=verbose. // less. 0=silence, 1=medium, 2=verbose.
int verbose; int verbose;
// Maximal permitted number of iseq JIT codes in a MJIT memory // Maximal permitted number of iseq JIT codes in a RJIT memory
// cache. // cache.
int max_cache_size; int max_cache_size;
// [experimental] Do not start MJIT until MJIT.resume is called. // [experimental] Do not start RJIT until RJIT.resume is called.
bool pause; bool pause;
// [experimental] Call custom RubyVM::MJIT.compile instead of MJIT. // [experimental] Call custom RubyVM::RJIT.compile instead of RJIT.
bool custom; bool custom;
// Enable disasm of all JIT code // Enable disasm of all JIT code
bool dump_disasm; bool dump_disasm;
@ -131,7 +131,7 @@ VALUE mjit_pause(bool wait_p);
VALUE mjit_resume(void); VALUE mjit_resume(void);
void mjit_finish(bool close_handle_p); void mjit_finish(bool close_handle_p);
# else // USE_MJIT # else // USE_RJIT
static inline void mjit_cancel_all(const char *reason){} static inline void mjit_cancel_all(const char *reason){}
static inline void mjit_free_iseq(const rb_iseq_t *iseq){} static inline void mjit_free_iseq(const rb_iseq_t *iseq){}
@ -154,5 +154,5 @@ static inline void mjit_finish(bool close_handle_p){}
static inline void rb_mjit_collect_vm_usage_insn(int insn) {} static inline void rb_mjit_collect_vm_usage_insn(int insn) {}
# endif // USE_MJIT # endif // USE_RJIT
#endif // RUBY_MJIT_H #endif // RUBY_RJIT_H

Просмотреть файл

@ -1,5 +1,5 @@
module RubyVM::MJIT module RubyVM::RJIT
# Return true if MJIT is enabled. # Return true if RJIT is enabled.
def self.enabled? def self.enabled?
Primitive.cexpr! 'RBOOL(mjit_enabled)' Primitive.cexpr! 'RBOOL(mjit_enabled)'
end end
@ -22,12 +22,12 @@ module RubyVM::MJIT
end end
end end
if RubyVM::MJIT.enabled? if RubyVM::RJIT.enabled?
begin begin
require 'fiddle' require 'fiddle'
require 'fiddle/import' require 'fiddle/import'
rescue LoadError rescue LoadError
return # miniruby doesn't support MJIT return # miniruby doesn't support RJIT
end end
require 'ruby_vm/mjit/c_type' require 'ruby_vm/mjit/c_type'

Просмотреть файл

@ -1,17 +1,17 @@
/********************************************************************** /**********************************************************************
mjit_c.c - C helpers for MJIT mjit_c.c - C helpers for RJIT
Copyright (C) 2017 Takashi Kokubun <k0kubun@ruby-lang.org>. Copyright (C) 2017 Takashi Kokubun <k0kubun@ruby-lang.org>.
**********************************************************************/ **********************************************************************/
#include "ruby/internal/config.h" // defines USE_MJIT #include "ruby/internal/config.h" // defines USE_RJIT
// ISO C requires a translation unit to contain at least one declaration // ISO C requires a translation unit to contain at least one declaration
void rb_mjit_c(void) {} void rb_mjit_c(void) {}
#if USE_MJIT #if USE_RJIT
#include "mjit.h" #include "mjit.h"
#include "mjit_c.h" #include "mjit_c.h"
@ -42,7 +42,7 @@ void rb_mjit_c(void) {}
#define SIZEOF(type) RB_SIZE2NUM(sizeof(type)) #define SIZEOF(type) RB_SIZE2NUM(sizeof(type))
#define SIGNED_TYPE_P(type) RBOOL((type)(-1) < (type)(1)) #define SIGNED_TYPE_P(type) RBOOL((type)(-1) < (type)(1))
#if MJIT_STATS #if RJIT_STATS
// Insn side exit counters // Insn side exit counters
static size_t mjit_insn_exits[VM_INSTRUCTION_SIZE] = { 0 }; static size_t mjit_insn_exits[VM_INSTRUCTION_SIZE] = { 0 };
#endif // YJIT_STATS #endif // YJIT_STATS
@ -83,7 +83,7 @@ dump_disasm(rb_execution_context_t *ec, VALUE self, VALUE from, VALUE to)
return result; return result;
} }
// Same as `RubyVM::MJIT.enabled?`, but this is used before it's defined. // Same as `RubyVM::RJIT.enabled?`, but this is used before it's defined.
static VALUE static VALUE
mjit_enabled_p(rb_execution_context_t *ec, VALUE self) mjit_enabled_p(rb_execution_context_t *ec, VALUE self)
{ {
@ -122,4 +122,4 @@ extern ID rb_get_symbol_id(VALUE name);
#include "mjit_c.rbinc" #include "mjit_c.rbinc"
#endif // USE_MJIT #endif // USE_RJIT

Просмотреть файл

@ -1,6 +1,6 @@
// This file is parsed by tool/mjit/generate.rb to generate mjit_c.rb // This file is parsed by tool/mjit/generate.rb to generate mjit_c.rb
#ifndef MJIT_C_H #ifndef RJIT_C_H
#define MJIT_C_H #define RJIT_C_H
#include "ruby/internal/config.h" #include "ruby/internal/config.h"
#include "internal/string.h" #include "internal/string.h"
@ -25,14 +25,14 @@ struct rb_mjit_unit_list {
enum rb_mjit_unit_type { enum rb_mjit_unit_type {
// Single-ISEQ unit for unit_queue // Single-ISEQ unit for unit_queue
MJIT_UNIT_ISEQ = 0, RJIT_UNIT_ISEQ = 0,
// Multi-ISEQ unit for mjit_batch // Multi-ISEQ unit for mjit_batch
MJIT_UNIT_BATCH = 1, RJIT_UNIT_BATCH = 1,
// All-ISEQ unit for mjit_compact // All-ISEQ unit for mjit_compact
MJIT_UNIT_COMPACT = 2, RJIT_UNIT_COMPACT = 2,
}; };
// The unit structure that holds metadata of ISeq for MJIT. // The unit structure that holds metadata of ISeq for RJIT.
// TODO: Use different structs for ISEQ and BATCH/COMPACT // TODO: Use different structs for ISEQ and BATCH/COMPACT
struct rb_mjit_unit { struct rb_mjit_unit {
struct ccan_list_node unode; struct ccan_list_node unode;
@ -41,7 +41,7 @@ struct rb_mjit_unit {
// Type of this unit // Type of this unit
enum rb_mjit_unit_type type; enum rb_mjit_unit_type type;
/* MJIT_UNIT_ISEQ */ /* RJIT_UNIT_ISEQ */
// ISEQ for a non-batch unit // ISEQ for a non-batch unit
rb_iseq_t *iseq; rb_iseq_t *iseq;
// Only used by unload_units. Flag to check this unit is currently on stack or not. // Only used by unload_units. Flag to check this unit is currently on stack or not.
@ -53,11 +53,11 @@ struct rb_mjit_unit {
// ISEQ_BODY(iseq)->ci_size + ones of inlined iseqs // ISEQ_BODY(iseq)->ci_size + ones of inlined iseqs
unsigned int cc_entries_size; unsigned int cc_entries_size;
/* MJIT_UNIT_BATCH, MJIT_UNIT_COMPACT */ /* RJIT_UNIT_BATCH, RJIT_UNIT_COMPACT */
// Dlopen handle of the loaded object file. // Dlopen handle of the loaded object file.
void *handle; void *handle;
// Units compacted by this batch // Units compacted by this batch
struct rb_mjit_unit_list units; // MJIT_UNIT_BATCH only struct rb_mjit_unit_list units; // RJIT_UNIT_BATCH only
}; };
// Storage to keep data which is consistent in each conditional branch. // Storage to keep data which is consistent in each conditional branch.
@ -103,12 +103,12 @@ struct compile_status {
// //
// TODO: Make it configurable // TODO: Make it configurable
#define MJIT_CODE_SIZE 64 * 1024 * 1024 #define RJIT_CODE_SIZE 64 * 1024 * 1024
extern uint8_t *rb_mjit_mem_block; extern uint8_t *rb_mjit_mem_block;
#define MJIT_RUNTIME_COUNTERS(...) struct rb_mjit_runtime_counters { size_t __VA_ARGS__; }; #define RJIT_RUNTIME_COUNTERS(...) struct rb_mjit_runtime_counters { size_t __VA_ARGS__; };
MJIT_RUNTIME_COUNTERS( RJIT_RUNTIME_COUNTERS(
vm_insns_count, vm_insns_count,
mjit_insns_count, mjit_insns_count,
@ -207,7 +207,7 @@ MJIT_RUNTIME_COUNTERS(
compiled_block_count compiled_block_count
) )
#undef MJIT_RUNTIME_COUNTERS #undef RJIT_RUNTIME_COUNTERS
extern struct rb_mjit_runtime_counters rb_mjit_counters; extern struct rb_mjit_runtime_counters rb_mjit_counters;
#endif /* MJIT_C_H */ #endif /* RJIT_C_H */

Просмотреть файл

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
# Part of this file is generated by tool/mjit/bindgen.rb. # Part of this file is generated by tool/mjit/bindgen.rb.
# Run `make mjit-bindgen` to update code between "MJIT bindgen begin" and "MJIT bindgen end". # Run `make mjit-bindgen` to update code between "RJIT bindgen begin" and "RJIT bindgen end".
module RubyVM::MJIT # :nodoc: all module RubyVM::RJIT # :nodoc: all
# This `class << C` section is for calling C functions. For importing variables # This `class << C` section is for calling C functions. For importing variables
# or macros as is, please consider using tool/mjit/bindgen.rb instead. # or macros as is, please consider using tool/mjit/bindgen.rb instead.
class << C = Object.new class << C = Object.new
@ -12,7 +12,7 @@ module RubyVM::MJIT # :nodoc: all
def mjit_mark_writable def mjit_mark_writable
Primitive.cstmt! %{ Primitive.cstmt! %{
extern bool rb_yjit_mark_writable(void *mem_block, uint32_t mem_size); extern bool rb_yjit_mark_writable(void *mem_block, uint32_t mem_size);
rb_yjit_mark_writable(rb_mjit_mem_block, MJIT_CODE_SIZE); rb_yjit_mark_writable(rb_mjit_mem_block, RJIT_CODE_SIZE);
return Qnil; return Qnil;
} }
end end
@ -20,14 +20,14 @@ module RubyVM::MJIT # :nodoc: all
def mjit_mark_executable def mjit_mark_executable
Primitive.cstmt! %{ Primitive.cstmt! %{
extern bool rb_yjit_mark_executable(void *mem_block, uint32_t mem_size); extern bool rb_yjit_mark_executable(void *mem_block, uint32_t mem_size);
rb_yjit_mark_executable(rb_mjit_mem_block, MJIT_CODE_SIZE); rb_yjit_mark_executable(rb_mjit_mem_block, RJIT_CODE_SIZE);
return Qnil; return Qnil;
} }
end end
def mjit_insn_exits def mjit_insn_exits
addr = Primitive.cstmt! %{ addr = Primitive.cstmt! %{
#if MJIT_STATS #if RJIT_STATS
return SIZET2NUM((size_t)mjit_insn_exits); return SIZET2NUM((size_t)mjit_insn_exits);
#else #else
return SIZET2NUM(0); return SIZET2NUM(0);
@ -45,7 +45,7 @@ module RubyVM::MJIT # :nodoc: all
def rb_mjit_counters def rb_mjit_counters
addr = Primitive.cstmt! %{ addr = Primitive.cstmt! %{
#if MJIT_STATS #if RJIT_STATS
return SIZET2NUM((size_t)&rb_mjit_counters); return SIZET2NUM((size_t)&rb_mjit_counters);
#else #else
return SIZET2NUM(0); return SIZET2NUM(0);
@ -569,7 +569,7 @@ module RubyVM::MJIT # :nodoc: all
end end
end end
### MJIT bindgen begin ### ### RJIT bindgen begin ###
def C.USE_LAZY_LOAD def C.USE_LAZY_LOAD
Primitive.cexpr! %q{ RBOOL(USE_LAZY_LOAD != 0) } Primitive.cexpr! %q{ RBOOL(USE_LAZY_LOAD != 0) }
@ -1872,5 +1872,5 @@ module RubyVM::MJIT # :nodoc: all
CType::Stub.new(:rb_ext_config) CType::Stub.new(:rb_ext_config)
end end
### MJIT bindgen end ### ### RJIT bindgen end ###
end if Primitive.mjit_enabled_p end if Primitive.mjit_enabled_p

34
ruby.c
Просмотреть файл

@ -118,7 +118,7 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
enum feature_flag_bits { enum feature_flag_bits {
EACH_FEATURES(DEFINE_FEATURE, COMMA), EACH_FEATURES(DEFINE_FEATURE, COMMA),
feature_debug_flag_first, feature_debug_flag_first,
#if defined(MJIT_FORCE_ENABLE) || !USE_YJIT #if defined(RJIT_FORCE_ENABLE) || !USE_YJIT
DEFINE_FEATURE(jit) = feature_mjit, DEFINE_FEATURE(jit) = feature_mjit,
#else #else
DEFINE_FEATURE(jit) = feature_yjit, DEFINE_FEATURE(jit) = feature_yjit,
@ -213,7 +213,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
opt->ext.enc.index = -1; opt->ext.enc.index = -1;
opt->intern.enc.index = -1; opt->intern.enc.index = -1;
opt->features.set = DEFAULT_FEATURES; opt->features.set = DEFAULT_FEATURES;
#ifdef MJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DMJIT_FORCE_ENABLE" */ #ifdef RJIT_FORCE_ENABLE /* to use with: ./configure cppflags="-DRJIT_FORCE_ENABLE" */
opt->features.set |= FEATURE_BIT(mjit); opt->features.set |= FEATURE_BIT(mjit);
#elif defined(YJIT_FORCE_ENABLE) #elif defined(YJIT_FORCE_ENABLE)
opt->features.set |= FEATURE_BIT(yjit); opt->features.set |= FEATURE_BIT(yjit);
@ -286,7 +286,7 @@ 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("-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("-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), M("--jit", "", "enable JIT for the platform, same as " PLATFORM_JIT_OPTION),
#if USE_MJIT #if USE_RJIT
M("--mjit", "", "enable C compiler-based JIT compiler (experimental)"), M("--mjit", "", "enable C compiler-based JIT compiler (experimental)"),
#endif #endif
#if USE_YJIT #if USE_YJIT
@ -321,7 +321,7 @@ usage(const char *name, int help, int highlight, int columns)
M("syntax_suggest", "", "syntax_suggest (default: "DEFAULT_RUBYGEMS_ENABLED")"), M("syntax_suggest", "", "syntax_suggest (default: "DEFAULT_RUBYGEMS_ENABLED")"),
M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"), M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
M("frozen-string-literal", "", "freeze all string literals (default: disabled)"), M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
#if USE_MJIT #if USE_RJIT
M("mjit", "", "C compiler-based JIT compiler (default: disabled)"), M("mjit", "", "C compiler-based JIT compiler (default: disabled)"),
#endif #endif
#if USE_YJIT #if USE_YJIT
@ -332,7 +332,7 @@ usage(const char *name, int help, int highlight, int columns)
M("deprecated", "", "deprecated features"), M("deprecated", "", "deprecated features"),
M("experimental", "", "experimental features"), M("experimental", "", "experimental features"),
}; };
#if USE_MJIT #if USE_RJIT
extern const struct ruby_opt_message mjit_option_messages[]; extern const struct ruby_opt_message mjit_option_messages[];
#endif #endif
#if USE_YJIT #if USE_YJIT
@ -370,8 +370,8 @@ usage(const char *name, int help, int highlight, int columns)
printf("%s""Warning categories:%s\n", sb, se); printf("%s""Warning categories:%s\n", sb, se);
for (i = 0; i < numberof(warn_categories); ++i) for (i = 0; i < numberof(warn_categories); ++i)
SHOW(warn_categories[i]); SHOW(warn_categories[i]);
#if USE_MJIT #if USE_RJIT
printf("%s""MJIT options (experimental):%s\n", sb, se); printf("%s""RJIT options (experimental):%s\n", sb, se);
for (i = 0; mjit_option_messages[i].str; ++i) for (i = 0; mjit_option_messages[i].str; ++i)
SHOW(mjit_option_messages[i]); SHOW(mjit_option_messages[i]);
#endif #endif
@ -957,7 +957,7 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable)
goto found; goto found;
} }
if (NAME_MATCH_P("all", str, len)) { if (NAME_MATCH_P("all", str, len)) {
// YJIT and MJIT cannot be enabled at the same time. We enable only one for --enable=all. // YJIT and RJIT cannot be enabled at the same time. We enable only one for --enable=all.
mask &= ~feature_jit_mask | FEATURE_BIT(jit); mask &= ~feature_jit_mask | FEATURE_BIT(jit);
goto found; goto found;
} }
@ -1486,19 +1486,19 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
ruby_verbose = Qtrue; ruby_verbose = Qtrue;
} }
else if (strcmp("jit", s) == 0) { else if (strcmp("jit", s) == 0) {
#if !USE_MJIT #if !USE_RJIT
rb_warn("Ruby was built without JIT support"); rb_warn("Ruby was built without JIT support");
#else #else
FEATURE_SET(opt->features, FEATURE_BIT(jit)); FEATURE_SET(opt->features, FEATURE_BIT(jit));
#endif #endif
} }
else if (is_option_with_optarg("mjit", '-', true, false, false)) { else if (is_option_with_optarg("mjit", '-', true, false, false)) {
#if USE_MJIT #if USE_RJIT
extern void mjit_setup_options(const char *s, struct mjit_options *mjit_opt); extern void mjit_setup_options(const char *s, struct mjit_options *mjit_opt);
FEATURE_SET(opt->features, FEATURE_BIT(mjit)); FEATURE_SET(opt->features, FEATURE_BIT(mjit));
mjit_setup_options(s, &opt->mjit); mjit_setup_options(s, &opt->mjit);
#else #else
rb_warn("MJIT support is disabled."); rb_warn("RJIT support is disabled.");
#endif #endif
} }
else if (is_option_with_optarg("yjit", '-', true, false, false)) { else if (is_option_with_optarg("yjit", '-', true, false, false)) {
@ -1611,8 +1611,8 @@ ruby_opt_init(ruby_cmdline_options_t *opt)
rb_warning_category_update(opt->warn.mask, opt->warn.set); rb_warning_category_update(opt->warn.mask, opt->warn.set);
#if USE_MJIT #if USE_RJIT
// rb_call_builtin_inits depends on RubyVM::MJIT.enabled? // rb_call_builtin_inits depends on RubyVM::RJIT.enabled?
if (opt->mjit.on) if (opt->mjit.on)
mjit_enabled = true; mjit_enabled = true;
if (opt->mjit.stats) if (opt->mjit.stats)
@ -1625,8 +1625,8 @@ ruby_opt_init(ruby_cmdline_options_t *opt)
ruby_init_prelude(); ruby_init_prelude();
// Initialize JITs after prelude because JITing prelude is typically not optimal. // Initialize JITs after prelude because JITing prelude is typically not optimal.
#if USE_MJIT #if USE_RJIT
// Also, mjit_init is safe only after rb_call_builtin_inits() defines RubyVM::MJIT::Compiler. // Also, mjit_init is safe only after rb_call_builtin_inits() defines RubyVM::RJIT::Compiler.
if (opt->mjit.on) if (opt->mjit.on)
mjit_init(&opt->mjit); mjit_init(&opt->mjit);
#endif #endif
@ -1935,11 +1935,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
#endif #endif
} }
if (MULTI_BITS_P(FEATURE_SET_BITS(opt->features) & feature_jit_mask)) { if (MULTI_BITS_P(FEATURE_SET_BITS(opt->features) & feature_jit_mask)) {
rb_warn("MJIT and YJIT cannot both be enabled at the same time. Exiting"); rb_warn("RJIT and YJIT cannot both be enabled at the same time. Exiting");
return Qfalse; return Qfalse;
} }
#if USE_MJIT #if USE_RJIT
if (FEATURE_SET_P(opt->features, mjit)) { if (FEATURE_SET_P(opt->features, mjit)) {
opt->mjit.on = true; // set opt->mjit.on for Init_ruby_description() and calling mjit_init() opt->mjit.on = true; // set opt->mjit.on for Init_ruby_description() and calling mjit_init()
} }

Просмотреть файл

@ -8,6 +8,6 @@ describe "The -v command line option" do
it "prints version and ends" do it "prints version and ends" do
ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION) ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION)
end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) || end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) ||
(defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?) (defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?)
end end
end end

Просмотреть файл

@ -19,11 +19,11 @@ describe "IO#flush" do
end end
end end
# [ruby-core:90895] MJIT worker may leave fd open in a forked child. # [ruby-core:90895] RJIT worker may leave fd open in a forked child.
# For instance, MJIT creates a worker before @r.close with fork(), @r.close happens, # For instance, RJIT creates a worker before @r.close with fork(), @r.close happens,
# and the MJIT worker keeps the pipe open until the worker execve(). # and the RJIT worker keeps the pipe open until the worker execve().
# TODO: consider acquiring GVL from MJIT worker. # TODO: consider acquiring GVL from RJIT worker.
guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do guard_not -> { defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? } do
it "raises Errno::EPIPE if sync=false and the read end is closed" do it "raises Errno::EPIPE if sync=false and the read end is closed" do
@w.sync = false @w.sync = false
@w.write "foo" @w.write "foo"

Просмотреть файл

@ -85,11 +85,11 @@ describe :io_write, shared: true do
@r.read.should == "foo" @r.read.should == "foo"
end end
# [ruby-core:90895] MJIT worker may leave fd open in a forked child. # [ruby-core:90895] RJIT worker may leave fd open in a forked child.
# For instance, MJIT creates a worker before @r.close with fork(), @r.close happens, # For instance, RJIT creates a worker before @r.close with fork(), @r.close happens,
# and the MJIT worker keeps the pipe open until the worker execve(). # and the RJIT worker keeps the pipe open until the worker execve().
# TODO: consider acquiring GVL from MJIT worker. # TODO: consider acquiring GVL from RJIT worker.
guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do guard_not -> { defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? } do
it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do
@r.close @r.close
-> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/) -> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/)

Просмотреть файл

@ -4,7 +4,7 @@ describe "Process.wait2" do
before :all do before :all do
# HACK: this kludge is temporarily necessary because some # HACK: this kludge is temporarily necessary because some
# misbehaving spec somewhere else does not clear processes # misbehaving spec somewhere else does not clear processes
# Note: background processes are unavoidable with MJIT, # Note: background processes are unavoidable with RJIT,
# but we shouldn't reap them from Ruby-space # but we shouldn't reap them from Ruby-space
begin begin
Process.wait(-1, Process::WNOHANG) Process.wait(-1, Process::WNOHANG)

Просмотреть файл

@ -2249,10 +2249,10 @@ PREDEFINED += DEPRECATED(_)=_
PREDEFINED += DEPRECATED_BY(__,_)=_ PREDEFINED += DEPRECATED_BY(__,_)=_
PREDEFINED += ENUM_OVER_INT=1 PREDEFINED += ENUM_OVER_INT=1
PREDEFINED += ERRORFUNC(__,_)=_ PREDEFINED += ERRORFUNC(__,_)=_
PREDEFINED += MJIT_FUNC_EXPORTED= PREDEFINED += RJIT_FUNC_EXPORTED=
PREDEFINED += MJIT_STATIC=extern PREDEFINED += RJIT_STATIC=extern
PREDEFINED += MJIT_SYMBOL_EXPORT_BEGIN= PREDEFINED += RJIT_SYMBOL_EXPORT_BEGIN=
PREDEFINED += MJIT_SYMBOL_EXPORT_END= PREDEFINED += RJIT_SYMBOL_EXPORT_END=
PREDEFINED += NOINLINE(_)=_ PREDEFINED += NOINLINE(_)=_
PREDEFINED += NORETURN(_)=_ PREDEFINED += NORETURN(_)=_
PREDEFINED += PACKED_STRUCT_UNALIGNED(_)=_ PREDEFINED += PACKED_STRUCT_UNALIGNED(_)=_

Просмотреть файл

@ -95,13 +95,13 @@ XCFLAGS = @XCFLAGS@ $(INCFLAGS) $(_RUBY_DEVEL_enabled:yes=-DRUBY_DEVEL=1)
USE_RUBYGEMS = @USE_RUBYGEMS@ USE_RUBYGEMS = @USE_RUBYGEMS@
USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=) USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=)
CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1) CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
MJIT_SUPPORT = @MJIT_SUPPORT@ RJIT_SUPPORT = @RJIT_SUPPORT@
MJIT_CC = @MJIT_CC@ RJIT_CC = @RJIT_CC@
MJIT_CFLAGS = @MJIT_CFLAGS@ RJIT_CFLAGS = @RJIT_CFLAGS@
MJIT_OPTFLAGS = @MJIT_OPTFLAGS@ RJIT_OPTFLAGS = @RJIT_OPTFLAGS@
MJIT_DEBUGFLAGS = @MJIT_DEBUGFLAGS@ RJIT_DEBUGFLAGS = @RJIT_DEBUGFLAGS@
MJIT_LDSHARED = @MJIT_LDSHARED@ RJIT_LDSHARED = @RJIT_LDSHARED@
MJIT_DLDFLAGS = $(XDLDFLAGS) RJIT_DLDFLAGS = $(XDLDFLAGS)
YJIT_SUPPORT=@YJIT_SUPPORT@ YJIT_SUPPORT=@YJIT_SUPPORT@
YJIT_LIBS=@YJIT_LIBS@ YJIT_LIBS=@YJIT_LIBS@
YJIT_OBJ=@YJIT_OBJ@ YJIT_OBJ=@YJIT_OBJ@

Просмотреть файл

@ -23,7 +23,7 @@ File.read(File.join(arg['srcdir'], 'version.c')).
scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |n, s, v| scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |n, s, v|
version[n] = arg[v] || src.value(v) || (s ? v : 0) version[n] = arg[v] || src.value(v) || (s ? v : 0)
end end
arg['RUBY_DESCRIPTION_WITH_MJIT'] = src.value('description_with_mjit') || 'description_with_mjit' arg['RUBY_DESCRIPTION_WITH_RJIT'] = src.value('description_with_mjit') || 'description_with_mjit'
arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit') || 'description_with_yjit' arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit') || 'description_with_yjit'
%>baseruby="<%=arg['BASERUBY']%>" %>baseruby="<%=arg['BASERUBY']%>"
_\ _\
@ -41,8 +41,8 @@ class Object
constants.grep(/^RUBY_/) {|n| remove_const n} constants.grep(/^RUBY_/) {|n| remove_const n}
% arg['versions'].each {|n, v| % arg['versions'].each {|n, v|
<%=n%> = <%if n=='RUBY_DESCRIPTION' %>case <%=n%> = <%if n=='RUBY_DESCRIPTION' %>case
when RubyVM.const_defined?(:MJIT) && RubyVM::MJIT.enabled? when RubyVM.const_defined?(:RJIT) && RubyVM::RJIT.enabled?
<%=arg['RUBY_DESCRIPTION_WITH_MJIT'].inspect%> <%=arg['RUBY_DESCRIPTION_WITH_RJIT'].inspect%>
when RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled? when RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled?
<%=arg['RUBY_DESCRIPTION_WITH_YJIT'].inspect%> <%=arg['RUBY_DESCRIPTION_WITH_YJIT'].inspect%>
else else

Просмотреть файл

@ -12,7 +12,7 @@ class TestBugReporter < Test::Unit::TestCase
omit if ENV['RUBY_ON_BUG'] omit if ENV['RUBY_ON_BUG']
description = RUBY_DESCRIPTION description = RUBY_DESCRIPTION
description = description.sub(/\+MJIT /, '') unless JITSupport.mjit_force_enabled? description = description.sub(/\+RJIT /, '') unless JITSupport.mjit_force_enabled?
expected_stderr = [ expected_stderr = [
:*, :*,
/\[BUG\]\sSegmentation\sfault.*\n/, /\[BUG\]\sSegmentation\sfault.*\n/,

Просмотреть файл

@ -329,7 +329,7 @@ line,5,jkl
if defined?(RubyVM::YJIT.enabled?) and RubyVM::YJIT.enabled? if defined?(RubyVM::YJIT.enabled?) and RubyVM::YJIT.enabled?
timeout = 1 # for --yjit-call-threshold=1 timeout = 1 # for --yjit-call-threshold=1
end end
if defined?(RubyVM::MJIT.enabled?) and RubyVM::MJIT.enabled? if defined?(RubyVM::RJIT.enabled?) and RubyVM::RJIT.enabled?
timeout = 5 # for --jit-wait timeout = 5 # for --jit-wait
end end
Timeout.timeout(timeout) do Timeout.timeout(timeout) do

Просмотреть файл

@ -218,7 +218,7 @@ module DRbCore
omit if RUBY_PLATFORM.include?("armv7l-linux") omit if RUBY_PLATFORM.include?("armv7l-linux")
omit if RUBY_PLATFORM.include?("sparc-solaris2.10") omit if RUBY_PLATFORM.include?("sparc-solaris2.10")
omit if RUBY_PLATFORM.include?("freebsd") omit if RUBY_PLATFORM.include?("freebsd")
omit if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # expecting a certain delay is difficult for --jit-wait CI omit if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # expecting a certain delay is difficult for --jit-wait CI
Timeout.timeout(60) do Timeout.timeout(60) do
ten = Onecky.new(10) ten = Onecky.new(10)
assert_raise(Timeout::Error) do assert_raise(Timeout::Error) do

Просмотреть файл

@ -54,11 +54,11 @@ module JITSupport
) )
end end
# For MJIT # For RJIT
def supported? def supported?
return @supported if defined?(@supported) return @supported if defined?(@supported)
@supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' && @supported = RbConfig::CONFIG["RJIT_SUPPORT"] != 'no' &&
UNSUPPORTED_COMPILERS.all? { |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) } && UNSUPPORTED_COMPILERS.all? { |regexp| !regexp.match?(RbConfig::CONFIG['RJIT_CC']) } &&
!PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) && !PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) &&
!UNSUPPORTED_ARCHITECTURES.include?(RUBY_PLATFORM.split('-', 2).first) !UNSUPPORTED_ARCHITECTURES.include?(RUBY_PLATFORM.split('-', 2).first)
end end
@ -70,8 +70,8 @@ module JITSupport
end end
def remove_mjit_logs(stderr) def remove_mjit_logs(stderr)
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # utility for -DFORCE_MJIT_ENABLE if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # utility for -DFORCE_RJIT_ENABLE
stderr.gsub(/^MJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '') stderr.gsub(/^RJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '')
else else
stderr stderr
end end
@ -88,6 +88,6 @@ module JITSupport
end end
def mjit_force_enabled? def mjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?MJIT_FORCE_ENABLE\b/) "#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?RJIT_FORCE_ENABLE\b/)
end end
end end

Просмотреть файл

@ -313,7 +313,7 @@ EOS
def test_read_body_block_mod def test_read_body_block_mod
# http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3019353 # http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3019353
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
omit 'too unstable with --jit-wait, and extending read_timeout did not help it' omit 'too unstable with --jit-wait, and extending read_timeout did not help it'
end end
IO.pipe do |r, w| IO.pipe do |r, w|

Просмотреть файл

@ -9,7 +9,7 @@ class Reline::WithinPipeTest < Reline::TestCase
@reader, @output_writer = IO.pipe(@encoding) @reader, @output_writer = IO.pipe(@encoding)
@output = Reline.output = @output_writer @output = Reline.output = @output_writer
@config = Reline.send(:core).config @config = Reline.send(:core).config
@config.keyseq_timeout *= 600 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait CI @config.keyseq_timeout *= 600 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait CI
@line_editor = Reline.send(:core).line_editor @line_editor = Reline.send(:core).line_editor
end end

Просмотреть файл

@ -402,7 +402,7 @@ module TupleSpaceTestModule
end end
def test_cancel_02 def test_cancel_02
omit 'this test is unstable with --jit-wait' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit 'this test is unstable with --jit-wait' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
entry = @ts.write([:removeme, 1]) entry = @ts.write([:removeme, 1])
assert_equal([[:removeme, 1]], @ts.read_all([nil, nil])) assert_equal([[:removeme, 1]], @ts.read_all([nil, nil]))
entry.cancel entry.cancel
@ -686,7 +686,7 @@ class TestRingServer < Test::Unit::TestCase
end end
def test_do_reply_local def test_do_reply_local
omit 'timeout-based test becomes unstable with --jit-wait' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit 'timeout-based test becomes unstable with --jit-wait' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
with_timeout(30) {_test_do_reply_local} with_timeout(30) {_test_do_reply_local}
end end

Просмотреть файл

@ -34,7 +34,7 @@ class TestFiber < Test::Unit::TestCase
end end
def test_many_fibers def test_many_fibers
omit 'This is unstable on GitHub Actions --jit-wait. TODO: debug it' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit 'This is unstable on GitHub Actions --jit-wait. TODO: debug it' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
max = 1000 max = 1000
assert_equal(max, max.times{ assert_equal(max, max.times{
Fiber.new{} Fiber.new{}

Просмотреть файл

@ -655,7 +655,7 @@ class TestIO < Test::Unit::TestCase
if have_nonblock? if have_nonblock?
def test_copy_stream_no_busy_wait def test_copy_stream_no_busy_wait
omit "MJIT has busy wait on GC. This sometimes fails with --jit." if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit "RJIT has busy wait on GC. This sometimes fails with --jit." if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
omit "multiple threads already active" if Thread.list.size > 1 omit "multiple threads already active" if Thread.list.size > 1
msg = 'r58534 [ruby-core:80969] [Backport #13533]' msg = 'r58534 [ruby-core:80969] [Backport #13533]'
@ -1679,7 +1679,7 @@ class TestIO < Test::Unit::TestCase
end if have_nonblock? end if have_nonblock?
def test_read_nonblock_no_exceptions def test_read_nonblock_no_exceptions
omit '[ruby-core:90895] MJIT worker may leave fd open in a forked child' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # TODO: consider acquiring GVL from MJIT worker. omit '[ruby-core:90895] RJIT worker may leave fd open in a forked child' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # TODO: consider acquiring GVL from RJIT worker.
with_pipe {|r, w| with_pipe {|r, w|
assert_equal :wait_readable, r.read_nonblock(4096, exception: false) assert_equal :wait_readable, r.read_nonblock(4096, exception: false)
w.puts "HI!" w.puts "HI!"
@ -2349,7 +2349,7 @@ class TestIO < Test::Unit::TestCase
def test_autoclose_true_closed_by_finalizer def test_autoclose_true_closed_by_finalizer
# http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1465760 # http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1465760
# http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1469765 # http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1469765
omit 'this randomly fails with MJIT' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit 'this randomly fails with RJIT' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
feature2250 = '[ruby-core:26222]' feature2250 = '[ruby-core:26222]'
pre = 'ft2250' pre = 'ft2250'

Просмотреть файл

@ -3172,7 +3172,7 @@ class TestModule < Test::Unit::TestCase
end end
def test_redefinition_mismatch def test_redefinition_mismatch
omit "Investigating trunk-mjit failure on ci.rvm.jp" if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit "Investigating trunk-mjit failure on ci.rvm.jp" if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
m = Module.new m = Module.new
m.module_eval "A = 1", __FILE__, line = __LINE__ m.module_eval "A = 1", __FILE__, line = __LINE__
e = assert_raise_with_message(TypeError, /is not a module/) { e = assert_raise_with_message(TypeError, /is not a module/) {

Просмотреть файл

@ -510,7 +510,7 @@ class TestRubyOptimization < Test::Unit::TestCase
end end
def test_tailcall_not_to_grow_stack def test_tailcall_not_to_grow_stack
omit 'currently JIT-ed code always creates a new stack frame' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit 'currently JIT-ed code always creates a new stack frame' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
bug16161 = '[ruby-core:94881]' bug16161 = '[ruby-core:94881]'
tailcall("#{<<-"begin;"}\n#{<<~"end;"}") tailcall("#{<<-"begin;"}\n#{<<~"end;"}")

Просмотреть файл

@ -272,7 +272,7 @@ class TestProcess < Test::Unit::TestCase
end; end;
end end
MANDATORY_ENVS = %w[RUBYLIB MJIT_SEARCH_BUILD_DIR] MANDATORY_ENVS = %w[RUBYLIB RJIT_SEARCH_BUILD_DIR]
case RbConfig::CONFIG['target_os'] case RbConfig::CONFIG['target_os']
when /linux/ when /linux/
MANDATORY_ENVS << 'LD_PRELOAD' MANDATORY_ENVS << 'LD_PRELOAD'
@ -1717,7 +1717,7 @@ class TestProcess < Test::Unit::TestCase
Process.wait pid Process.wait pid
assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable' assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable'
end end
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE. It may trigger extra SIGCHLD. if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # checking -DRJIT_FORCE_ENABLE. It may trigger extra SIGCHLD.
assert_equal [true], signal_received.uniq, "[ruby-core:19744]" assert_equal [true], signal_received.uniq, "[ruby-core:19744]"
else else
assert_equal [true], signal_received, "[ruby-core:19744]" assert_equal [true], signal_received, "[ruby-core:19744]"

Просмотреть файл

@ -7,12 +7,12 @@ require 'tempfile'
require_relative '../lib/jit_support' require_relative '../lib/jit_support'
class TestRubyOptions < Test::Unit::TestCase class TestRubyOptions < Test::Unit::TestCase
def self.mjit_enabled? = defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? def self.mjit_enabled? = defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled? def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
NO_JIT_DESCRIPTION = NO_JIT_DESCRIPTION =
if mjit_enabled? if mjit_enabled?
RUBY_DESCRIPTION.sub(/\+MJIT /, '') RUBY_DESCRIPTION.sub(/\+RJIT /, '')
elsif yjit_enabled? elsif yjit_enabled?
RUBY_DESCRIPTION.sub(/\+YJIT( (dev|dev_nodebug|stats))? /, '') RUBY_DESCRIPTION.sub(/\+YJIT( (dev|dev_nodebug|stats))? /, '')
else else
@ -140,7 +140,7 @@ class TestRubyOptions < Test::Unit::TestCase
VERSION_PATTERN_WITH_JIT = VERSION_PATTERN_WITH_JIT =
case RUBY_ENGINE case RUBY_ENGINE
when 'ruby' when 'ruby'
/^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+MJIT \[#{q[RUBY_PLATFORM]}\]$/ /^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+RJIT \[#{q[RUBY_PLATFORM]}\]$/
else else
VERSION_PATTERN VERSION_PATTERN
end end
@ -225,8 +225,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_equal([], e) assert_equal([], e)
end end
omit "This fails on some CIs for now. To be fixed in MJIT's side." omit "This fails on some CIs for now. To be fixed in RJIT's side."
return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no' return if RbConfig::CONFIG["RJIT_SUPPORT"] == 'no'
return if yjit_force_enabled? return if yjit_force_enabled?
[ [

Просмотреть файл

@ -2168,9 +2168,9 @@ CODE
} }
# it is dirty hack. usually we shouldn't use such technique # it is dirty hack. usually we shouldn't use such technique
Thread.pass until t.status == 'sleep' Thread.pass until t.status == 'sleep'
# When MJIT thread exists, t.status becomes 'sleep' even if it does not reach m2t_q.pop. # When RJIT thread exists, t.status becomes 'sleep' even if it does not reach m2t_q.pop.
# This sleep forces it to reach m2t_q.pop for --jit-wait. # This sleep forces it to reach m2t_q.pop for --jit-wait.
sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? sleep 1 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
t.add_trace_func proc{|ev, file, line, *args| t.add_trace_func proc{|ev, file, line, *args|
if file == __FILE__ if file == __FILE__

Просмотреть файл

@ -348,7 +348,7 @@ class TestShapes < Test::Unit::TestCase
end end
def test_basic_shape_transition def test_basic_shape_transition
omit "Failing with MJIT for some reason" if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit "Failing with RJIT for some reason" if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
obj = Example.new obj = Example.new
shape = RubyVM::Shape.of(obj) shape = RubyVM::Shape.of(obj)
refute_equal(RubyVM::Shape.root_shape, shape) refute_equal(RubyVM::Shape.root_shape, shape)

Просмотреть файл

@ -323,7 +323,7 @@ class TestThread < Test::Unit::TestCase
s += 1 s += 1
end end
Thread.pass until t.stop? Thread.pass until t.stop?
sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # t.stop? behaves unexpectedly with --jit-wait sleep 1 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # t.stop? behaves unexpectedly with --jit-wait
assert_equal(1, s) assert_equal(1, s)
t.wakeup t.wakeup
Thread.pass while t.alive? Thread.pass while t.alive?
@ -1446,8 +1446,8 @@ q.pop
def test_thread_interrupt_for_killed_thread def test_thread_interrupt_for_killed_thread
opts = { timeout: 5, timeout_error: nil } opts = { timeout: 5, timeout_error: nil }
# prevent SIGABRT from slow shutdown with MJIT # prevent SIGABRT from slow shutdown with RJIT
opts[:reprieve] = 3 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? opts[:reprieve] = 3 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
assert_normal_exit(<<-_end, '[Bug #8996]', **opts) assert_normal_exit(<<-_end, '[Bug #8996]', **opts)
Thread.report_on_exception = false Thread.report_on_exception = false

Просмотреть файл

@ -11,7 +11,7 @@ require_relative '../lib/jit_support'
return unless JITSupport.yjit_supported? return unless JITSupport.yjit_supported?
# Tests for YJIT with assertions on compilation and side exits # Tests for YJIT with assertions on compilation and side exits
# insipired by the MJIT tests in test/ruby/test_mjit.rb # insipired by the RJIT tests in test/ruby/test_mjit.rb
class TestYJIT < Test::Unit::TestCase class TestYJIT < Test::Unit::TestCase
running_with_yjit = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? running_with_yjit = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?

Просмотреть файл

@ -11,7 +11,7 @@ require_relative '../lib/jit_support'
return unless JITSupport.yjit_supported? return unless JITSupport.yjit_supported?
# Tests for YJIT with assertions on tracing exits # Tests for YJIT with assertions on tracing exits
# insipired by the MJIT tests in test/ruby/test_yjit.rb # insipired by the RJIT tests in test/ruby/test_yjit.rb
class TestYJITExitLocations < Test::Unit::TestCase class TestYJITExitLocations < Test::Unit::TestCase
def test_yjit_trace_exits_and_v_no_error def test_yjit_trace_exits_and_v_no_error
_stdout, stderr, _status = EnvUtil.invoke_ruby(%w(-v --yjit-trace-exits), '', true, true) _stdout, stderr, _status = EnvUtil.invoke_ruby(%w(-v --yjit-trace-exits), '', true, true)

Просмотреть файл

@ -4,8 +4,8 @@ require "rubygems/user_interaction"
require "timeout" require "timeout"
class TestGemStreamUI < Gem::TestCase class TestGemStreamUI < Gem::TestCase
# increase timeout with MJIT for --jit-wait testing # increase timeout with RJIT for --jit-wait testing
mjit_enabled = defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? mjit_enabled = defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
SHORT_TIMEOUT = (RUBY_ENGINE == "ruby" && !mjit_enabled) ? 0.1 : 1.0 SHORT_TIMEOUT = (RUBY_ENGINE == "ruby" && !mjit_enabled) ? 0.1 : 1.0
module IsTty module IsTty

Просмотреть файл

@ -486,7 +486,7 @@ class TestSocket < Test::Unit::TestCase
end while IO.select([r], nil, nil, 0.1).nil? end while IO.select([r], nil, nil, 0.1).nil?
n n
end end
timeout = (defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? ? 120 : 30) # for --jit-wait timeout = (defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? ? 120 : 30) # for --jit-wait
assert_equal([[s1],[],[]], IO.select([s1], nil, nil, timeout)) assert_equal([[s1],[],[]], IO.select([s1], nil, nil, timeout))
msg, _, _, stamp = s1.recvmsg msg, _, _, stamp = s1.recvmsg
assert_equal("a", msg) assert_equal("a", msg)

Просмотреть файл

@ -100,7 +100,7 @@
#include "vm_debug.h" #include "vm_debug.h"
#include "vm_sync.h" #include "vm_sync.h"
#if USE_MJIT && defined(HAVE_SYS_WAIT_H) #if USE_RJIT && defined(HAVE_SYS_WAIT_H)
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
@ -2280,7 +2280,7 @@ threadptr_get_interrupts(rb_thread_t *th)
return interrupt & (rb_atomic_t)~ec->interrupt_mask; return interrupt & (rb_atomic_t)~ec->interrupt_mask;
} }
#if USE_MJIT #if USE_RJIT
// process.c // process.c
extern bool mjit_waitpid_finished; extern bool mjit_waitpid_finished;
extern int mjit_waitpid_status; extern int mjit_waitpid_status;
@ -2335,8 +2335,8 @@ rb_threadptr_execute_interrupts(rb_thread_t *th, int blocking_timing)
th->status = prev_status; th->status = prev_status;
} }
#if USE_MJIT #if USE_RJIT
// Handle waitpid_signal for MJIT issued by ruby_sigchld_handler. This needs to be done // Handle waitpid_signal for RJIT issued by ruby_sigchld_handler. This needs to be done
// outside ruby_sigchld_handler to avoid recursively relying on the SIGCHLD handler. // outside ruby_sigchld_handler to avoid recursively relying on the SIGCHLD handler.
if (mjit_waitpid_finished && th == th->vm->ractor.main_thread) { if (mjit_waitpid_finished && th == th->vm->ractor.main_thread) {
mjit_waitpid_finished = false; mjit_waitpid_finished = false;
@ -4621,7 +4621,7 @@ rb_thread_atfork_internal(rb_thread_t *th, void (*atfork)(rb_thread_t *, const r
rb_ractor_atfork(vm, th); rb_ractor_atfork(vm, th);
/* may be held by MJIT threads in parent */ /* may be held by RJIT threads in parent */
rb_native_mutex_initialize(&vm->waitpid_lock); rb_native_mutex_initialize(&vm->waitpid_lock);
rb_native_mutex_initialize(&vm->workqueue_lock); rb_native_mutex_initialize(&vm->workqueue_lock);
@ -4658,7 +4658,7 @@ rb_thread_atfork(void)
/* We don't want reproduce CVE-2003-0900. */ /* We don't want reproduce CVE-2003-0900. */
rb_reset_random_seed(); rb_reset_random_seed();
/* For child, starting MJIT worker thread in this place which is safer than immediately after `after_fork_ruby`. */ /* For child, starting RJIT worker thread in this place which is safer than immediately after `after_fork_ruby`. */
mjit_child_after_fork(); mjit_child_after_fork();
} }

Просмотреть файл

@ -275,7 +275,7 @@ static int ubf_threads_empty(void);
/* /*
* sigwait_th is the thread which owns sigwait_fd and sleeps on it * sigwait_th is the thread which owns sigwait_fd and sleeps on it
* (using ppoll). MJIT worker can be sigwait_th==0, so we initialize * (using ppoll). RJIT worker can be sigwait_th==0, so we initialize
* it to THREAD_INVALID at startup and fork time. It is the ONLY thread * it to THREAD_INVALID at startup and fork time. It is the ONLY thread
* allowed to read from sigwait_fd, otherwise starvation can occur. * allowed to read from sigwait_fd, otherwise starvation can occur.
*/ */

Просмотреть файл

@ -111,8 +111,8 @@ module Test
end end
def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt) def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
# TODO: consider choosing some appropriate limit for MJIT and stop skipping this once it does not randomly fail # TODO: consider choosing some appropriate limit for RJIT and stop skipping this once it does not randomly fail
pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? pend 'assert_no_memory_leak may consider RJIT memory usage as leak' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
require_relative 'memory_status' require_relative 'memory_status'
raise Test::Unit::PendedError, "unsupported platform" unless defined?(Memory::Status) raise Test::Unit::PendedError, "unsupported platform" unless defined?(Memory::Status)

Просмотреть файл

@ -89,16 +89,16 @@ module Test
end end
end end
module MJITFirst module RJITFirst
def group(list) def group(list)
# MJIT first # RJIT first
mjit, others = list.partition {|e| /test_mjit/ =~ e} mjit, others = list.partition {|e| /test_mjit/ =~ e}
mjit + others mjit + others
end end
end end
class Alpha < NoSort class Alpha < NoSort
include MJITFirst include RJITFirst
def sort_by_name(list) def sort_by_name(list)
list.sort_by(&:name) list.sort_by(&:name)
@ -112,7 +112,7 @@ module Test
# shuffle test suites based on CRC32 of their names # shuffle test suites based on CRC32 of their names
Shuffle = Struct.new(:seed, :salt) do Shuffle = Struct.new(:seed, :salt) do
include MJITFirst include RJITFirst
def initialize(seed) def initialize(seed)
self.class::CRC_TBL ||= (0..255).map {|i| self.class::CRC_TBL ||= (0..255).map {|i|
@ -1589,7 +1589,7 @@ module Test
puts if @verbose puts if @verbose
$stdout.flush $stdout.flush
unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # compiler process is wrongly considered as leak unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # compiler process is wrongly considered as leak
leakchecker.check("#{inst.class}\##{inst.__name__}") leakchecker.check("#{inst.class}\##{inst.__name__}")
end end

Просмотреть файл

@ -63,8 +63,8 @@ File.foreach "config.status" do |line|
when /^(?:X|(?:MINI|RUN|(?:HAVE_)?BASE|BOOTSTRAP|BTEST)RUBY(?:_COMMAND)?$)/; next when /^(?:X|(?:MINI|RUN|(?:HAVE_)?BASE|BOOTSTRAP|BTEST)RUBY(?:_COMMAND)?$)/; next
when /^INSTALLDOC|TARGET$/; next when /^INSTALLDOC|TARGET$/; next
when /^DTRACE/; next when /^DTRACE/; next
when /^MJIT_(CC|SUPPORT)$/; # pass when /^RJIT_(CC|SUPPORT)$/; # pass
when /^MJIT_/; next when /^RJIT_/; next
when /^(?:MAJOR|MINOR|TEENY)$/; vars[name] = val; next when /^(?:MAJOR|MINOR|TEENY)$/; vars[name] = val; next
when /^LIBRUBY_D?LD/; next when /^LIBRUBY_D?LD/; next
when /^RUBY_INSTALL_NAME$/; next vars[name] = (install_name = val).dup if $install_name when /^RUBY_INSTALL_NAME$/; next vars[name] = (install_name = val).dup if $install_name

Просмотреть файл

@ -98,8 +98,8 @@ end
# Convert Node objects to a Ruby binding source. # Convert Node objects to a Ruby binding source.
class BindingGenerator class BindingGenerator
BINDGEN_BEG = '### MJIT bindgen begin ###' BINDGEN_BEG = '### RJIT bindgen begin ###'
BINDGEN_END = '### MJIT bindgen end ###' BINDGEN_END = '### RJIT bindgen end ###'
DEFAULTS = { '_Bool' => 'CType::Bool.new' } DEFAULTS = { '_Bool' => 'CType::Bool.new' }
DEFAULTS.default_proc = proc { |_h, k| "CType::Stub.new(:#{k})" } DEFAULTS.default_proc = proc { |_h, k| "CType::Stub.new(:#{k})" }

Просмотреть файл

@ -35,7 +35,7 @@ insn_leaf_p(VALUE insn)
return rb_vm_insn_leaf_p[insn]; return rb_vm_insn_leaf_p[insn];
} }
// This is used to tell MJIT that this insn would be leaf if CHECK_INTS didn't exist. // This is used to tell RJIT that this insn would be leaf if CHECK_INTS didn't exist.
// It should be used only when RUBY_VM_CHECK_INTS is directly written in insns.def. // It should be used only when RUBY_VM_CHECK_INTS is directly written in insns.def.
static bool leafness_of_check_ints = false; static bool leafness_of_check_ints = false;

Просмотреть файл

@ -1,4 +1,4 @@
module RubyVM::MJIT # :nodoc: all module RubyVM::RJIT # :nodoc: all
Instruction = Struct.new( Instruction = Struct.new(
:name, :name,
:bin, :bin,

Просмотреть файл

@ -6,7 +6,7 @@ class TestHideSkip < Test::Unit::TestCase
assert_not_match(/^ *1\) Skipped/, hideskip) assert_not_match(/^ *1\) Skipped/, hideskip)
assert_match(/^ *1\) Skipped.*^ *2\) Skipped/m, hideskip("--show-skip")) assert_match(/^ *1\) Skipped.*^ *2\) Skipped/m, hideskip("--show-skip"))
output = hideskip("--hide-skip") output = hideskip("--hide-skip")
output.gsub!(/Successful MJIT finish\n/, '') if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? output.gsub!(/Successful RJIT finish\n/, '') if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
assert_match(/assertions\/s.\n+2 tests, 0 assertions, 0 failures, 0 errors, 2 skips/, output) assert_match(/assertions\/s.\n+2 tests, 0 assertions, 0 failures, 0 errors, 2 skips/, output)
end end

Просмотреть файл

@ -6,7 +6,7 @@ module TestParallel
PARALLEL_RB = "#{__dir__}/../../lib/test/unit/parallel.rb" PARALLEL_RB = "#{__dir__}/../../lib/test/unit/parallel.rb"
TESTS = "#{__dir__}/tests_for_parallel" TESTS = "#{__dir__}/tests_for_parallel"
# use large timeout for --jit-wait # use large timeout for --jit-wait
TIMEOUT = EnvUtil.apply_timeout_scale(defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? ? 100 : 30) TIMEOUT = EnvUtil.apply_timeout_scale(defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? ? 100 : 30)
class TestParallelWorker < Test::Unit::TestCase class TestParallelWorker < Test::Unit::TestCase
def setup def setup

Просмотреть файл

@ -253,7 +253,7 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase
server.virtual_host(WEBrick::HTTPServer.new(vhost_config)) server.virtual_host(WEBrick::HTTPServer.new(vhost_config))
Thread.pass while server.status != :Running Thread.pass while server.status != :Running
sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # server.status behaves unexpectedly with --jit-wait sleep 1 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # server.status behaves unexpectedly with --jit-wait
assert_equal(1, started, log.call) assert_equal(1, started, log.call)
assert_equal(0, stopped, log.call) assert_equal(0, stopped, log.call)
assert_equal(0, accepted, log.call) assert_equal(0, accepted, log.call)

Просмотреть файл

@ -65,7 +65,7 @@ class TestWEBrickServer < Test::Unit::TestCase
} }
TestWEBrick.start_server(Echo, config){|server, addr, port, log| TestWEBrick.start_server(Echo, config){|server, addr, port, log|
true while server.status != :Running true while server.status != :Running
sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # server.status behaves unexpectedly with --jit-wait sleep 1 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # server.status behaves unexpectedly with --jit-wait
assert_equal(1, started, log.call) assert_equal(1, started, log.call)
assert_equal(0, stopped, log.call) assert_equal(0, stopped, log.call)
assert_equal(0, accepted, log.call) assert_equal(0, accepted, log.call)

Просмотреть файл

@ -71,7 +71,7 @@ const char ruby_release_date[] = RUBY_RELEASE_DATE;
const char ruby_platform[] = RUBY_PLATFORM; const char ruby_platform[] = RUBY_PLATFORM;
const int ruby_patchlevel = RUBY_PATCHLEVEL; const int ruby_patchlevel = RUBY_PATCHLEVEL;
const char ruby_description[] = RUBY_DESCRIPTION_WITH(""); const char ruby_description[] = RUBY_DESCRIPTION_WITH("");
static const char ruby_description_with_mjit[] = RUBY_DESCRIPTION_WITH(" +MJIT"); static const char ruby_description_with_mjit[] = RUBY_DESCRIPTION_WITH(" +RJIT");
static const char ruby_description_with_yjit[] = RUBY_DESCRIPTION_WITH(YJIT_DESCRIPTION); static const char ruby_description_with_yjit[] = RUBY_DESCRIPTION_WITH(YJIT_DESCRIPTION);
const char ruby_copyright[] = "ruby - Copyright (C) " const char ruby_copyright[] = "ruby - Copyright (C) "
RUBY_BIRTH_YEAR_STR "-" RUBY_RELEASE_YEAR_STR " " RUBY_BIRTH_YEAR_STR "-" RUBY_RELEASE_YEAR_STR " "
@ -126,10 +126,10 @@ Init_version(void)
rb_provide("ruby2_keywords.rb"); rb_provide("ruby2_keywords.rb");
} }
#if USE_MJIT #if USE_RJIT
#define MJIT_OPTS_ON opt->mjit.on #define RJIT_OPTS_ON opt->mjit.on
#else #else
#define MJIT_OPTS_ON 0 #define RJIT_OPTS_ON 0
#endif #endif
#if USE_YJIT #if USE_YJIT
@ -143,7 +143,7 @@ Init_ruby_description(ruby_cmdline_options_t *opt)
{ {
VALUE description; VALUE description;
if (MJIT_OPTS_ON) { if (RJIT_OPTS_ON) {
rb_dynamic_description = ruby_description_with_mjit; rb_dynamic_description = ruby_description_with_mjit;
description = MKSTR(description_with_mjit); description = MKSTR(description_with_mjit);
} }

4
vm.c
Просмотреть файл

@ -368,9 +368,9 @@ extern VALUE rb_vm_invoke_bmethod(rb_execution_context_t *ec, rb_proc_t *proc, V
const rb_callable_method_entry_t *me); const rb_callable_method_entry_t *me);
static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE block_handler); static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE block_handler);
#if USE_MJIT || USE_YJIT #if USE_RJIT || USE_YJIT
// Try to execute the current iseq in ec. Use JIT code if it is ready. // Try to execute the current iseq in ec. Use JIT code if it is ready.
// If it is not, add ISEQ to the compilation queue and return Qundef for MJIT. // If it is not, add ISEQ to the compilation queue and return Qundef for RJIT.
// YJIT compiles on the thread running the iseq. // YJIT compiles on the thread running the iseq.
static inline VALUE static inline VALUE
jit_exec(rb_execution_context_t *ec) jit_exec(rb_execution_context_t *ec)

Просмотреть файл

@ -424,7 +424,7 @@ vm_cc_invalidated_p(const struct rb_callcache *cc)
} }
} }
// For MJIT. cc_cme is supposed to have inlined `vm_cc_cme(cc)`. // For RJIT. cc_cme is supposed to have inlined `vm_cc_cme(cc)`.
static inline bool static inline bool
vm_cc_valid_p(const struct rb_callcache *cc, const rb_callable_method_entry_t *cc_cme, VALUE klass) vm_cc_valid_p(const struct rb_callcache *cc, const rb_callable_method_entry_t *cc_cme, VALUE klass)
{ {

Просмотреть файл

@ -503,15 +503,15 @@ struct rb_iseq_constant_body {
const rb_iseq_t *mandatory_only_iseq; const rb_iseq_t *mandatory_only_iseq;
#if USE_MJIT || USE_YJIT #if USE_RJIT || USE_YJIT
// Function pointer for JIT code // Function pointer for JIT code
VALUE (*jit_func)(struct rb_execution_context_struct *, struct rb_control_frame_struct *); VALUE (*jit_func)(struct rb_execution_context_struct *, struct rb_control_frame_struct *);
// Number of total calls with jit_exec() // Number of total calls with jit_exec()
long unsigned total_calls; long unsigned total_calls;
#endif #endif
#if USE_MJIT #if USE_RJIT
// MJIT stores some data on each iseq. // RJIT stores some data on each iseq.
VALUE mjit_blocks; VALUE mjit_blocks;
#endif #endif

Просмотреть файл

@ -5397,7 +5397,7 @@ vm_ic_track_const_chain(rb_control_frame_t *cfp, IC ic, const ID *segments)
RB_VM_LOCK_LEAVE(); RB_VM_LOCK_LEAVE();
} }
// For MJIT inlining // For RJIT inlining
static inline bool static inline bool
vm_inlined_ic_hit_p(VALUE flags, VALUE value, const rb_cref_t *ic_cref, const VALUE *reg_ep) vm_inlined_ic_hit_p(VALUE flags, VALUE value, const rb_cref_t *ic_cref, const VALUE *reg_ep)
{ {

Просмотреть файл

@ -16,8 +16,8 @@ RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_invalidations;
RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_misses; RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_misses;
RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state; RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
#ifndef MJIT_STATS #ifndef RJIT_STATS
# define MJIT_STATS RUBY_DEBUG # define RJIT_STATS RUBY_DEBUG
#endif #endif
#if VM_COLLECT_USAGE_DETAILS #if VM_COLLECT_USAGE_DETAILS
@ -25,12 +25,12 @@ RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
#define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op))) #define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
#define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s)) #define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s))
#elif MJIT_STATS && YJIT_STATS #elif RJIT_STATS && YJIT_STATS
// Both flags could be enabled at the same time. You need to call both in that case. // Both flags could be enabled at the same time. You need to call both in that case.
#define COLLECT_USAGE_INSN(insn) rb_mjit_collect_vm_usage_insn(insn); rb_yjit_collect_vm_usage_insn(insn) #define COLLECT_USAGE_INSN(insn) rb_mjit_collect_vm_usage_insn(insn); rb_yjit_collect_vm_usage_insn(insn)
#define COLLECT_USAGE_OPERAND(insn, n, op) /* none */ #define COLLECT_USAGE_OPERAND(insn, n, op) /* none */
#define COLLECT_USAGE_REGISTER(reg, s) /* none */ #define COLLECT_USAGE_REGISTER(reg, s) /* none */
#elif MJIT_STATS #elif RJIT_STATS
// for --mjit-stats // for --mjit-stats
#define COLLECT_USAGE_INSN(insn) rb_mjit_collect_vm_usage_insn(insn) #define COLLECT_USAGE_INSN(insn) rb_mjit_collect_vm_usage_insn(insn)
#define COLLECT_USAGE_OPERAND(insn, n, op) /* none */ #define COLLECT_USAGE_OPERAND(insn, n, op) /* none */

Просмотреть файл

@ -350,8 +350,8 @@ CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS)
!if "$(USE_RUBYGEMS)" == "no" !if "$(USE_RUBYGEMS)" == "no"
CPPFLAGS = -DDISABLE_RUBYGEMS $(CPPFLAGS) CPPFLAGS = -DDISABLE_RUBYGEMS $(CPPFLAGS)
!endif !endif
!ifndef MJIT_SUPPORT !ifndef RJIT_SUPPORT
MJIT_SUPPORT = no RJIT_SUPPORT = no
!endif !endif
POSTLINK = POSTLINK =
@ -930,7 +930,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define RUBY_COREDLL "$(RT)" #define RUBY_COREDLL "$(RT)"
#define RUBY_PLATFORM "$(arch)" #define RUBY_PLATFORM "$(arch)"
#define RUBY_SITEARCH "$(sitearch)" #define RUBY_SITEARCH "$(sitearch)"
#define USE_MJIT 0 #define USE_RJIT 0
#endif /* $(guard) */ #endif /* $(guard) */
<< <<
@ -1123,7 +1123,7 @@ s,@srcdir@,$(srcdir),;t t
s,@top_srcdir@,$(srcdir),;t t s,@top_srcdir@,$(srcdir),;t t
s,@try_header@,try_compile,;t t s,@try_header@,try_compile,;t t
s,@ruby_pc@,$(ruby_pc),;t t s,@ruby_pc@,$(ruby_pc),;t t
s,@MJIT_SUPPORT@,$(MJIT_SUPPORT),;t t s,@RJIT_SUPPORT@,$(RJIT_SUPPORT),;t t
<<KEEP <<KEEP
!if "$(HAVE_BASERUBY)" != "yes" || "$(CROSS_COMPILING)" == "yes" !if "$(HAVE_BASERUBY)" != "yes" || "$(CROSS_COMPILING)" == "yes"

Просмотреть файл

@ -59,8 +59,8 @@ USE_RUBYGEMS = $(USE_RUBYGEMS)
!if defined(ENABLE_DEBUG_ENV) !if defined(ENABLE_DEBUG_ENV)
ENABLE_DEBUG_ENV = $(ENABLE_DEBUG_ENV) ENABLE_DEBUG_ENV = $(ENABLE_DEBUG_ENV)
!endif !endif
!if defined(MJIT_SUPPORT) !if defined(RJIT_SUPPORT)
MJIT_SUPPORT = $(MJIT_SUPPORT) RJIT_SUPPORT = $(RJIT_SUPPORT)
!endif !endif
# TOOLS # TOOLS

Просмотреть файл

@ -1355,7 +1355,7 @@ is_batch(const char *cmd)
HANDLE HANDLE
rb_w32_start_process(const char *abspath, char *const *argv, int out_fd) rb_w32_start_process(const char *abspath, char *const *argv, int out_fd)
{ {
/* NOTE: This function is used by MJIT worker, so it can be used parallelly with /* NOTE: This function is used by RJIT worker, so it can be used parallelly with
Ruby's main thread. So functions touching things shared with main thread can't Ruby's main thread. So functions touching things shared with main thread can't
be used, like `ALLOCV` that may trigger GC or `FindFreeChildSlot` that finds be used, like `ALLOCV` that may trigger GC or `FindFreeChildSlot` that finds
a slot from shared memory without atomic locks. */ a slot from shared memory without atomic locks. */
@ -2222,7 +2222,7 @@ rb_w32_wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen, long *plen)
WCHAR * WCHAR *
rb_w32_mbstr_to_wstr(UINT cp, const char *str, int clen, long *plen) rb_w32_mbstr_to_wstr(UINT cp, const char *str, int clen, long *plen)
{ {
/* This is used by MJIT worker. Do not trigger GC or call Ruby method here. */ /* This is used by RJIT worker. Do not trigger GC or call Ruby method here. */
WCHAR *ptr; WCHAR *ptr;
int len = MultiByteToWideChar(cp, 0, str, clen, NULL, 0); int len = MultiByteToWideChar(cp, 0, str, clen, NULL, 0);
if (!(ptr = malloc(sizeof(WCHAR) * len))) return 0; if (!(ptr = malloc(sizeof(WCHAR) * len))) return 0;