summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2025-03-07 12:55:47 -0800
committerTakashi Kokubun <[email protected]>2025-04-18 21:52:59 +0900
commit33a052486baa54ab858bd0a06033e90a3c66d2ac ()
treed2f0602755e3e1df114be2c882dc4071128d362d
parentd2115562b92e70bea71cfaca175f59587c6a77da (diff)
Assert everything is compiled in test_zjit (https://.com/Shopify/zjit/pull/40)
* Assert everything is compiled in test_zjit * Update a comment on rb_zjit_assert_compiles Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> * Add a comment about assert_compiles * Actually use pipe_fd --------- Co-authored-by: Maxime Chevalier-Boisvert <[email protected]>
Notes: Merged: https://.com/ruby/ruby/pull/13131
-rw-r--r--.document1
-rw-r--r--./workflows/zjit-macos.yml13
-rw-r--r--./workflows/zjit-ubuntu.yml13
-rw-r--r--bootstraptest/test_zjit.rb33
-rw-r--r--common.mk3
-rw-r--r--inits.c1
-rw-r--r--test/lib/jit_support.rb6
-rw-r--r--test/ruby/test_zjit.rb117
-rw-r--r--zjit.c6
-rw-r--r--zjit.rb6
-rw-r--r--zjit/src/lib.rs16
-rw-r--r--zjit/src/state.rs15
12 files changed, 177 insertions, 53 deletions
@@ -30,6 +30,7 @@ thread_sync.rb
trace_point.rb
warning.rb
yjit.rb
# Errno::*
known_errors.inc
@@ -31,15 +31,9 @@ jobs:
- test_task: 'zjit-test'
configure: '--enable-zjit=dev'
- - test_task: 'btest'
- zjit_opts: '--zjit-call-threshold=1'
configure: '--enable-zjit=dev'
- btests: '../src/bootstraptest/test_zjit.rb'
-
- - test_task: 'btest'
- zjit_opts: '--zjit-call-threshold=2'
- configure: '--enable-zjit=dev'
- btests: '../src/bootstraptest/test_zjit.rb'
# Test without ZJIT for now
- test_task: 'check'
@@ -101,14 +95,13 @@ jobs:
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"}
RUN_OPTS="$RUN_OPTS"
SPECOPTS="$SPECOPTS"
- BTESTS="$BTESTS"
timeout-minutes: 60
env:
RUBY_TESTOPTS: '-q --tty=no'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'typeprof'
SYNTAX_SUGGEST_TIMEOUT: '5'
PRECHECK_BUNDLED_GEMS: 'no'
- BTESTS: ${{ matrix.btests }}
continue-on-error: ${{ matrix.continue-on-test_task || false }}
result:
@@ -36,15 +36,9 @@ jobs:
- test_task: 'zjit-test'
configure: '--enable-zjit=dev'
- - test_task: 'btest'
- zjit_opts: '--zjit-call-threshold=1'
configure: '--enable-zjit=dev'
- btests: '../src/bootstraptest/test_zjit.rb'
-
- - test_task: 'btest'
- zjit_opts: '--zjit-call-threshold=2'
- configure: '--enable-zjit=dev'
- btests: '../src/bootstraptest/test_zjit.rb'
# Test without ZJIT for now
- test_task: 'check'
@@ -125,7 +119,6 @@ jobs:
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"}
RUN_OPTS="$RUN_OPTS" MSPECOPT=--debug SPECOPTS="$SPECOPTS"
YJIT_BENCH_OPTS="$YJIT_BENCH_OPTS" YJIT_BINDGEN_DIFF_OPTS="$YJIT_BINDGEN_DIFF_OPTS"
- BTESTS="$BTESTS"
timeout-minutes: 90
env:
RUBY_TESTOPTS: '-q --tty=no'
@@ -134,7 +127,7 @@ jobs:
SYNTAX_SUGGEST_TIMEOUT: '5'
YJIT_BINDGEN_DIFF_OPTS: '--exit-code'
LIBCLANG_PATH: ${{ matrix.libclang_path }}
- BTESTS: ${{ matrix.btests }}
continue-on-error: ${{ matrix.continue-on-test_task || false }}
result:
@@ -1,33 +0,0 @@
-# Tests of Ruby methods that ZJIT can currently compile.
-# make btest BTESTS=bootstraptest/test_zjit.rb RUN_OPTS="--zjit"
-
-assert_equal 'nil', %q{
- def test = nil
- test; test.inspect
-}
-
-assert_equal '1', %q{
- def test = 1
- test; test
-}
-
-assert_equal '3', %q{
- def test = 1 + 2
- test; test
-}
-
-assert_equal '[6, 3]', %q{
- def test(a, b) = a + b
- [test(2, 4), test(1, 2)]
-}
-
-# Test argument ordering
-assert_equal '2', %q{
- def test(a, b) = a - b
- test(6, 4)
-}
-
-assert_equal '6', %q{
- def test(a, b, c) = a + b + c
- test(1, 2, 3)
-}
@@ -1223,6 +1223,7 @@ BUILTIN_RB_SRCS = \
$(srcdir)/gem_prelude.rb \
$(srcdir)/yjit.rb \
$(srcdir)/yjit_hook.rb \
$(empty)
BUILTIN_RB_INCS = $(BUILTIN_RB_SRCS:.rb=.rbinc)
@@ -10717,6 +10718,7 @@ miniinit.$(OBJEXT): {$(VPATH)}vm_opts.h
miniinit.$(OBJEXT): {$(VPATH)}warning.rb
miniinit.$(OBJEXT): {$(VPATH)}yjit.rb
miniinit.$(OBJEXT): {$(VPATH)}yjit_hook.rb
node.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
node.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
node.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -21179,4 +21181,5 @@ zjit.$(OBJEXT): {$(VPATH)}vm_opts.h
zjit.$(OBJEXT): {$(VPATH)}vm_sync.h
zjit.$(OBJEXT): {$(VPATH)}zjit.c
zjit.$(OBJEXT): {$(VPATH)}zjit.h
# AUTOGENERATED DEPENDENCIES END
@@ -103,6 +103,7 @@ rb_call_builtin_inits(void)
BUILTIN(thread_sync);
BUILTIN(nilclass);
BUILTIN(marshal);
Init_builtin_prelude();
}
#undef CALL
@@ -16,4 +16,10 @@ module JITSupport
def yjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?YJIT_FORCE_ENABLE\b/)
end
end
@@ -0,0 +1,117 @@
@@ -677,3 +677,9 @@ rb_iseq_set_zjit_payload(const rb_iseq_t *iseq, void *payload)
RUBY_ASSERT_ALWAYS(NULL == iseq->body->zjit_payload);
iseq->body->zjit_payload = payload;
}
@@ -0,0 +1,6 @@
@@ -89,6 +89,15 @@ fn rb_bug_panic_hook() {
/// Generate JIT code for a given ISEQ, which takes EC and CFP as its arguments.
#[unsafe(no_mangle)]
pub extern "C" fn rb_zjit_iseq_gen_entry_point(iseq: IseqPtr, _ec: EcPtr) -> *const u8 {
// Do not test the JIT code in HIR tests
if cfg!(test) {
return std::ptr::null();
@@ -116,3 +125,10 @@ pub extern "C" fn rb_zjit_iseq_gen_entry_point(iseq: IseqPtr, _ec: EcPtr) -> *co
}
})
}
@@ -12,6 +12,9 @@ pub struct ZJITState {
/// Assumptions that require invalidation
invariants: Invariants,
}
/// Private singleton instance of the codegen globals
@@ -64,6 +67,7 @@ impl ZJITState {
code_block: cb,
options,
invariants: Invariants::default(),
};
unsafe { ZJIT_STATE = Some(zjit_state); }
}
@@ -92,4 +96,15 @@ impl ZJITState {
pub fn get_invariants() -> &'static mut Invariants {
&mut ZJITState::get_instance().invariants
}
}