зеркало из https://github.com/github/ruby.git
s/MJIT/RJIT/
This commit is contained in:
Родитель
eaccdc1941
Коммит
2e875549a9
|
@ -197,7 +197,7 @@ jobs:
|
|||
# - { name: VM_DEBUG_BP_CHECK, env: { cppflags: '-DVM_DEBUG_BP_CHECK' } }
|
||||
# - { name: VM_DEBUG_VERIFY_METHOD_CACHE, env: { cppflags: '-DVM_DEBUG_VERIFY_METHOD_CACHE' } }
|
||||
|
||||
- { name: MJIT_FORCE_ENABLE, env: { cppflags: '-DMJIT_FORCE_ENABLE' } }
|
||||
- { name: RJIT_FORCE_ENABLE, env: { cppflags: '-DRJIT_FORCE_ENABLE' } }
|
||||
- { name: YJIT_FORCE_ENABLE, env: { cppflags: '-DYJIT_FORCE_ENABLE' } }
|
||||
|
||||
name: ${{ matrix.entry.name }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: MJIT bindgen
|
||||
name: RJIT bindgen
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: MJIT
|
||||
name: RJIT
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
|
@ -112,7 +112,7 @@ jobs:
|
|||
payload: |
|
||||
{
|
||||
"ci": "GitHub Actions",
|
||||
"env": "MJIT / ${{ matrix.run_opts }}",
|
||||
"env": "RJIT / ${{ matrix.run_opts }}",
|
||||
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
|
||||
"commit": "${{ github.sha }}",
|
||||
"branch": "${{ github.ref_name }}"
|
||||
|
|
|
@ -238,7 +238,7 @@ lcov*.info
|
|||
# /win32/
|
||||
/win32/*.ico
|
||||
|
||||
# MJIT
|
||||
# RJIT
|
||||
/include/ruby-*/*/rb_mjit_min_header-*.h
|
||||
/lib/ruby_vm/mjit/instruction.rb
|
||||
/lib/ruby_vm/rjit/instruction.rb
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
|
||||
[![Actions Status: MJIT](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MJIT")
|
||||
[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
|
||||
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
|
||||
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
|
||||
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
|
||||
[![Actions Status: MJIT](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MJIT")
|
||||
[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
|
||||
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
|
||||
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
|
||||
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
|
||||
|
|
|
@ -669,7 +669,7 @@ end
|
|||
|
||||
def assert_finish(timeout_seconds, testsrc, message = '')
|
||||
add_assertion testsrc, -> as do
|
||||
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
|
||||
if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait
|
||||
timeout_seconds *= 3
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ ms = "a".."k"
|
|||
o.send(meth)
|
||||
end
|
||||
end
|
||||
}, '[ruby-dev:39453]' unless ENV.fetch('RUN_OPTS', '').include?('mjit') # speed up MJIT CI
|
||||
}, '[ruby-dev:39453]' unless ENV.fetch('RUN_OPTS', '').include?('mjit') # speed up RJIT CI
|
||||
|
||||
assert_normal_exit %q{
|
||||
a = []
|
||||
|
|
|
@ -2244,7 +2244,7 @@ assert_equal '[[:c_return, :String, :string_alias, "events_to_str"]]', %q{
|
|||
events.compiled(events)
|
||||
|
||||
events
|
||||
} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
|
||||
} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods
|
||||
|
||||
# test enabling a TracePoint that targets a particular line in a C method call
|
||||
assert_equal '[true]', %q{
|
||||
|
@ -2326,7 +2326,7 @@ assert_equal '[[:c_call, :itself]]', %q{
|
|||
tp.enable { shouldnt_compile }
|
||||
|
||||
events
|
||||
} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
|
||||
} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods
|
||||
|
||||
# test enabling c_return tracing before compiling
|
||||
assert_equal '[[:c_return, :itself, main]]', %q{
|
||||
|
@ -2341,7 +2341,7 @@ assert_equal '[[:c_return, :itself, main]]', %q{
|
|||
tp.enable { shouldnt_compile }
|
||||
|
||||
events
|
||||
} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
|
||||
} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods
|
||||
|
||||
# test c_call invalidation
|
||||
assert_equal '[[:c_call, :itself]]', %q{
|
||||
|
|
|
@ -360,7 +360,7 @@ ruby.imp: $(COMMONOBJS)
|
|||
$(NM) -Pgp $(COMMONOBJS) | \
|
||||
awk 'BEGIN{print "#!"}; $$2~/^[A-TV-Z]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \
|
||||
($(CHDIR) $(srcdir) && \
|
||||
exec sed -n '/^MJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
|
||||
exec sed -n '/^RJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
|
||||
} | \
|
||||
sort -u -o $@
|
||||
|
||||
|
|
44
configure.ac
44
configure.ac
|
@ -405,19 +405,19 @@ AC_SUBST(OUTFLAG)
|
|||
AC_SUBST(COUTFLAG)
|
||||
AC_SUBST(CSRCFLAG)
|
||||
|
||||
: ${MJIT_CC=$CC}
|
||||
: ${RJIT_CC=$CC}
|
||||
AS_IF([test "x$cross_compiling" = xno], [
|
||||
AC_PATH_PROG([MJIT_CC], ${MJIT_CC})
|
||||
AC_PATH_PROG([RJIT_CC], ${RJIT_CC})
|
||||
|
||||
# if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache)
|
||||
AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null &&
|
||||
echo $MJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
|
||||
PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` MJIT_CC=`which $CC`])
|
||||
echo $RJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
|
||||
PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` RJIT_CC=`which $CC`])
|
||||
|
||||
AS_CASE([$target_os],
|
||||
[*mingw*], [command -v cygpath > /dev/null && MJIT_CC=`cygpath -ma $MJIT_CC`])
|
||||
[*mingw*], [command -v cygpath > /dev/null && RJIT_CC=`cygpath -ma $RJIT_CC`])
|
||||
shift 2
|
||||
MJIT_CC="$MJIT_CC${1+ }$*"
|
||||
RJIT_CC="$RJIT_CC${1+ }$*"
|
||||
])
|
||||
|
||||
AS_CASE(["$build_os"],
|
||||
|
@ -1236,7 +1236,7 @@ main()
|
|||
AS_CASE(["$target_cpu"], [powerpc64*], [
|
||||
ac_cv_func___builtin_setjmp=no
|
||||
])
|
||||
# With gcc-8's -fcf-protection, MJIT's __builtin_longjmp fails.
|
||||
# With gcc-8's -fcf-protection, RJIT's __builtin_longjmp fails.
|
||||
AS_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no])
|
||||
AS_IF([test "$cf_protection" = yes], [
|
||||
ac_cv_func___builtin_setjmp=no
|
||||
|
@ -2927,14 +2927,14 @@ LIBEXT=a
|
|||
|
||||
AC_SUBST(DLDFLAGS)dnl
|
||||
AC_SUBST(ARCH_FLAG)dnl
|
||||
AC_SUBST(MJIT_CC)dnl
|
||||
AC_SUBST(RJIT_CC)dnl
|
||||
AS_CASE(["$GCC:$target_os"],
|
||||
[yes:aix*], [mjit_std_cflag="-std=gnu99"],
|
||||
[mjit_std_cflag=])
|
||||
AC_SUBST(MJIT_CFLAGS, [${MJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
|
||||
AC_SUBST(MJIT_OPTFLAGS, [${MJIT_OPTFLAGS-'$(optflags)'}])dnl
|
||||
AC_SUBST(MJIT_DEBUGFLAGS, [${MJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
|
||||
AC_SUBST(MJIT_LDSHARED)dnl
|
||||
AC_SUBST(RJIT_CFLAGS, [${RJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
|
||||
AC_SUBST(RJIT_OPTFLAGS, [${RJIT_OPTFLAGS-'$(optflags)'}])dnl
|
||||
AC_SUBST(RJIT_DEBUGFLAGS, [${RJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
|
||||
AC_SUBST(RJIT_LDSHARED)dnl
|
||||
|
||||
AC_SUBST(STATIC)dnl
|
||||
AC_SUBST(CCDLFLAGS)dnl
|
||||
|
@ -3727,13 +3727,13 @@ AC_SUBST(INSTALLDOC)
|
|||
|
||||
AC_ARG_ENABLE(jit-support,
|
||||
AS_HELP_STRING([--disable-jit-support], [disable JIT features]),
|
||||
[MJIT_SUPPORT=$enableval],
|
||||
[RJIT_SUPPORT=$enableval],
|
||||
[AS_CASE(["$target_os"],
|
||||
[wasi | mingw* | solaris*], [MJIT_SUPPORT=no],
|
||||
[MJIT_SUPPORT=yes]
|
||||
[wasi | mingw* | solaris*], [RJIT_SUPPORT=no],
|
||||
[RJIT_SUPPORT=yes]
|
||||
)])
|
||||
|
||||
AC_SUBST(MJIT_SUPPORT)
|
||||
AC_SUBST(RJIT_SUPPORT)
|
||||
|
||||
AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix
|
||||
|
||||
|
@ -3835,15 +3835,15 @@ AS_CASE(["${YJIT_SUPPORT}"],
|
|||
AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT])
|
||||
])
|
||||
AC_DEFINE(USE_YJIT, 1)
|
||||
AC_DEFINE(USE_MJIT, 1)
|
||||
AC_DEFINE(USE_RJIT, 1)
|
||||
], [
|
||||
AC_DEFINE(USE_YJIT, 0)
|
||||
AC_DEFINE(USE_MJIT, 0)
|
||||
AC_DEFINE(USE_RJIT, 0)
|
||||
])
|
||||
|
||||
# If YJIT links capstone, libcapstone stops working on the C side.
|
||||
# capstone should be linked for MJIT only when YJIT doesn't.
|
||||
AS_IF([test x"$MJIT_SUPPORT" = "xyes" -a -z "$CARGO_BUILD_ARGS" ], [
|
||||
# capstone should be linked for RJIT only when YJIT doesn't.
|
||||
AS_IF([test x"$RJIT_SUPPORT" = "xyes" -a -z "$CARGO_BUILD_ARGS" ], [
|
||||
AC_CHECK_LIB([capstone], [cs_disasm])
|
||||
])
|
||||
|
||||
|
@ -4054,7 +4054,7 @@ AS_IF([test "${universal_binary-no}" = yes ], [
|
|||
[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no]))
|
||||
])
|
||||
|
||||
: ${MJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(MJIT_CC)|g']`}
|
||||
: ${RJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(RJIT_CC)|g']`}
|
||||
|
||||
MAINLIBS="$LIBS"
|
||||
LIBS=$ORIG_LIBS
|
||||
|
@ -4541,7 +4541,7 @@ config_summary "debugflags" "$debugflags"
|
|||
config_summary "warnflags" "$warnflags"
|
||||
config_summary "strip command" "$STRIP"
|
||||
config_summary "install doc" "$DOCTARGETS"
|
||||
config_summary "MJIT support" "$MJIT_SUPPORT"
|
||||
config_summary "RJIT support" "$RJIT_SUPPORT"
|
||||
config_summary "YJIT support" "$YJIT_SUPPORT"
|
||||
config_summary "man page type" "$MANTYPE"
|
||||
config_summary "search path" "$search_path"
|
||||
|
|
|
@ -13,7 +13,7 @@ endif
|
|||
|
||||
ifneq ($(filter darwin%,$(target_os)),)
|
||||
# Remove debug option not to generate thousands of .dSYM
|
||||
MJIT_DEBUGFLAGS := $(filter-out -g%,$(MJIT_DEBUGFLAGS))
|
||||
RJIT_DEBUGFLAGS := $(filter-out -g%,$(RJIT_DEBUGFLAGS))
|
||||
|
||||
INSTRUBY_ENV += SDKROOT=
|
||||
endif
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -11,24 +11,24 @@ The following platforms are either tested on CI or assumed to work.
|
|||
|
||||
### Not supported
|
||||
|
||||
The MJIT support for the following platforms is no longer maintained.
|
||||
The RJIT support for the following platforms is no longer maintained.
|
||||
|
||||
* OS: Windows (mswin, MinGW), Solaris
|
||||
* Arch: SPARC, s390x
|
||||
|
||||
## Developing MJIT
|
||||
## Developing RJIT
|
||||
|
||||
### Bindgen
|
||||
|
||||
If you see an "MJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.
|
||||
If you see an "RJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.
|
||||
|
||||
For doing the same thing locally, run `make mjit-bindgen` after installing libclang.
|
||||
macOS seems to have libclang by default. On Ubuntu, you can install it with `apt install libclang1`.
|
||||
|
||||
### Always run make install
|
||||
|
||||
Always run `make install` before running MJIT. It could easily cause a SEGV if you don't.
|
||||
MJIT looks for the installed header for security reasons.
|
||||
Always run `make install` before running RJIT. It could easily cause a SEGV if you don't.
|
||||
RJIT looks for the installed header for security reasons.
|
||||
|
||||
### --mjit-debug vs --mjit-debug=-ggdb3
|
||||
|
||||
|
@ -36,4 +36,4 @@ MJIT looks for the installed header for security reasons.
|
|||
which is useful for profiling benchmarks.
|
||||
|
||||
`--mjit-debug` alone, on the other hand, disables `-O3` and adds debug flags.
|
||||
If you're debugging MJIT, what you need to use is not `--mjit-debug=-ggdb3` but `--mjit-debug`.
|
||||
If you're debugging RJIT, what you need to use is not `--mjit-debug=-ggdb3` but `--mjit-debug`.
|
||||
|
|
2
inits.c
2
inits.c
|
@ -105,7 +105,7 @@ rb_call_builtin_inits(void)
|
|||
BUILTIN(yjit);
|
||||
BUILTIN(nilclass);
|
||||
BUILTIN(marshal);
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
BUILTIN(mjit_c);
|
||||
BUILTIN(mjit);
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@ typedef struct ruby_cmdline_options {
|
|||
ruby_features_t features;
|
||||
ruby_features_t warn;
|
||||
unsigned int dump;
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
struct mjit_options mjit;
|
||||
#endif
|
||||
|
||||
|
|
6
iseq.c
6
iseq.c
|
@ -164,7 +164,7 @@ rb_iseq_free(const rb_iseq_t *iseq)
|
|||
if (iseq && ISEQ_BODY(iseq)) {
|
||||
iseq_clear_ic_references(iseq);
|
||||
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
|
||||
mjit_free_iseq(iseq); /* Notify MJIT */
|
||||
mjit_free_iseq(iseq); /* Notify RJIT */
|
||||
#if USE_YJIT
|
||||
rb_yjit_iseq_free(body->yjit_payload);
|
||||
#endif
|
||||
|
@ -356,7 +356,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
|
|||
}
|
||||
|
||||
if (reference_updating) {
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
rb_mjit_iseq_update_references(body);
|
||||
#endif
|
||||
#if USE_YJIT
|
||||
|
@ -364,7 +364,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
|
|||
#endif
|
||||
}
|
||||
else {
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
rb_mjit_iseq_mark(body->mjit_blocks);
|
||||
#endif
|
||||
#if USE_YJIT
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
# 8-bit memory access
|
||||
class BytePtr < Data.define(:reg, :disp); end
|
||||
|
||||
|
@ -905,7 +905,7 @@ module RubyVM::MJIT
|
|||
Label.new(id: @label_id += 1, name:)
|
||||
end
|
||||
|
||||
# @param [RubyVM::MJIT::Assembler::Label] label
|
||||
# @param [RubyVM::RJIT::Assembler::Label] label
|
||||
def write_label(label)
|
||||
@labels[label] = @bytes.size
|
||||
end
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class RubyVM::MJIT::Block < Struct.new(
|
||||
class RubyVM::RJIT::Block < Struct.new(
|
||||
:iseq, # @param ``
|
||||
:pc, # @param [Integer] Starting PC
|
||||
:ctx, # @param [RubyVM::MJIT::Context] **Starting** Context (TODO: freeze?)
|
||||
:ctx, # @param [RubyVM::RJIT::Context] **Starting** Context (TODO: freeze?)
|
||||
:start_addr, # @param [Integer] Starting address of this block's JIT code
|
||||
:entry_exit, # @param [Integer] Address of entry exit (optional)
|
||||
:incoming, # @param [Array<RubyVM::MJIT::BranchStub>] Incoming branches
|
||||
:incoming, # @param [Array<RubyVM::RJIT::BranchStub>] Incoming branches
|
||||
:invalidated, # @param [TrueClass,FalseClass] true if already invalidated
|
||||
)
|
||||
def initialize(incoming: [], invalidated: false, **) = super
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
# Branch shapes
|
||||
Next0 = :Next0 # target0 is a fallthrough
|
||||
Next1 = :Next1 # target1 is a fallthrough
|
||||
Default = :Default # neither targets is a fallthrough
|
||||
|
||||
class BranchStub < Struct.new(
|
||||
:iseq, # @param [RubyVM::MJIT::CPointer::Struct_rb_iseq_struct] Branch target ISEQ
|
||||
:iseq, # @param [RubyVM::RJIT::CPointer::Struct_rb_iseq_struct] Branch target ISEQ
|
||||
:shape, # @param [Symbol] Next0, Next1, or Default
|
||||
:target0, # @param [RubyVM::MJIT::BranchTarget] First branch target
|
||||
:target1, # @param [RubyVM::MJIT::BranchTarget,NilClass] Second branch target (optional)
|
||||
:target0, # @param [RubyVM::RJIT::BranchTarget] First branch target
|
||||
:target1, # @param [RubyVM::RJIT::BranchTarget,NilClass] Second branch target (optional)
|
||||
:compile, # @param [Proc] A callback to (re-)generate this branch stub
|
||||
:start_addr, # @param [Integer] Stub source start address to be re-generated
|
||||
:end_addr, # @param [Integer] Stub source end address to be re-generated
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
# Every class under this namespace is a pointer. Even if the type is
|
||||
# immediate, it shouldn't be dereferenced until `*` is called.
|
||||
module CPointer
|
||||
|
@ -7,7 +7,7 @@ module RubyVM::MJIT
|
|||
class Struct
|
||||
# @param name [String]
|
||||
# @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)
|
||||
@addr = addr
|
||||
@sizeof = sizeof
|
||||
|
@ -48,7 +48,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# @param size [Integer]
|
||||
# @param members [Hash{ Symbol => [Integer, RubyVM::MJIT::CType::*] }]
|
||||
# @param members [Hash{ Symbol => [Integer, RubyVM::RJIT::CType::*] }]
|
||||
def self.define(size, members)
|
||||
Class.new(self) do
|
||||
# Return the size of this type
|
||||
|
@ -103,7 +103,7 @@ module RubyVM::MJIT
|
|||
class Union
|
||||
# @param _name [String] To be used when it starts defining a union pointer class
|
||||
# @param sizeof [Integer]
|
||||
# @param members [Hash{ Symbol => RubyVM::MJIT::CType::* }]
|
||||
# @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
|
||||
def initialize(addr, sizeof, members)
|
||||
@addr = addr
|
||||
@sizeof = sizeof
|
||||
|
@ -128,7 +128,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# @param sizeof [Integer]
|
||||
# @param members [Hash{ Symbol => RubyVM::MJIT::CType::* }]
|
||||
# @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
|
||||
def self.define(sizeof, members)
|
||||
Class.new(self) do
|
||||
# Return the size of this type
|
||||
|
@ -242,7 +242,7 @@ module RubyVM::MJIT
|
|||
attr_reader :type
|
||||
|
||||
# @param addr [Integer]
|
||||
# @param type [Class] RubyVM::MJIT::CType::*
|
||||
# @param type [Class] RubyVM::RJIT::CType::*
|
||||
def initialize(addr, type)
|
||||
@addr = addr
|
||||
@type = type
|
||||
|
@ -267,7 +267,7 @@ module RubyVM::MJIT
|
|||
|
||||
# Array set
|
||||
# @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)
|
||||
Fiddle::Pointer.new(@addr + index * Fiddle::SIZEOF_VOIDP)[0, Fiddle::SIZEOF_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
|
||||
# @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|
|
||||
value = value.to_i
|
||||
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_relative 'c_pointer'
|
||||
|
||||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
module CType
|
||||
module Struct
|
||||
# @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)
|
||||
name = members.keys.join('_') if name.empty?
|
||||
CPointer.with_class_name('Struct', name) do
|
||||
|
@ -17,7 +17,7 @@ module RubyVM::MJIT
|
|||
|
||||
module Union
|
||||
# @param name [String]
|
||||
# @param members [Hash{ Symbol => RubyVM::MJIT::CType::* }]
|
||||
# @param members [Hash{ Symbol => RubyVM::RJIT::CType::* }]
|
||||
def self.new(name, sizeof, **members)
|
||||
name = members.keys.join('_') if name.empty?
|
||||
CPointer.with_class_name('Union', name) do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
class CodeBlock
|
||||
# @param mem_block [Integer] JIT buffer address
|
||||
# @param mem_size [Integer] JIT buffer size
|
||||
|
@ -11,7 +11,7 @@ module RubyVM::MJIT
|
|||
@outlined = outlined
|
||||
end
|
||||
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def write(asm)
|
||||
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/jit_state'
|
||||
|
||||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
# Compilation status
|
||||
KeepCompiling = :KeepCompiling
|
||||
CantCompile = :CantCompile
|
||||
|
@ -55,8 +55,8 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# Compile an ISEQ from its entry point.
|
||||
# @param iseq `RubyVM::MJIT::CPointer::Struct_rb_iseq_t`
|
||||
# @param cfp `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t`
|
||||
# @param iseq `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
|
||||
# @param cfp `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t`
|
||||
def compile(iseq, cfp)
|
||||
# TODO: Support has_opt
|
||||
return if iseq.body.param.flags.has_opt
|
||||
|
@ -73,8 +73,8 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# Compile a branch stub.
|
||||
# @param branch_stub [RubyVM::MJIT::BranchStub]
|
||||
# @param cfp `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t`
|
||||
# @param branch_stub [RubyVM::RJIT::BranchStub]
|
||||
# @param cfp `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t`
|
||||
# @param target0_p [TrueClass,FalseClass]
|
||||
# @return [Integer] The starting address of the compiled branch stub
|
||||
def branch_stub_hit(branch_stub, cfp, target0_p)
|
||||
|
@ -127,14 +127,14 @@ module RubyVM::MJIT
|
|||
exit 1
|
||||
end
|
||||
|
||||
# @param iseq `RubyVM::MJIT::CPointer::Struct_rb_iseq_t`
|
||||
# @param iseq `RubyVM::RJIT::CPointer::Struct_rb_iseq_t`
|
||||
# @param pc [Integer]
|
||||
def invalidate_blocks(iseq, pc)
|
||||
list_blocks(iseq, pc).each do |block|
|
||||
invalidate_block(block)
|
||||
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
|
||||
iseq.body.jit_func = 0
|
||||
iseq.body.total_calls = 0
|
||||
|
@ -191,9 +191,9 @@ module RubyVM::MJIT
|
|||
# Callee-saved: rbx, rsp, rbp, r12, r13, r14, r15
|
||||
# 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)
|
||||
asm.comment('MJIT entry point')
|
||||
asm.comment('RJIT entry point')
|
||||
|
||||
# Save callee-saved registers used by JITed code
|
||||
asm.push(CFP)
|
||||
|
@ -212,7 +212,7 @@ module RubyVM::MJIT
|
|||
asm.mov([CFP, C.rb_control_frame_t.offsetof(:jit_return)], :rax)
|
||||
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)
|
||||
# Mark the block start address and prepare an exit code storage
|
||||
block = Block.new(iseq: jit.iseq, pc:, ctx: ctx.dup)
|
||||
|
@ -276,18 +276,18 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# @param [Integer] pc
|
||||
# @param [RubyVM::MJIT::Context] ctx
|
||||
# @return [RubyVM::MJIT::Block,NilClass]
|
||||
# @param [RubyVM::RJIT::Context] ctx
|
||||
# @return [RubyVM::RJIT::Block,NilClass]
|
||||
def find_block(iseq, pc, ctx)
|
||||
mjit_blocks(iseq)[pc][ctx]
|
||||
end
|
||||
|
||||
# @param [RubyVM::MJIT::Block] block
|
||||
# @param [RubyVM::RJIT::Block] block
|
||||
def set_block(iseq, block)
|
||||
mjit_blocks(iseq)[block.pc][block.ctx] = block
|
||||
end
|
||||
|
||||
# @param [RubyVM::MJIT::Block] block
|
||||
# @param [RubyVM::RJIT::Block] block
|
||||
def remove_block(iseq, block)
|
||||
mjit_blocks(iseq)[block.pc].delete(block.ctx)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
class Context < Struct.new(
|
||||
:stack_size, # @param [Integer] The number of values on the stack
|
||||
: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
|
||||
# Used for invalidating a block on entry.
|
||||
# @param pc [Integer]
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def compile_entry_exit(pc, ctx, asm, cause:)
|
||||
# Increment per-insn exit counter
|
||||
incr_insn_exit(pc, asm)
|
||||
|
@ -21,7 +21,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# 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)
|
||||
asm.comment('default cfp->jit_return')
|
||||
|
||||
|
@ -35,7 +35,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# Fire cfunc events on invalidation by TracePoint
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def compile_full_cfunc_return(asm)
|
||||
# This chunk of code expects REG_EC to be filled properly and
|
||||
# RAX to contain the return value of the C method.
|
||||
|
@ -56,9 +56,9 @@ module RubyVM::MJIT
|
|||
asm.ret
|
||||
end
|
||||
|
||||
# @param jit [RubyVM::MJIT::JITState]
|
||||
# @param ctx [RubyVM::MJIT::Context]
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param jit [RubyVM::RJIT::JITState]
|
||||
# @param ctx [RubyVM::RJIT::Context]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def compile_side_exit(pc, ctx, asm)
|
||||
# Increment per-insn exit counter
|
||||
incr_insn_exit(pc, asm)
|
||||
|
@ -76,9 +76,9 @@ module RubyVM::MJIT
|
|||
asm.ret
|
||||
end
|
||||
|
||||
# @param ctx [RubyVM::MJIT::Context]
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param branch_stub [RubyVM::MJIT::BranchStub]
|
||||
# @param ctx [RubyVM::RJIT::Context]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
# @param branch_stub [RubyVM::RJIT::BranchStub]
|
||||
# @param target0_p [TrueClass,FalseClass]
|
||||
def compile_branch_stub(ctx, asm, branch_stub, target0_p)
|
||||
# Call rb_mjit_branch_stub_hit
|
||||
|
@ -102,7 +102,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
|
||||
# @param pc [Integer]
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def incr_insn_exit(pc, asm)
|
||||
if C.mjit_opts.stats
|
||||
insn = Compiler.decode_insn(C.VALUE.new(pc).*)
|
||||
|
@ -112,9 +112,9 @@ module RubyVM::MJIT
|
|||
end
|
||||
end
|
||||
|
||||
# @param jit [RubyVM::MJIT::JITState]
|
||||
# @param ctx [RubyVM::MJIT::Context]
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param jit [RubyVM::RJIT::JITState]
|
||||
# @param ctx [RubyVM::RJIT::Context]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def save_pc_and_sp(pc, ctx, asm, reset_sp_offset: true)
|
||||
# Update pc (TODO: manage PC offset?)
|
||||
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
|
||||
def self.on_bop_redefined(_redefined_flag, _bop)
|
||||
# C.mjit_cancel_all("BOP is redefined")
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,13 +1,13 @@
|
|||
require 'set'
|
||||
|
||||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
class Invariants
|
||||
class << self
|
||||
# Called by RubyVM::MJIT::Compiler to lazily initialize this
|
||||
# Called by RubyVM::RJIT::Compiler to lazily initialize this
|
||||
# @param cb [CodeBlock]
|
||||
# @param ocb [CodeBlock]
|
||||
# @param compiler [RubyVM::MJIT::Compiler]
|
||||
# @param exit_compiler [RubyVM::MJIT::ExitCompiler]
|
||||
# @param compiler [RubyVM::RJIT::Compiler]
|
||||
# @param exit_compiler [RubyVM::RJIT::ExitCompiler]
|
||||
def initialize(cb, ocb, compiler, exit_compiler)
|
||||
@cb = cb
|
||||
@ocb = ocb
|
||||
|
@ -21,7 +21,7 @@ module RubyVM::MJIT
|
|||
# freeze # workaround a binding.irb issue. TODO: resurrect this
|
||||
end
|
||||
|
||||
# @param jit [RubyVM::MJIT::JITState]
|
||||
# @param jit [RubyVM::RJIT::JITState]
|
||||
# @param klass [Integer]
|
||||
# @param op [Integer]
|
||||
def assume_bop_not_redefined(jit, klass, op)
|
||||
|
@ -32,7 +32,7 @@ module RubyVM::MJIT
|
|||
true
|
||||
end
|
||||
|
||||
# @param jit [RubyVM::MJIT::JITState]
|
||||
# @param jit [RubyVM::RJIT::JITState]
|
||||
def assume_method_lookup_stable(jit, cme)
|
||||
ensure_block_entry_exit(jit, cause: 'assume_method_lookup_stable')
|
||||
@cme_blocks[cme.to_i] << jit.block
|
||||
|
@ -45,7 +45,7 @@ module RubyVM::MJIT
|
|||
end
|
||||
end
|
||||
|
||||
# @param asm [RubyVM::MJIT::Assembler]
|
||||
# @param asm [RubyVM::RJIT::Assembler]
|
||||
def record_global_inval_patch(asm, target)
|
||||
asm.pos_marker do |address|
|
||||
if @patches.key?(address)
|
||||
|
@ -103,8 +103,8 @@ module RubyVM::MJIT
|
|||
invalidate_all
|
||||
end
|
||||
|
||||
# @param jit [RubyVM::MJIT::JITState]
|
||||
# @param block [RubyVM::MJIT::Block]
|
||||
# @param jit [RubyVM::RJIT::JITState]
|
||||
# @param block [RubyVM::RJIT::Block]
|
||||
def ensure_block_entry_exit(jit, cause:)
|
||||
block = jit.block
|
||||
if block.entry_exit.nil?
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
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
|
||||
:cfp, # @param `RubyVM::MJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before MJIT is called)
|
||||
:block, # @param [RubyVM::MJIT::Block]
|
||||
:cfp, # @param `RubyVM::RJIT::CPointer::Struct_rb_control_frame_t` The JIT source CFP (before RJIT is called)
|
||||
:block, # @param [RubyVM::RJIT::Block]
|
||||
:side_exits, # @param [Hash{ Integer => Integer }] { PC => address }
|
||||
:record_boundary_patch_point, # @param [TrueClass,FalseClass]
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
module RubyVM::MJIT
|
||||
module RubyVM::RJIT
|
||||
def self.runtime_stats
|
||||
stats = {}
|
||||
|
||||
|
@ -32,7 +32,7 @@ module RubyVM::MJIT
|
|||
|
||||
def print_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: 'invokesuper_', prompt: 'invokesuper exit reasons')
|
||||
|
|
16
process.c
16
process.c
|
@ -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_thread_sleep_interruptible(void);
|
||||
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
static struct waitpid_state mjit_waitpid_state;
|
||||
|
||||
// variables shared with thread.c
|
||||
|
@ -1095,7 +1095,7 @@ waitpid_signal(struct waitpid_state *w)
|
|||
rb_threadptr_interrupt(rb_ec_thread_ptr(w->ec));
|
||||
return TRUE;
|
||||
}
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
else if (w == &mjit_waitpid_state && w->ret) { /* mjit_add_waiting_pid */
|
||||
mjit_waitpid_finished = true;
|
||||
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;
|
||||
}
|
||||
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
/*
|
||||
* 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
|
||||
// This is used to create MJIT's child Ruby process
|
||||
#if USE_RJIT
|
||||
// This is used to create RJIT's child Ruby process
|
||||
pid_t
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
rb_pid_t
|
||||
|
@ -4297,7 +4297,7 @@ rb_fork_ruby2(struct rb_process_status *status)
|
|||
|
||||
while (1) {
|
||||
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);
|
||||
before_fork_ruby();
|
||||
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);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
if (!eargp->waitpid_state && mjit_enabled) {
|
||||
|
|
6
ractor.c
6
ractor.c
|
@ -39,7 +39,7 @@ static void
|
|||
ASSERT_ractor_unlocking(rb_ractor_t *r)
|
||||
{
|
||||
#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())) {
|
||||
rb_bug("recursive ractor locking");
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ static void
|
|||
ASSERT_ractor_locking(rb_ractor_t *r)
|
||||
{
|
||||
#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())) {
|
||||
rp(r->sync.locked_by);
|
||||
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);
|
||||
|
||||
#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());
|
||||
}
|
||||
#endif
|
||||
|
|
134
rjit.c
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
|
||||
void rb_mjit(void) {}
|
||||
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
|
||||
#include "constant.h"
|
||||
#include "id_table.h"
|
||||
|
@ -59,12 +59,12 @@ void rb_mjit(void) {}
|
|||
|
||||
#include "ruby/util.h"
|
||||
|
||||
// A copy of MJIT portion of MRI options since MJIT initialization. We
|
||||
// need them as MJIT threads still can work when the most MRI data were
|
||||
// A copy of RJIT portion of MRI options since RJIT initialization. We
|
||||
// need them as RJIT threads still can work when the most MRI data were
|
||||
// freed.
|
||||
struct mjit_options mjit_opts;
|
||||
|
||||
// true if MJIT is enabled.
|
||||
// true if RJIT is enabled.
|
||||
bool mjit_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`
|
||||
|
@ -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.
|
||||
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.
|
||||
PRINTF_ARGS(static void, 2, 3)
|
||||
verbose(int level, const char *format, ...)
|
||||
|
@ -126,18 +126,18 @@ mjit_notify_waitpid(int exit_code)
|
|||
// TODO: remove this function
|
||||
}
|
||||
|
||||
// RubyVM::MJIT
|
||||
static VALUE rb_mMJIT = 0;
|
||||
// RubyVM::MJIT::C
|
||||
static VALUE rb_mMJITC = 0;
|
||||
// RubyVM::MJIT::Compiler
|
||||
static VALUE rb_MJITCompiler = 0;
|
||||
// RubyVM::MJIT::CPointer::Struct_rb_iseq_t
|
||||
static VALUE rb_cMJITIseqPtr = 0;
|
||||
// RubyVM::MJIT::CPointer::Struct_rb_control_frame_t
|
||||
static VALUE rb_cMJITCfpPtr = 0;
|
||||
// RubyVM::MJIT::Hooks
|
||||
static VALUE rb_mMJITHooks = 0;
|
||||
// RubyVM::RJIT
|
||||
static VALUE rb_mRJIT = 0;
|
||||
// RubyVM::RJIT::C
|
||||
static VALUE rb_mRJITC = 0;
|
||||
// RubyVM::RJIT::Compiler
|
||||
static VALUE rb_RJITCompiler = 0;
|
||||
// RubyVM::RJIT::CPointer::Struct_rb_iseq_t
|
||||
static VALUE rb_cRJITIseqPtr = 0;
|
||||
// RubyVM::RJIT::CPointer::Struct_rb_control_frame_t
|
||||
static VALUE rb_cRJITCfpPtr = 0;
|
||||
// RubyVM::RJIT::Hooks
|
||||
static VALUE rb_mRJITHooks = 0;
|
||||
|
||||
void
|
||||
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 {
|
||||
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-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-stats", "", "Enable collecting MJIT statistics"),
|
||||
M("--mjit-stats", "", "Enable collecting RJIT statistics"),
|
||||
{0}
|
||||
};
|
||||
#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_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;
|
||||
|
||||
#if MJIT_STATS
|
||||
#if RJIT_STATS
|
||||
|
||||
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_disable(void);
|
||||
|
||||
#define WITH_MJIT_ISOLATED(stmt) do { \
|
||||
#define WITH_RJIT_ISOLATED(stmt) do { \
|
||||
VALUE was_disabled = rb_gc_disable(); \
|
||||
rb_hook_list_t *global_hooks = rb_ec_ractor_hooks(GET_EC()); \
|
||||
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
|
||||
mjit_cme_invalidate(void *data)
|
||||
{
|
||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
||||
WITH_MJIT_ISOLATED({
|
||||
rb_funcall(rb_mMJITHooks, rb_intern("on_cme_invalidate"), 1, SIZET2NUM((size_t)data));
|
||||
if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
|
||||
WITH_RJIT_ISOLATED({
|
||||
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
|
||||
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.
|
||||
rb_workqueue_register(0, mjit_cme_invalidate, (void *)cme);
|
||||
}
|
||||
|
@ -362,12 +362,12 @@ rb_mjit_before_ractor_spawn(void)
|
|||
static void
|
||||
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_barrier();
|
||||
|
||||
WITH_MJIT_ISOLATED({
|
||||
rb_funcall(rb_mMJITHooks, rb_intern("on_constant_state_changed"), 1, SIZET2NUM((size_t)data));
|
||||
WITH_RJIT_ISOLATED({
|
||||
rb_funcall(rb_mRJITHooks, rb_intern("on_constant_state_changed"), 1, SIZET2NUM((size_t)data));
|
||||
});
|
||||
|
||||
RB_VM_LOCK_LEAVE();
|
||||
|
@ -376,7 +376,7 @@ mjit_constant_state_changed(void *data)
|
|||
void
|
||||
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".
|
||||
rb_workqueue_register(0, mjit_constant_state_changed, (void *)id);
|
||||
}
|
||||
|
@ -384,13 +384,13 @@ rb_mjit_constant_state_changed(ID id)
|
|||
void
|
||||
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_barrier();
|
||||
|
||||
WITH_MJIT_ISOLATED({
|
||||
rb_funcall(rb_mMJITHooks, rb_intern("on_constant_ic_update"), 3,
|
||||
WITH_RJIT_ISOLATED({
|
||||
rb_funcall(rb_mRJITHooks, rb_intern("on_constant_ic_update"), 3,
|
||||
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
|
||||
rb_mjit_tracing_invalidate_all(rb_event_flag_t new_iseq_events)
|
||||
{
|
||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
||||
WITH_MJIT_ISOLATED({
|
||||
rb_funcall(rb_mMJITHooks, rb_intern("on_tracing_invalidate_all"), 1, UINT2NUM(new_iseq_events));
|
||||
if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
|
||||
WITH_RJIT_ISOLATED({
|
||||
rb_funcall(rb_mRJITHooks, rb_intern("on_tracing_invalidate_all"), 1, UINT2NUM(new_iseq_events));
|
||||
});
|
||||
}
|
||||
|
||||
static void
|
||||
mjit_iseq_update_references(void *data)
|
||||
{
|
||||
if (!mjit_enabled || !mjit_call_p || !rb_mMJITHooks) return;
|
||||
WITH_MJIT_ISOLATED({
|
||||
rb_funcall(rb_mMJITHooks, rb_intern("on_update_references"), 0);
|
||||
if (!mjit_enabled || !mjit_call_p || !rb_mRJITHooks) return;
|
||||
WITH_RJIT_ISOLATED({
|
||||
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;
|
||||
|
||||
// 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) {
|
||||
rb_gc_mark_movable(mjit_blocks);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ rb_mjit_iseq_mark(VALUE mjit_blocks)
|
|||
VALUE
|
||||
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
|
||||
|
@ -455,10 +455,10 @@ rb_mjit_compile(const rb_iseq_t *iseq)
|
|||
RB_VM_LOCK_ENTER();
|
||||
rb_vm_barrier();
|
||||
|
||||
WITH_MJIT_ISOLATED({
|
||||
VALUE iseq_ptr = rb_funcall(rb_cMJITIseqPtr, 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));
|
||||
rb_funcall(rb_MJITCompiler, rb_intern("compile"), 2, iseq_ptr, cfp_ptr);
|
||||
WITH_RJIT_ISOLATED({
|
||||
VALUE iseq_ptr = rb_funcall(rb_cRJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq));
|
||||
VALUE cfp_ptr = rb_funcall(rb_cRJITCfpPtr, rb_intern("new"), 1, SIZET2NUM((size_t)GET_EC()->cfp));
|
||||
rb_funcall(rb_RJITCompiler, rb_intern("compile"), 2, iseq_ptr, cfp_ptr);
|
||||
});
|
||||
|
||||
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;
|
||||
cfp->sp += sp_offset; // preserve stack values, also using the actual sp_offset to make jit.peek_at_stack work
|
||||
|
||||
WITH_MJIT_ISOLATED({
|
||||
VALUE cfp_ptr = rb_funcall(rb_cMJITCfpPtr, 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));
|
||||
WITH_RJIT_ISOLATED({
|
||||
VALUE cfp_ptr = rb_funcall(rb_cRJITCfpPtr, rb_intern("new"), 1, SIZET2NUM((size_t)cfp));
|
||||
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
|
||||
|
@ -496,10 +496,10 @@ mjit_mark(void)
|
|||
RUBY_MARK_ENTER("mjit");
|
||||
|
||||
// Pin object pointers used in this file
|
||||
rb_gc_mark(rb_MJITCompiler);
|
||||
rb_gc_mark(rb_cMJITIseqPtr);
|
||||
rb_gc_mark(rb_cMJITCfpPtr);
|
||||
rb_gc_mark(rb_mMJITHooks);
|
||||
rb_gc_mark(rb_RJITCompiler);
|
||||
rb_gc_mark(rb_cRJITIseqPtr);
|
||||
rb_gc_mark(rb_cRJITCfpPtr);
|
||||
rb_gc_mark(rb_mRJITHooks);
|
||||
|
||||
RUBY_MARK_LEAVE("mjit");
|
||||
}
|
||||
|
@ -511,22 +511,22 @@ mjit_init(const struct mjit_options *opts)
|
|||
mjit_opts = *opts;
|
||||
|
||||
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.
|
||||
rb_mMJIT = rb_const_get(rb_cRubyVM, rb_intern("MJIT"));
|
||||
if (!rb_const_defined(rb_mMJIT, rb_intern("Compiler"))) {
|
||||
verbose(1, "Disabling MJIT because RubyVM::MJIT::Compiler is not defined");
|
||||
// RJIT doesn't support miniruby, but it might reach here by RJIT_FORCE_ENABLE.
|
||||
rb_mRJIT = rb_const_get(rb_cRubyVM, rb_intern("RJIT"));
|
||||
if (!rb_const_defined(rb_mRJIT, rb_intern("Compiler"))) {
|
||||
verbose(1, "Disabling RJIT because RubyVM::RJIT::Compiler is not defined");
|
||||
mjit_enabled = false;
|
||||
return;
|
||||
}
|
||||
rb_mMJITC = rb_const_get(rb_mMJIT, rb_intern("C"));
|
||||
VALUE rb_cMJITCompiler = rb_const_get(rb_mMJIT, rb_intern("Compiler"));
|
||||
rb_MJITCompiler = rb_funcall(rb_cMJITCompiler, rb_intern("new"), 2,
|
||||
SIZET2NUM((size_t)rb_mjit_mem_block), UINT2NUM(MJIT_CODE_SIZE));
|
||||
rb_cMJITIseqPtr = rb_funcall(rb_mMJITC, rb_intern("rb_iseq_t"), 0);
|
||||
rb_cMJITCfpPtr = rb_funcall(rb_mMJITC, rb_intern("rb_control_frame_t"), 0);
|
||||
rb_mMJITHooks = rb_const_get(rb_mMJIT, rb_intern("Hooks"));
|
||||
rb_mRJITC = rb_const_get(rb_mRJIT, rb_intern("C"));
|
||||
VALUE rb_cRJITCompiler = rb_const_get(rb_mRJIT, rb_intern("Compiler"));
|
||||
rb_RJITCompiler = rb_funcall(rb_cRJITCompiler, rb_intern("new"), 2,
|
||||
SIZET2NUM((size_t)rb_mjit_mem_block), UINT2NUM(RJIT_CODE_SIZE));
|
||||
rb_cRJITIseqPtr = rb_funcall(rb_mRJITC, rb_intern("rb_iseq_t"), 0);
|
||||
rb_cRJITCfpPtr = rb_funcall(rb_mRJITC, rb_intern("rb_control_frame_t"), 0);
|
||||
rb_mRJITHooks = rb_const_get(rb_mRJIT, rb_intern("Hooks"));
|
||||
|
||||
mjit_call_p = true;
|
||||
mjit_stats_p = mjit_opts.stats;
|
||||
|
@ -546,7 +546,7 @@ mjit_finish(bool close_handle_p)
|
|||
// 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
|
||||
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"
|
||||
|
||||
#endif // USE_MJIT
|
||||
#endif // USE_RJIT
|
||||
|
|
42
rjit.h
42
rjit.h
|
@ -1,5 +1,5 @@
|
|||
#ifndef RUBY_MJIT_H
|
||||
#define RUBY_MJIT_H 1
|
||||
#ifndef RUBY_RJIT_H
|
||||
#define RUBY_RJIT_H 1
|
||||
/**********************************************************************
|
||||
|
||||
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 "vm_core.h"
|
||||
|
||||
# if USE_MJIT
|
||||
# if USE_RJIT
|
||||
|
||||
#ifndef MJIT_STATS
|
||||
# define MJIT_STATS RUBY_DEBUG
|
||||
#ifndef RJIT_STATS
|
||||
# define RJIT_STATS RUBY_DEBUG
|
||||
#endif
|
||||
|
||||
#include "ruby.h"
|
||||
#include "vm_core.h"
|
||||
|
||||
// Special address values of a function generated from the
|
||||
// corresponding iseq by MJIT:
|
||||
// corresponding iseq by RJIT:
|
||||
enum rb_mjit_func_state {
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
#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 {
|
||||
// Converted from "jit" feature flag to tell the enablement
|
||||
// information to ruby_show_version().
|
||||
|
@ -46,7 +46,7 @@ struct mjit_options {
|
|||
// include the pre-compiled header, C code file generated for ISEQ,
|
||||
// and the corresponding object file.
|
||||
bool save_temps;
|
||||
// Print MJIT warnings to stderr.
|
||||
// Print RJIT warnings to stderr.
|
||||
bool warnings;
|
||||
// Disable compiler optimization and add debug symbols. It can be
|
||||
// very slow.
|
||||
|
@ -57,17 +57,17 @@ struct mjit_options {
|
|||
bool wait;
|
||||
// Number of calls to trigger JIT compilation. For testing.
|
||||
unsigned int call_threshold;
|
||||
// Collect MJIT statistics
|
||||
// Collect RJIT statistics
|
||||
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.
|
||||
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.
|
||||
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;
|
||||
// [experimental] Call custom RubyVM::MJIT.compile instead of MJIT.
|
||||
// [experimental] Call custom RubyVM::RJIT.compile instead of RJIT.
|
||||
bool custom;
|
||||
// Enable disasm of all JIT code
|
||||
bool dump_disasm;
|
||||
|
@ -131,7 +131,7 @@ VALUE mjit_pause(bool wait_p);
|
|||
VALUE mjit_resume(void);
|
||||
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_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) {}
|
||||
|
||||
# endif // USE_MJIT
|
||||
#endif // RUBY_MJIT_H
|
||||
# endif // USE_RJIT
|
||||
#endif // RUBY_RJIT_H
|
||||
|
|
8
rjit.rb
8
rjit.rb
|
@ -1,5 +1,5 @@
|
|||
module RubyVM::MJIT
|
||||
# Return true if MJIT is enabled.
|
||||
module RubyVM::RJIT
|
||||
# Return true if RJIT is enabled.
|
||||
def self.enabled?
|
||||
Primitive.cexpr! 'RBOOL(mjit_enabled)'
|
||||
end
|
||||
|
@ -22,12 +22,12 @@ module RubyVM::MJIT
|
|||
end
|
||||
end
|
||||
|
||||
if RubyVM::MJIT.enabled?
|
||||
if RubyVM::RJIT.enabled?
|
||||
begin
|
||||
require 'fiddle'
|
||||
require 'fiddle/import'
|
||||
rescue LoadError
|
||||
return # miniruby doesn't support MJIT
|
||||
return # miniruby doesn't support RJIT
|
||||
end
|
||||
|
||||
require 'ruby_vm/mjit/c_type'
|
||||
|
|
12
rjit_c.c
12
rjit_c.c
|
@ -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>.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#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
|
||||
void rb_mjit_c(void) {}
|
||||
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
|
||||
#include "mjit.h"
|
||||
#include "mjit_c.h"
|
||||
|
@ -42,7 +42,7 @@ void rb_mjit_c(void) {}
|
|||
#define SIZEOF(type) RB_SIZE2NUM(sizeof(type))
|
||||
#define SIGNED_TYPE_P(type) RBOOL((type)(-1) < (type)(1))
|
||||
|
||||
#if MJIT_STATS
|
||||
#if RJIT_STATS
|
||||
// Insn side exit counters
|
||||
static size_t mjit_insn_exits[VM_INSTRUCTION_SIZE] = { 0 };
|
||||
#endif // YJIT_STATS
|
||||
|
@ -83,7 +83,7 @@ dump_disasm(rb_execution_context_t *ec, VALUE self, VALUE from, VALUE to)
|
|||
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
|
||||
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"
|
||||
|
||||
#endif // USE_MJIT
|
||||
#endif // USE_RJIT
|
||||
|
|
28
rjit_c.h
28
rjit_c.h
|
@ -1,6 +1,6 @@
|
|||
// This file is parsed by tool/mjit/generate.rb to generate mjit_c.rb
|
||||
#ifndef MJIT_C_H
|
||||
#define MJIT_C_H
|
||||
#ifndef RJIT_C_H
|
||||
#define RJIT_C_H
|
||||
|
||||
#include "ruby/internal/config.h"
|
||||
#include "internal/string.h"
|
||||
|
@ -25,14 +25,14 @@ struct rb_mjit_unit_list {
|
|||
|
||||
enum rb_mjit_unit_type {
|
||||
// Single-ISEQ unit for unit_queue
|
||||
MJIT_UNIT_ISEQ = 0,
|
||||
RJIT_UNIT_ISEQ = 0,
|
||||
// Multi-ISEQ unit for mjit_batch
|
||||
MJIT_UNIT_BATCH = 1,
|
||||
RJIT_UNIT_BATCH = 1,
|
||||
// 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
|
||||
struct rb_mjit_unit {
|
||||
struct ccan_list_node unode;
|
||||
|
@ -41,7 +41,7 @@ struct rb_mjit_unit {
|
|||
// Type of this unit
|
||||
enum rb_mjit_unit_type type;
|
||||
|
||||
/* MJIT_UNIT_ISEQ */
|
||||
/* RJIT_UNIT_ISEQ */
|
||||
// ISEQ for a non-batch unit
|
||||
rb_iseq_t *iseq;
|
||||
// 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
|
||||
unsigned int cc_entries_size;
|
||||
|
||||
/* MJIT_UNIT_BATCH, MJIT_UNIT_COMPACT */
|
||||
/* RJIT_UNIT_BATCH, RJIT_UNIT_COMPACT */
|
||||
// Dlopen handle of the loaded object file.
|
||||
void *handle;
|
||||
// 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.
|
||||
|
@ -103,12 +103,12 @@ struct compile_status {
|
|||
//
|
||||
|
||||
// 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;
|
||||
|
||||
#define MJIT_RUNTIME_COUNTERS(...) struct rb_mjit_runtime_counters { size_t __VA_ARGS__; };
|
||||
MJIT_RUNTIME_COUNTERS(
|
||||
#define RJIT_RUNTIME_COUNTERS(...) struct rb_mjit_runtime_counters { size_t __VA_ARGS__; };
|
||||
RJIT_RUNTIME_COUNTERS(
|
||||
vm_insns_count,
|
||||
mjit_insns_count,
|
||||
|
||||
|
@ -207,7 +207,7 @@ MJIT_RUNTIME_COUNTERS(
|
|||
|
||||
compiled_block_count
|
||||
)
|
||||
#undef MJIT_RUNTIME_COUNTERS
|
||||
#undef RJIT_RUNTIME_COUNTERS
|
||||
extern struct rb_mjit_runtime_counters rb_mjit_counters;
|
||||
|
||||
#endif /* MJIT_C_H */
|
||||
#endif /* RJIT_C_H */
|
||||
|
|
16
rjit_c.rb
16
rjit_c.rb
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
# 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".
|
||||
module RubyVM::MJIT # :nodoc: all
|
||||
# Run `make mjit-bindgen` to update code between "RJIT bindgen begin" and "RJIT bindgen end".
|
||||
module RubyVM::RJIT # :nodoc: all
|
||||
# This `class << C` section is for calling C functions. For importing variables
|
||||
# or macros as is, please consider using tool/mjit/bindgen.rb instead.
|
||||
class << C = Object.new
|
||||
|
@ -12,7 +12,7 @@ module RubyVM::MJIT # :nodoc: all
|
|||
def mjit_mark_writable
|
||||
Primitive.cstmt! %{
|
||||
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;
|
||||
}
|
||||
end
|
||||
|
@ -20,14 +20,14 @@ module RubyVM::MJIT # :nodoc: all
|
|||
def mjit_mark_executable
|
||||
Primitive.cstmt! %{
|
||||
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;
|
||||
}
|
||||
end
|
||||
|
||||
def mjit_insn_exits
|
||||
addr = Primitive.cstmt! %{
|
||||
#if MJIT_STATS
|
||||
#if RJIT_STATS
|
||||
return SIZET2NUM((size_t)mjit_insn_exits);
|
||||
#else
|
||||
return SIZET2NUM(0);
|
||||
|
@ -45,7 +45,7 @@ module RubyVM::MJIT # :nodoc: all
|
|||
|
||||
def rb_mjit_counters
|
||||
addr = Primitive.cstmt! %{
|
||||
#if MJIT_STATS
|
||||
#if RJIT_STATS
|
||||
return SIZET2NUM((size_t)&rb_mjit_counters);
|
||||
#else
|
||||
return SIZET2NUM(0);
|
||||
|
@ -569,7 +569,7 @@ module RubyVM::MJIT # :nodoc: all
|
|||
end
|
||||
end
|
||||
|
||||
### MJIT bindgen begin ###
|
||||
### RJIT bindgen begin ###
|
||||
|
||||
def C.USE_LAZY_LOAD
|
||||
Primitive.cexpr! %q{ RBOOL(USE_LAZY_LOAD != 0) }
|
||||
|
@ -1872,5 +1872,5 @@ module RubyVM::MJIT # :nodoc: all
|
|||
CType::Stub.new(:rb_ext_config)
|
||||
end
|
||||
|
||||
### MJIT bindgen end ###
|
||||
### RJIT bindgen end ###
|
||||
end if Primitive.mjit_enabled_p
|
||||
|
|
34
ruby.c
34
ruby.c
|
@ -118,7 +118,7 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
|
|||
enum feature_flag_bits {
|
||||
EACH_FEATURES(DEFINE_FEATURE, COMMA),
|
||||
feature_debug_flag_first,
|
||||
#if defined(MJIT_FORCE_ENABLE) || !USE_YJIT
|
||||
#if defined(RJIT_FORCE_ENABLE) || !USE_YJIT
|
||||
DEFINE_FEATURE(jit) = feature_mjit,
|
||||
#else
|
||||
DEFINE_FEATURE(jit) = feature_yjit,
|
||||
|
@ -213,7 +213,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
|
|||
opt->ext.enc.index = -1;
|
||||
opt->intern.enc.index = -1;
|
||||
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);
|
||||
#elif defined(YJIT_FORCE_ENABLE)
|
||||
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("-x[directory]", "", "strip off text before #!ruby line and perhaps cd to directory"),
|
||||
M("--jit", "", "enable JIT for the platform, same as " PLATFORM_JIT_OPTION),
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
M("--mjit", "", "enable C compiler-based JIT compiler (experimental)"),
|
||||
#endif
|
||||
#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("rubyopt", "", "RUBYOPT environment variable (default: enabled)"),
|
||||
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)"),
|
||||
#endif
|
||||
#if USE_YJIT
|
||||
|
@ -332,7 +332,7 @@ usage(const char *name, int help, int highlight, int columns)
|
|||
M("deprecated", "", "deprecated features"),
|
||||
M("experimental", "", "experimental features"),
|
||||
};
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
extern const struct ruby_opt_message mjit_option_messages[];
|
||||
#endif
|
||||
#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);
|
||||
for (i = 0; i < numberof(warn_categories); ++i)
|
||||
SHOW(warn_categories[i]);
|
||||
#if USE_MJIT
|
||||
printf("%s""MJIT options (experimental):%s\n", sb, se);
|
||||
#if USE_RJIT
|
||||
printf("%s""RJIT options (experimental):%s\n", sb, se);
|
||||
for (i = 0; mjit_option_messages[i].str; ++i)
|
||||
SHOW(mjit_option_messages[i]);
|
||||
#endif
|
||||
|
@ -957,7 +957,7 @@ feature_option(const char *str, int len, void *arg, const unsigned int enable)
|
|||
goto found;
|
||||
}
|
||||
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);
|
||||
goto found;
|
||||
}
|
||||
|
@ -1486,19 +1486,19 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
|
|||
ruby_verbose = Qtrue;
|
||||
}
|
||||
else if (strcmp("jit", s) == 0) {
|
||||
#if !USE_MJIT
|
||||
#if !USE_RJIT
|
||||
rb_warn("Ruby was built without JIT support");
|
||||
#else
|
||||
FEATURE_SET(opt->features, FEATURE_BIT(jit));
|
||||
#endif
|
||||
}
|
||||
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);
|
||||
FEATURE_SET(opt->features, FEATURE_BIT(mjit));
|
||||
mjit_setup_options(s, &opt->mjit);
|
||||
#else
|
||||
rb_warn("MJIT support is disabled.");
|
||||
rb_warn("RJIT support is disabled.");
|
||||
#endif
|
||||
}
|
||||
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);
|
||||
|
||||
#if USE_MJIT
|
||||
// rb_call_builtin_inits depends on RubyVM::MJIT.enabled?
|
||||
#if USE_RJIT
|
||||
// rb_call_builtin_inits depends on RubyVM::RJIT.enabled?
|
||||
if (opt->mjit.on)
|
||||
mjit_enabled = true;
|
||||
if (opt->mjit.stats)
|
||||
|
@ -1625,8 +1625,8 @@ ruby_opt_init(ruby_cmdline_options_t *opt)
|
|||
ruby_init_prelude();
|
||||
|
||||
// Initialize JITs after prelude because JITing prelude is typically not optimal.
|
||||
#if USE_MJIT
|
||||
// Also, mjit_init is safe only after rb_call_builtin_inits() defines RubyVM::MJIT::Compiler.
|
||||
#if USE_RJIT
|
||||
// Also, mjit_init is safe only after rb_call_builtin_inits() defines RubyVM::RJIT::Compiler.
|
||||
if (opt->mjit.on)
|
||||
mjit_init(&opt->mjit);
|
||||
#endif
|
||||
|
@ -1935,11 +1935,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
#endif
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
if (FEATURE_SET_P(opt->features, mjit)) {
|
||||
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
|
||||
ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION)
|
||||
end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) ||
|
||||
(defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?)
|
||||
(defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,11 +19,11 @@ describe "IO#flush" do
|
|||
end
|
||||
end
|
||||
|
||||
# [ruby-core:90895] MJIT worker may leave fd open in a forked child.
|
||||
# For instance, MJIT creates a worker before @r.close with fork(), @r.close happens,
|
||||
# and the MJIT worker keeps the pipe open until the worker execve().
|
||||
# TODO: consider acquiring GVL from MJIT worker.
|
||||
guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do
|
||||
# [ruby-core:90895] RJIT worker may leave fd open in a forked child.
|
||||
# For instance, RJIT creates a worker before @r.close with fork(), @r.close happens,
|
||||
# and the RJIT worker keeps the pipe open until the worker execve().
|
||||
# TODO: consider acquiring GVL from RJIT worker.
|
||||
guard_not -> { defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? } do
|
||||
it "raises Errno::EPIPE if sync=false and the read end is closed" do
|
||||
@w.sync = false
|
||||
@w.write "foo"
|
||||
|
|
|
@ -85,11 +85,11 @@ describe :io_write, shared: true do
|
|||
@r.read.should == "foo"
|
||||
end
|
||||
|
||||
# [ruby-core:90895] MJIT worker may leave fd open in a forked child.
|
||||
# For instance, MJIT creates a worker before @r.close with fork(), @r.close happens,
|
||||
# and the MJIT worker keeps the pipe open until the worker execve().
|
||||
# TODO: consider acquiring GVL from MJIT worker.
|
||||
guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do
|
||||
# [ruby-core:90895] RJIT worker may leave fd open in a forked child.
|
||||
# For instance, RJIT creates a worker before @r.close with fork(), @r.close happens,
|
||||
# and the RJIT worker keeps the pipe open until the worker execve().
|
||||
# TODO: consider acquiring GVL from RJIT worker.
|
||||
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
|
||||
@r.close
|
||||
-> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/)
|
||||
|
|
|
@ -4,7 +4,7 @@ describe "Process.wait2" do
|
|||
before :all do
|
||||
# HACK: this kludge is temporarily necessary because some
|
||||
# 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
|
||||
begin
|
||||
Process.wait(-1, Process::WNOHANG)
|
||||
|
|
|
@ -2249,10 +2249,10 @@ PREDEFINED += DEPRECATED(_)=_
|
|||
PREDEFINED += DEPRECATED_BY(__,_)=_
|
||||
PREDEFINED += ENUM_OVER_INT=1
|
||||
PREDEFINED += ERRORFUNC(__,_)=_
|
||||
PREDEFINED += MJIT_FUNC_EXPORTED=
|
||||
PREDEFINED += MJIT_STATIC=extern
|
||||
PREDEFINED += MJIT_SYMBOL_EXPORT_BEGIN=
|
||||
PREDEFINED += MJIT_SYMBOL_EXPORT_END=
|
||||
PREDEFINED += RJIT_FUNC_EXPORTED=
|
||||
PREDEFINED += RJIT_STATIC=extern
|
||||
PREDEFINED += RJIT_SYMBOL_EXPORT_BEGIN=
|
||||
PREDEFINED += RJIT_SYMBOL_EXPORT_END=
|
||||
PREDEFINED += NOINLINE(_)=_
|
||||
PREDEFINED += NORETURN(_)=_
|
||||
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:yes=)
|
||||
CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
|
||||
MJIT_SUPPORT = @MJIT_SUPPORT@
|
||||
MJIT_CC = @MJIT_CC@
|
||||
MJIT_CFLAGS = @MJIT_CFLAGS@
|
||||
MJIT_OPTFLAGS = @MJIT_OPTFLAGS@
|
||||
MJIT_DEBUGFLAGS = @MJIT_DEBUGFLAGS@
|
||||
MJIT_LDSHARED = @MJIT_LDSHARED@
|
||||
MJIT_DLDFLAGS = $(XDLDFLAGS)
|
||||
RJIT_SUPPORT = @RJIT_SUPPORT@
|
||||
RJIT_CC = @RJIT_CC@
|
||||
RJIT_CFLAGS = @RJIT_CFLAGS@
|
||||
RJIT_OPTFLAGS = @RJIT_OPTFLAGS@
|
||||
RJIT_DEBUGFLAGS = @RJIT_DEBUGFLAGS@
|
||||
RJIT_LDSHARED = @RJIT_LDSHARED@
|
||||
RJIT_DLDFLAGS = $(XDLDFLAGS)
|
||||
YJIT_SUPPORT=@YJIT_SUPPORT@
|
||||
YJIT_LIBS=@YJIT_LIBS@
|
||||
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|
|
||||
version[n] = arg[v] || src.value(v) || (s ? v : 0)
|
||||
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'
|
||||
%>baseruby="<%=arg['BASERUBY']%>"
|
||||
_\
|
||||
|
@ -41,8 +41,8 @@ class Object
|
|||
constants.grep(/^RUBY_/) {|n| remove_const n}
|
||||
% arg['versions'].each {|n, v|
|
||||
<%=n%> = <%if n=='RUBY_DESCRIPTION' %>case
|
||||
when RubyVM.const_defined?(:MJIT) && RubyVM::MJIT.enabled?
|
||||
<%=arg['RUBY_DESCRIPTION_WITH_MJIT'].inspect%>
|
||||
when RubyVM.const_defined?(:RJIT) && RubyVM::RJIT.enabled?
|
||||
<%=arg['RUBY_DESCRIPTION_WITH_RJIT'].inspect%>
|
||||
when RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled?
|
||||
<%=arg['RUBY_DESCRIPTION_WITH_YJIT'].inspect%>
|
||||
else
|
||||
|
|
|
@ -12,7 +12,7 @@ class TestBugReporter < Test::Unit::TestCase
|
|||
omit if ENV['RUBY_ON_BUG']
|
||||
|
||||
description = RUBY_DESCRIPTION
|
||||
description = description.sub(/\+MJIT /, '') unless JITSupport.mjit_force_enabled?
|
||||
description = description.sub(/\+RJIT /, '') unless JITSupport.mjit_force_enabled?
|
||||
expected_stderr = [
|
||||
:*,
|
||||
/\[BUG\]\sSegmentation\sfault.*\n/,
|
||||
|
|
|
@ -329,7 +329,7 @@ line,5,jkl
|
|||
if defined?(RubyVM::YJIT.enabled?) and RubyVM::YJIT.enabled?
|
||||
timeout = 1 # for --yjit-call-threshold=1
|
||||
end
|
||||
if defined?(RubyVM::MJIT.enabled?) and RubyVM::MJIT.enabled?
|
||||
if defined?(RubyVM::RJIT.enabled?) and RubyVM::RJIT.enabled?
|
||||
timeout = 5 # for --jit-wait
|
||||
end
|
||||
Timeout.timeout(timeout) do
|
||||
|
|
|
@ -218,7 +218,7 @@ module DRbCore
|
|||
omit if RUBY_PLATFORM.include?("armv7l-linux")
|
||||
omit if RUBY_PLATFORM.include?("sparc-solaris2.10")
|
||||
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
|
||||
ten = Onecky.new(10)
|
||||
assert_raise(Timeout::Error) do
|
||||
|
|
|
@ -54,11 +54,11 @@ module JITSupport
|
|||
)
|
||||
end
|
||||
|
||||
# For MJIT
|
||||
# For RJIT
|
||||
def supported?
|
||||
return @supported if defined?(@supported)
|
||||
@supported = RbConfig::CONFIG["MJIT_SUPPORT"] != 'no' &&
|
||||
UNSUPPORTED_COMPILERS.all? { |regexp| !regexp.match?(RbConfig::CONFIG['MJIT_CC']) } &&
|
||||
@supported = RbConfig::CONFIG["RJIT_SUPPORT"] != 'no' &&
|
||||
UNSUPPORTED_COMPILERS.all? { |regexp| !regexp.match?(RbConfig::CONFIG['RJIT_CC']) } &&
|
||||
!PENDING_RUBYCI_NICKNAMES.include?(ENV['RUBYCI_NICKNAME']) &&
|
||||
!UNSUPPORTED_ARCHITECTURES.include?(RUBY_PLATFORM.split('-', 2).first)
|
||||
end
|
||||
|
@ -70,8 +70,8 @@ module JITSupport
|
|||
end
|
||||
|
||||
def remove_mjit_logs(stderr)
|
||||
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # utility for -DFORCE_MJIT_ENABLE
|
||||
stderr.gsub(/^MJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '')
|
||||
if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # utility for -DFORCE_RJIT_ENABLE
|
||||
stderr.gsub(/^RJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '')
|
||||
else
|
||||
stderr
|
||||
end
|
||||
|
@ -88,6 +88,6 @@ module JITSupport
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -313,7 +313,7 @@ EOS
|
|||
|
||||
def test_read_body_block_mod
|
||||
# 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'
|
||||
end
|
||||
IO.pipe do |r, w|
|
||||
|
|
|
@ -9,7 +9,7 @@ class Reline::WithinPipeTest < Reline::TestCase
|
|||
@reader, @output_writer = IO.pipe(@encoding)
|
||||
@output = Reline.output = @output_writer
|
||||
@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
|
||||
end
|
||||
|
||||
|
|
|
@ -402,7 +402,7 @@ module TupleSpaceTestModule
|
|||
end
|
||||
|
||||
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])
|
||||
assert_equal([[:removeme, 1]], @ts.read_all([nil, nil]))
|
||||
entry.cancel
|
||||
|
@ -686,7 +686,7 @@ class TestRingServer < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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}
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class TestFiber < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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
|
||||
assert_equal(max, max.times{
|
||||
Fiber.new{}
|
||||
|
|
|
@ -655,7 +655,7 @@ class TestIO < Test::Unit::TestCase
|
|||
|
||||
if have_nonblock?
|
||||
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
|
||||
|
||||
msg = 'r58534 [ruby-core:80969] [Backport #13533]'
|
||||
|
@ -1679,7 +1679,7 @@ class TestIO < Test::Unit::TestCase
|
|||
end if have_nonblock?
|
||||
|
||||
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|
|
||||
assert_equal :wait_readable, r.read_nonblock(4096, exception: false)
|
||||
w.puts "HI!"
|
||||
|
@ -2349,7 +2349,7 @@ class TestIO < Test::Unit::TestCase
|
|||
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/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]'
|
||||
pre = 'ft2250'
|
||||
|
|
|
@ -3172,7 +3172,7 @@ class TestModule < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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_eval "A = 1", __FILE__, line = __LINE__
|
||||
e = assert_raise_with_message(TypeError, /is not a module/) {
|
||||
|
|
|
@ -510,7 +510,7 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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]'
|
||||
|
||||
tailcall("#{<<-"begin;"}\n#{<<~"end;"}")
|
||||
|
|
|
@ -272,7 +272,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
end;
|
||||
end
|
||||
|
||||
MANDATORY_ENVS = %w[RUBYLIB MJIT_SEARCH_BUILD_DIR]
|
||||
MANDATORY_ENVS = %w[RUBYLIB RJIT_SEARCH_BUILD_DIR]
|
||||
case RbConfig::CONFIG['target_os']
|
||||
when /linux/
|
||||
MANDATORY_ENVS << 'LD_PRELOAD'
|
||||
|
@ -1717,7 +1717,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
Process.wait pid
|
||||
assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable'
|
||||
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]"
|
||||
else
|
||||
assert_equal [true], signal_received, "[ruby-core:19744]"
|
||||
|
|
|
@ -7,12 +7,12 @@ require 'tempfile'
|
|||
require_relative '../lib/jit_support'
|
||||
|
||||
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?
|
||||
|
||||
NO_JIT_DESCRIPTION =
|
||||
if mjit_enabled?
|
||||
RUBY_DESCRIPTION.sub(/\+MJIT /, '')
|
||||
RUBY_DESCRIPTION.sub(/\+RJIT /, '')
|
||||
elsif yjit_enabled?
|
||||
RUBY_DESCRIPTION.sub(/\+YJIT( (dev|dev_nodebug|stats))? /, '')
|
||||
else
|
||||
|
@ -140,7 +140,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
VERSION_PATTERN_WITH_JIT =
|
||||
case RUBY_ENGINE
|
||||
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
|
||||
VERSION_PATTERN
|
||||
end
|
||||
|
@ -225,8 +225,8 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
assert_equal([], e)
|
||||
end
|
||||
|
||||
omit "This fails on some CIs for now. To be fixed in MJIT's side."
|
||||
return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no'
|
||||
omit "This fails on some CIs for now. To be fixed in RJIT's side."
|
||||
return if RbConfig::CONFIG["RJIT_SUPPORT"] == 'no'
|
||||
return if yjit_force_enabled?
|
||||
|
||||
[
|
||||
|
|
|
@ -2168,9 +2168,9 @@ CODE
|
|||
}
|
||||
# it is dirty hack. usually we shouldn't use such technique
|
||||
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.
|
||||
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|
|
||||
if file == __FILE__
|
||||
|
|
|
@ -348,7 +348,7 @@ class TestShapes < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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
|
||||
shape = RubyVM::Shape.of(obj)
|
||||
refute_equal(RubyVM::Shape.root_shape, shape)
|
||||
|
|
|
@ -323,7 +323,7 @@ class TestThread < Test::Unit::TestCase
|
|||
s += 1
|
||||
end
|
||||
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)
|
||||
t.wakeup
|
||||
Thread.pass while t.alive?
|
||||
|
@ -1446,8 +1446,8 @@ q.pop
|
|||
def test_thread_interrupt_for_killed_thread
|
||||
opts = { timeout: 5, timeout_error: nil }
|
||||
|
||||
# prevent SIGABRT from slow shutdown with MJIT
|
||||
opts[:reprieve] = 3 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
|
||||
# prevent SIGABRT from slow shutdown with RJIT
|
||||
opts[:reprieve] = 3 if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
|
||||
|
||||
assert_normal_exit(<<-_end, '[Bug #8996]', **opts)
|
||||
Thread.report_on_exception = false
|
||||
|
|
|
@ -11,7 +11,7 @@ require_relative '../lib/jit_support'
|
|||
return unless JITSupport.yjit_supported?
|
||||
|
||||
# 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
|
||||
running_with_yjit = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ require_relative '../lib/jit_support'
|
|||
return unless JITSupport.yjit_supported?
|
||||
|
||||
# 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
|
||||
def test_yjit_trace_exits_and_v_no_error
|
||||
_stdout, stderr, _status = EnvUtil.invoke_ruby(%w(-v --yjit-trace-exits), '', true, true)
|
||||
|
|
|
@ -4,8 +4,8 @@ require "rubygems/user_interaction"
|
|||
require "timeout"
|
||||
|
||||
class TestGemStreamUI < Gem::TestCase
|
||||
# increase timeout with MJIT for --jit-wait testing
|
||||
mjit_enabled = defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
|
||||
# increase timeout with RJIT for --jit-wait testing
|
||||
mjit_enabled = defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
|
||||
SHORT_TIMEOUT = (RUBY_ENGINE == "ruby" && !mjit_enabled) ? 0.1 : 1.0
|
||||
|
||||
module IsTty
|
||||
|
|
|
@ -486,7 +486,7 @@ class TestSocket < Test::Unit::TestCase
|
|||
end while IO.select([r], nil, nil, 0.1).nil?
|
||||
n
|
||||
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))
|
||||
msg, _, _, stamp = s1.recvmsg
|
||||
assert_equal("a", msg)
|
||||
|
|
12
thread.c
12
thread.c
|
@ -100,7 +100,7 @@
|
|||
#include "vm_debug.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>
|
||||
#endif
|
||||
|
||||
|
@ -2280,7 +2280,7 @@ threadptr_get_interrupts(rb_thread_t *th)
|
|||
return interrupt & (rb_atomic_t)~ec->interrupt_mask;
|
||||
}
|
||||
|
||||
#if USE_MJIT
|
||||
#if USE_RJIT
|
||||
// process.c
|
||||
extern bool mjit_waitpid_finished;
|
||||
extern int mjit_waitpid_status;
|
||||
|
@ -2335,8 +2335,8 @@ rb_threadptr_execute_interrupts(rb_thread_t *th, int blocking_timing)
|
|||
th->status = prev_status;
|
||||
}
|
||||
|
||||
#if USE_MJIT
|
||||
// Handle waitpid_signal for MJIT issued by ruby_sigchld_handler. This needs to be done
|
||||
#if USE_RJIT
|
||||
// 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.
|
||||
if (mjit_waitpid_finished && th == th->vm->ractor.main_thread) {
|
||||
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);
|
||||
|
||||
/* 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->workqueue_lock);
|
||||
|
||||
|
@ -4658,7 +4658,7 @@ rb_thread_atfork(void)
|
|||
/* We don't want reproduce CVE-2003-0900. */
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ static int ubf_threads_empty(void);
|
|||
|
||||
/*
|
||||
* 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
|
||||
* allowed to read from sigwait_fd, otherwise starvation can occur.
|
||||
*/
|
||||
|
|
|
@ -111,8 +111,8 @@ module Test
|
|||
end
|
||||
|
||||
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
|
||||
pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
|
||||
# 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 RJIT memory usage as leak' if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?
|
||||
|
||||
require_relative 'memory_status'
|
||||
raise Test::Unit::PendedError, "unsupported platform" unless defined?(Memory::Status)
|
||||
|
|
|
@ -89,16 +89,16 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
module MJITFirst
|
||||
module RJITFirst
|
||||
def group(list)
|
||||
# MJIT first
|
||||
# RJIT first
|
||||
mjit, others = list.partition {|e| /test_mjit/ =~ e}
|
||||
mjit + others
|
||||
end
|
||||
end
|
||||
|
||||
class Alpha < NoSort
|
||||
include MJITFirst
|
||||
include RJITFirst
|
||||
|
||||
def sort_by_name(list)
|
||||
list.sort_by(&:name)
|
||||
|
@ -112,7 +112,7 @@ module Test
|
|||
|
||||
# shuffle test suites based on CRC32 of their names
|
||||
Shuffle = Struct.new(:seed, :salt) do
|
||||
include MJITFirst
|
||||
include RJITFirst
|
||||
|
||||
def initialize(seed)
|
||||
self.class::CRC_TBL ||= (0..255).map {|i|
|
||||
|
@ -1589,7 +1589,7 @@ module Test
|
|||
puts if @verbose
|
||||
$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__}")
|
||||
end
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ File.foreach "config.status" do |line|
|
|||
when /^(?:X|(?:MINI|RUN|(?:HAVE_)?BASE|BOOTSTRAP|BTEST)RUBY(?:_COMMAND)?$)/; next
|
||||
when /^INSTALLDOC|TARGET$/; next
|
||||
when /^DTRACE/; next
|
||||
when /^MJIT_(CC|SUPPORT)$/; # pass
|
||||
when /^MJIT_/; next
|
||||
when /^RJIT_(CC|SUPPORT)$/; # pass
|
||||
when /^RJIT_/; next
|
||||
when /^(?:MAJOR|MINOR|TEENY)$/; vars[name] = val; next
|
||||
when /^LIBRUBY_D?LD/; next
|
||||
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.
|
||||
class BindingGenerator
|
||||
BINDGEN_BEG = '### MJIT bindgen begin ###'
|
||||
BINDGEN_END = '### MJIT bindgen end ###'
|
||||
BINDGEN_BEG = '### RJIT bindgen begin ###'
|
||||
BINDGEN_END = '### RJIT bindgen end ###'
|
||||
DEFAULTS = { '_Bool' => 'CType::Bool.new' }
|
||||
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];
|
||||
}
|
||||
|
||||
// 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.
|
||||
static bool leafness_of_check_ints = false;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module RubyVM::MJIT # :nodoc: all
|
||||
module RubyVM::RJIT # :nodoc: all
|
||||
Instruction = Struct.new(
|
||||
:name,
|
||||
:bin,
|
||||
|
|
|
@ -6,7 +6,7 @@ class TestHideSkip < Test::Unit::TestCase
|
|||
assert_not_match(/^ *1\) Skipped/, hideskip)
|
||||
assert_match(/^ *1\) Skipped.*^ *2\) Skipped/m, hideskip("--show-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)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module TestParallel
|
|||
PARALLEL_RB = "#{__dir__}/../../lib/test/unit/parallel.rb"
|
||||
TESTS = "#{__dir__}/tests_for_parallel"
|
||||
# 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
|
||||
def setup
|
||||
|
|
|
@ -253,7 +253,7 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase
|
|||
server.virtual_host(WEBrick::HTTPServer.new(vhost_config))
|
||||
|
||||
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(0, stopped, 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|
|
||||
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(0, stopped, log.call)
|
||||
assert_equal(0, accepted, log.call)
|
||||
|
|
10
version.c
10
version.c
|
@ -71,7 +71,7 @@ const char ruby_release_date[] = RUBY_RELEASE_DATE;
|
|||
const char ruby_platform[] = RUBY_PLATFORM;
|
||||
const int ruby_patchlevel = RUBY_PATCHLEVEL;
|
||||
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);
|
||||
const char ruby_copyright[] = "ruby - Copyright (C) "
|
||||
RUBY_BIRTH_YEAR_STR "-" RUBY_RELEASE_YEAR_STR " "
|
||||
|
@ -126,10 +126,10 @@ Init_version(void)
|
|||
rb_provide("ruby2_keywords.rb");
|
||||
}
|
||||
|
||||
#if USE_MJIT
|
||||
#define MJIT_OPTS_ON opt->mjit.on
|
||||
#if USE_RJIT
|
||||
#define RJIT_OPTS_ON opt->mjit.on
|
||||
#else
|
||||
#define MJIT_OPTS_ON 0
|
||||
#define RJIT_OPTS_ON 0
|
||||
#endif
|
||||
|
||||
#if USE_YJIT
|
||||
|
@ -143,7 +143,7 @@ Init_ruby_description(ruby_cmdline_options_t *opt)
|
|||
{
|
||||
VALUE description;
|
||||
|
||||
if (MJIT_OPTS_ON) {
|
||||
if (RJIT_OPTS_ON) {
|
||||
rb_dynamic_description = ruby_description_with_mjit;
|
||||
description = MKSTR(description_with_mjit);
|
||||
}
|
||||
|
|
4
vm.c
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);
|
||||
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.
|
||||
// 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.
|
||||
static inline VALUE
|
||||
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
|
||||
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;
|
||||
|
||||
#if USE_MJIT || USE_YJIT
|
||||
#if USE_RJIT || USE_YJIT
|
||||
// Function pointer for JIT code
|
||||
VALUE (*jit_func)(struct rb_execution_context_struct *, struct rb_control_frame_struct *);
|
||||
// Number of total calls with jit_exec()
|
||||
long unsigned total_calls;
|
||||
#endif
|
||||
|
||||
#if USE_MJIT
|
||||
// MJIT stores some data on each iseq.
|
||||
#if USE_RJIT
|
||||
// RJIT stores some data on each iseq.
|
||||
VALUE mjit_blocks;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5397,7 +5397,7 @@ vm_ic_track_const_chain(rb_control_frame_t *cfp, IC ic, const ID *segments)
|
|||
RB_VM_LOCK_LEAVE();
|
||||
}
|
||||
|
||||
// For MJIT inlining
|
||||
// For RJIT inlining
|
||||
static inline bool
|
||||
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_global_cvar_state;
|
||||
|
||||
#ifndef MJIT_STATS
|
||||
# define MJIT_STATS RUBY_DEBUG
|
||||
#ifndef RJIT_STATS
|
||||
# define RJIT_STATS RUBY_DEBUG
|
||||
#endif
|
||||
|
||||
#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_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.
|
||||
#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_REGISTER(reg, s) /* none */
|
||||
#elif MJIT_STATS
|
||||
#elif RJIT_STATS
|
||||
// for --mjit-stats
|
||||
#define COLLECT_USAGE_INSN(insn) rb_mjit_collect_vm_usage_insn(insn)
|
||||
#define COLLECT_USAGE_OPERAND(insn, n, op) /* none */
|
||||
|
|
|
@ -350,8 +350,8 @@ CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS)
|
|||
!if "$(USE_RUBYGEMS)" == "no"
|
||||
CPPFLAGS = -DDISABLE_RUBYGEMS $(CPPFLAGS)
|
||||
!endif
|
||||
!ifndef MJIT_SUPPORT
|
||||
MJIT_SUPPORT = no
|
||||
!ifndef RJIT_SUPPORT
|
||||
RJIT_SUPPORT = no
|
||||
!endif
|
||||
|
||||
POSTLINK =
|
||||
|
@ -930,7 +930,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
|
|||
#define RUBY_COREDLL "$(RT)"
|
||||
#define RUBY_PLATFORM "$(arch)"
|
||||
#define RUBY_SITEARCH "$(sitearch)"
|
||||
#define USE_MJIT 0
|
||||
#define USE_RJIT 0
|
||||
#endif /* $(guard) */
|
||||
<<
|
||||
|
||||
|
@ -1123,7 +1123,7 @@ s,@srcdir@,$(srcdir),;t t
|
|||
s,@top_srcdir@,$(srcdir),;t t
|
||||
s,@try_header@,try_compile,;t t
|
||||
s,@ruby_pc@,$(ruby_pc),;t t
|
||||
s,@MJIT_SUPPORT@,$(MJIT_SUPPORT),;t t
|
||||
s,@RJIT_SUPPORT@,$(RJIT_SUPPORT),;t t
|
||||
<<KEEP
|
||||
|
||||
!if "$(HAVE_BASERUBY)" != "yes" || "$(CROSS_COMPILING)" == "yes"
|
||||
|
|
|
@ -59,8 +59,8 @@ USE_RUBYGEMS = $(USE_RUBYGEMS)
|
|||
!if defined(ENABLE_DEBUG_ENV)
|
||||
ENABLE_DEBUG_ENV = $(ENABLE_DEBUG_ENV)
|
||||
!endif
|
||||
!if defined(MJIT_SUPPORT)
|
||||
MJIT_SUPPORT = $(MJIT_SUPPORT)
|
||||
!if defined(RJIT_SUPPORT)
|
||||
RJIT_SUPPORT = $(RJIT_SUPPORT)
|
||||
!endif
|
||||
|
||||
# TOOLS
|
||||
|
|
|
@ -1355,7 +1355,7 @@ is_batch(const char *cmd)
|
|||
HANDLE
|
||||
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
|
||||
be used, like `ALLOCV` that may trigger GC or `FindFreeChildSlot` that finds
|
||||
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 *
|
||||
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;
|
||||
int len = MultiByteToWideChar(cp, 0, str, clen, NULL, 0);
|
||||
if (!(ptr = malloc(sizeof(WCHAR) * len))) return 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче