diff --git a/.github/workflows/annocheck.yml b/.github/workflows/annocheck.yml index be85205feed097..304d216d6844e3 100644 --- a/.github/workflows/annocheck.yml +++ b/.github/workflows/annocheck.yml @@ -39,9 +39,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/baseruby.yml b/.github/workflows/baseruby.yml index 87162936fd8ff5..ffaec18b83e74d 100644 --- a/.github/workflows/baseruby.yml +++ b/.github/workflows/baseruby.yml @@ -35,9 +35,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 5267bd35f1c92a..54f8df66a2f177 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -71,9 +71,7 @@ jobs: ${{false || contains(github.event.head_commit.message, '[ruby/rdoc]') || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0dfae7f045220b..6968be5e02a43c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,9 +41,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index f52cab97081d30..3bad0886130698 100644 --- a/.github/workflows/compilers.yml +++ b/.github/workflows/compilers.yml @@ -35,9 +35,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index d822a2e9e217e3..d23261ddeee350 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -32,9 +32,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index bf5f5cd413c112..aab238ea47f523 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -57,9 +57,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index 1c4cb533d3f3c7..773bb775033d41 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -57,9 +57,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/modgc.yml b/.github/workflows/modgc.yml index fe10979a5fc9d3..63c2d75d77e2e2 100644 --- a/.github/workflows/modgc.yml +++ b/.github/workflows/modgc.yml @@ -42,9 +42,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/parse_y.yml b/.github/workflows/parse_y.yml index c77b4516d1e737..5acf6ae4cb9596 100644 --- a/.github/workflows/parse_y.yml +++ b/.github/workflows/parse_y.yml @@ -45,9 +45,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/rust-warnings.yml b/.github/workflows/rust-warnings.yml index b05ebbfe64ff3e..a8840c28e4c30c 100644 --- a/.github/workflows/rust-warnings.yml +++ b/.github/workflows/rust-warnings.yml @@ -30,9 +30,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/spec_guards.yml b/.github/workflows/spec_guards.yml index 34b0202e9fb6da..e952053891de78 100644 --- a/.github/workflows/spec_guards.yml +++ b/.github/workflows/spec_guards.yml @@ -29,9 +29,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index e17d6dc3ed0efb..27cd43bf9cd880 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -68,9 +68,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 9294e2d339bf4c..1d1e4bc5a2d1dc 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -53,9 +53,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d7c88393be52e0..9137e5298a9b1b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -44,9 +44,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/wsl.yml b/.github/workflows/wsl.yml index af490dffd74d1b..640f18ce42e876 100644 --- a/.github/workflows/wsl.yml +++ b/.github/workflows/wsl.yml @@ -21,9 +21,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/yjit-macos.yml b/.github/workflows/yjit-macos.yml index 60139257af306c..72ef599a39010d 100644 --- a/.github/workflows/yjit-macos.yml +++ b/.github/workflows/yjit-macos.yml @@ -35,9 +35,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} @@ -79,9 +77,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/yjit-ubuntu.yml b/.github/workflows/yjit-ubuntu.yml index 7ec4de8cdce66b..3b3b75faac8054 100644 --- a/.github/workflows/yjit-ubuntu.yml +++ b/.github/workflows/yjit-ubuntu.yml @@ -120,9 +120,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/zjit-macos.yml b/.github/workflows/zjit-macos.yml index 7b5d9f6b6107ce..41ff382382c706 100644 --- a/.github/workflows/zjit-macos.yml +++ b/.github/workflows/zjit-macos.yml @@ -57,9 +57,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/.github/workflows/zjit-ubuntu.yml b/.github/workflows/zjit-ubuntu.yml index da53a52b7d9f1d..4b0e0dbd5caf21 100644 --- a/.github/workflows/zjit-ubuntu.yml +++ b/.github/workflows/zjit-ubuntu.yml @@ -63,9 +63,7 @@ jobs: if: >- ${{!(false || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.head_commit.message, 'Document') || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.title, 'Document') || contains(github.event.pull_request.labels.*.name, 'Documentation') || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') )}} diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 3e3936942d67bb..f76af3633deaa9 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -5342,3 +5342,30 @@ def test_local_fill_in_forwardable test_local_fill_in_forwardable.inspect } + +# Test defined?(yield) and block_given? in non-method context. +# It's good that the body of this runs at true top level and isn't wrapped in a block. +assert_equal 'false', %{ + RESULT = [] + RESULT << defined?(yield) + RESULT << block_given? + + 1.times do + RESULT << defined?(yield) + RESULT << block_given? + end + + module ModuleContext + 1.times do + RESULT << defined?(yield) + RESULT << block_given? + end + end + + class << self + RESULT << defined?(yield) + RESULT << block_given? + end + + RESULT.any? +} diff --git a/include/ruby/internal/core/rtypeddata.h b/include/ruby/internal/core/rtypeddata.h index 9441b2f5c2b78a..4d9fd4a6acbde8 100644 --- a/include/ruby/internal/core/rtypeddata.h +++ b/include/ruby/internal/core/rtypeddata.h @@ -375,7 +375,9 @@ struct RTypedData { void *data; }; +#if !defined(__cplusplus) || __cplusplus >= 201103L RBIMPL_STATIC_ASSERT(data_in_rtypeddata, offsetof(struct RData, data) == offsetof(struct RTypedData, data)); +#endif RBIMPL_SYMBOL_EXPORT_BEGIN() RBIMPL_ATTR_NONNULL((3)) diff --git a/ruby.c b/ruby.c index f400a3d53140b3..5a78a7c7649f90 100644 --- a/ruby.c +++ b/ruby.c @@ -2354,7 +2354,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) if (!FEATURE_USED_P(opt->features, yjit) && env_var_truthy("RUBY_YJIT_ENABLE")) { FEATURE_SET(opt->features, FEATURE_BIT(yjit)); } -#elif USE_ZJIT +#endif +#if USE_ZJIT if (!FEATURE_USED_P(opt->features, zjit) && env_var_truthy("RUBY_ZJIT_ENABLE")) { FEATURE_SET(opt->features, FEATURE_BIT(zjit)); } diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 326cf22e1f01d5..e35fc0c14ecfe5 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -309,7 +309,7 @@ def test_trace_object_allocations_compaction def test_trace_object_allocations_compaction_freed_pages omit "compaction is not supported on this platform" unless GC.respond_to?(:compact) - assert_normal_exit(<<~RUBY) + assert_normal_exit(<<~RUBY, timeout: 60) require "objspace" objs = [] diff --git a/test/ruby/test_ractor.rb b/test/ruby/test_ractor.rb index 74de2bf9cd1af5..1e06dfd83a59fb 100644 --- a/test/ruby/test_ractor.rb +++ b/test/ruby/test_ractor.rb @@ -164,7 +164,8 @@ def test_require_non_string # [Bug #21398] def test_port_receive_dnt_with_port_send - assert_ractor(<<~'RUBY', timeout: 30) + omit 'unstable on macos-14' if RUBY_PLATFORM =~ /darwin/ + assert_ractor(<<~'RUBY', timeout: 90) THREADS = 10 JOBS_PER_THREAD = 50 ARRAY_SIZE = 20_000 diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index fe6ffde07c0cae..b6c76ac73a662e 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -994,7 +994,7 @@ def test_script_from_stdin pid = spawn(EnvUtil.rubybin, :in => s, :out => w) w.close assert_nothing_raised('[ruby-dev:37798]') do - result = EnvUtil.timeout(3) {r.read} + result = EnvUtil.timeout(10) {r.read} end Process.wait pid } diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 58fc9ba6393d17..e3880a2828cf2e 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -18,6 +18,14 @@ def test_enabled RUBY end + def test_enable_through_env + child_env = {'RUBY_YJIT_ENABLE' => nil, 'RUBY_ZJIT_ENABLE' => '1'} + assert_in_out_err([child_env, '-v'], '') do |stdout, stderr| + assert_includes(stdout.first, '+ZJIT') + assert_equal([], stderr) + end + end + def test_call_itself assert_compiles '42', <<~RUBY, call_threshold: 2 def test = 42.itself diff --git a/version.c b/version.c index 243f00b38c0e74..d634755efd16c0 100644 --- a/version.c +++ b/version.c @@ -72,11 +72,6 @@ const int ruby_api_version[] = { #else #define ZJIT_DESCRIPTION " +ZJIT" #endif -#if USE_ZJIT -#define JIT_DESCRIPTION ZJIT_DESCRIPTION -#else -#define JIT_DESCRIPTION YJIT_DESCRIPTION -#endif #if USE_MODULAR_GC #define GC_DESCRIPTION " +GC" #else @@ -207,6 +202,8 @@ rb_ruby_default_parser_set(ruby_default_parser_enum parser) static void define_ruby_description(const char *const jit_opt) { +#define JIT_DESCRIPTION YJIT_DESCRIPTION ZJIT_DESCRIPTION + static char desc[ sizeof(ruby_description) + rb_strlen_lit(JIT_DESCRIPTION) @@ -248,6 +245,7 @@ define_ruby_description(const char *const jit_opt) * The full ruby version string, like ruby -v prints */ rb_define_const(mRuby, "DESCRIPTION", /* MKSTR(description) */ description); +#undef JIT_DESCRIPTION } void diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index b8b15adc8b44a8..9644b948d7d515 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -6656,16 +6656,24 @@ fn gen_block_given( ) { asm_comment!(asm, "block_given?"); - // Same as rb_vm_frame_block_handler - let ep_opnd = gen_get_lep(jit, asm); - let block_handler = asm.load( - Opnd::mem(64, ep_opnd, SIZEOF_VALUE_I32 * VM_ENV_DATA_INDEX_SPECVAL) - ); + // `yield` goes to the block handler stowed in the "local" iseq which is + // the current iseq or a parent. Only the "method" iseq type can be passed a + // block handler. (e.g. `yield` in the top level script is a syntax error.) + let local_iseq = unsafe { rb_get_iseq_body_local_iseq(jit.iseq) }; + if unsafe { rb_get_iseq_body_type(local_iseq) } == ISEQ_TYPE_METHOD { + // Same as rb_vm_frame_block_handler + let ep_opnd = gen_get_lep(jit, asm); + let block_handler = asm.load( + Opnd::mem(64, ep_opnd, SIZEOF_VALUE_I32 * VM_ENV_DATA_INDEX_SPECVAL) + ); - // Return `block_handler != VM_BLOCK_HANDLER_NONE` - asm.cmp(block_handler, VM_BLOCK_HANDLER_NONE.into()); - let block_given = asm.csel_ne(true_opnd, false_opnd); - asm.mov(out_opnd, block_given); + // Return `block_handler != VM_BLOCK_HANDLER_NONE` + asm.cmp(block_handler, VM_BLOCK_HANDLER_NONE.into()); + let block_given = asm.csel_ne(true_opnd, false_opnd); + asm.mov(out_opnd, block_given); + } else { + asm.mov(out_opnd, false_opnd); + } } // Codegen for rb_class_superclass()