diff options
author | Takashi Kokubun <[email protected]> | 2025-04-29 11:03:13 -0700 |
---|---|---|
committer | <[email protected]> | 2025-04-29 11:03:13 -0700 |
commit | 0f3d6ee57825f6ecbcbab797ef8e9ca9f84bc095 () | |
tree | 0d6e112eb555e161e9feecf7c00dfa13622cf67b | |
parent | 0c44e5ab5efc3a54a0d18bf9c2a206c714e1d1c7 (diff) |
ZJIT: Disable ZJIT instructions when USE_ZJIT is 0 (#13199)
* ZJIT: Disable ZJIT instructions when USE_ZJIT is 0 * Test the order of ZJIT instructions * Add more jobs that disable JITs * Show instruction names in the message
Notes: Merged-By: k0kubun <[email protected]>
-rw-r--r-- | ./workflows/compilers.yml | 4 | ||||
-rw-r--r-- | test/ruby/test_zjit.rb | 13 | ||||
-rw-r--r-- | tool/ruby_vm/views/_comptime_insn_stack_increase.erb | 25 | ||||
-rw-r--r-- | tool/ruby_vm/views/_insn_len_info.erb | 12 | ||||
-rw-r--r-- | tool/ruby_vm/views/_insn_name_info.erb | 32 | ||||
-rw-r--r-- | tool/ruby_vm/views/_insn_operand_info.erb | 32 | ||||
-rw-r--r-- | tool/ruby_vm/views/_zjit_helpers.erb | 4 | ||||
-rw-r--r-- | tool/ruby_vm/views/_zjit_instruction.erb | 4 | ||||
-rw-r--r-- | tool/ruby_vm/views/insns.inc.erb | 10 | ||||
-rw-r--r-- | tool/ruby_vm/views/optunifs.inc.erb | 5 | ||||
-rw-r--r-- | tool/ruby_vm/views/vmtc.inc.erb | 10 | ||||
-rw-r--r-- | yjit/src/cruby_bindings.inc.rs | 14 |
12 files changed, 118 insertions, 47 deletions
@@ -193,7 +193,9 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: { sparse-checkout-cone-mode: false, sparse-checkout: /. } - { uses: '././actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } } - - { uses: '././actions/compilers', name: 'disable-jit', with: { append_configure: '--disable-yjit' } } - { uses: '././actions/compilers', name: 'disable-dln', with: { append_configure: '--disable-dln' } } - { uses: '././actions/compilers', name: 'enable-mkmf-verbose', with: { append_configure: '--enable-mkmf-verbose' } } - { uses: '././actions/compilers', name: 'disable-rubygems', with: { append_configure: '--disable-rubygems' } } @@ -479,6 +479,19 @@ class TestZJIT < Test::Unit::TestCase }, call_threshold: 5, num_profiles: 3 end private # Assert that every method call in `test_script` can be compiled by ZJIT @@ -6,6 +6,16 @@ %# conditions mentioned in the file COPYING are met. Consult the file for %# details. %# PUREFUNC(MAYBE_UNUSED(static int comptime_insn_stack_increase(int depth, int insn, const VALUE *opes))); PUREFUNC(static rb_snum_t comptime_insn_stack_increase_dis(enum ruby_vminsn_type insn, const VALUE *opes)); @@ -13,15 +23,14 @@ rb_snum_t comptime_insn_stack_increase_dis(enum ruby_vminsn_type insn, const VALUE *opes) { static const signed char t[] = { -% RubyVM::Instructions.each_slice 8 do |a| - <%= a.map { |i| - if i.has_attribute?('sp_inc') - '-127' - else - sprintf("%4d", i.rets.size - i.pops.size) - end - }.join(', ') -%>, % end }; signed char c = t[insn]; @@ -5,6 +5,9 @@ %# granted, to either redistribute and/or modify this file, provided that the %# conditions mentioned in the file COPYING are met. Consult the file for %# details. CONSTFUNC(MAYBE_UNUSED(static int insn_len(VALUE insn))); RUBY_SYMBOL_EXPORT_BEGIN /* for debuggers */ @@ -13,9 +16,14 @@ RUBY_SYMBOL_EXPORT_END #ifdef RUBY_VM_INSNS_INFO const uint8_t rb_vm_insn_len_info[] = { -% RubyVM::Instructions.each_slice 23 do |a| - <%= a.map(&:width).join(', ') -%>, % end }; ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_len_info); @@ -6,10 +6,14 @@ %# conditions mentioned in the file COPYING are met. Consult the file for %# details. % -% a = RubyVM::Instructions.map {|i| i.name } -% b = (0...a.size) -% c = a.inject([0]) {|r, i| r << (r[-1] + i.length + 1) } -% c.pop % CONSTFUNC(MAYBE_UNUSED(static const char *insn_name(VALUE insn))); @@ -20,18 +24,28 @@ extern const unsigned short rb_vm_insn_name_offset[VM_INSTRUCTION_SIZE]; RUBY_SYMBOL_EXPORT_END #ifdef RUBY_VM_INSNS_INFO -const int rb_vm_max_insn_name_size = <%= a.map(&:size).max %>; const char rb_vm_insn_name_base[] = -% a.each do |i| - <%=cstr i%> "\0" % end ; const unsigned short rb_vm_insn_name_offset[] = { -% c.each_slice 12 do |d| - <%= d.map {|i| sprintf("%4d", i) }.join(', ') %>, % end }; ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_name_offset); @@ -6,10 +6,16 @@ %# conditions mentioned in the file COPYING are met. Consult the file for %# details. % -% a = RubyVM::Instructions.map {|i| i.operands_info } -% b = (0...a.size) -% c = a.inject([0]) {|r, i| r << (r[-1] + i.length + 1) } -% c.pop % CONSTFUNC(MAYBE_UNUSED(static const char *insn_op_types(VALUE insn))); CONSTFUNC(MAYBE_UNUSED(static int insn_op_type(VALUE insn, long pos))); @@ -21,15 +27,25 @@ RUBY_SYMBOL_EXPORT_END #ifdef RUBY_VM_INSNS_INFO const char rb_vm_insn_op_base[] = -% a.each_slice 5 do |d| - <%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(' "\0" ') %> "\0" % end ; const unsigned short rb_vm_insn_op_offset[] = { -% c.each_slice 12 do |d| - <%= d.map {|i| sprintf("%3d", i) }.join(', ') %>, % end }; ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_op_offset); @@ -1,3 +1,5 @@ MAYBE_UNUSED(static int vm_bare_insn_to_zjit_insn(int insn)); static int vm_bare_insn_to_zjit_insn(int insn) @@ -25,3 +27,5 @@ vm_zjit_insn_to_bare_insn(int insn) return insn; } } @@ -1,3 +1,5 @@ /* insn <%= insn.pretty_name %> */ INSN_ENTRY(<%= insn.name %>) { @@ -6,3 +8,5 @@ INSN_ENTRY(<%= insn.name %>) DIS_ORIGINAL_INSN(<%= insn.jump_destination %>); END_INSN(<%= insn.name %>); } @@ -6,6 +6,9 @@ %# granted, to either redistribute and/or modify this file, provided that the %# conditions mentioned in the file COPYING are met. Consult the file for %# details. <%= render 'copyright' %> <%= render 'notice', locals: { this_file: 'contains YARV instruction list', @@ -19,9 +22,14 @@ #define BIN(n) YARVINSN_##n enum ruby_vminsn_type { -% RubyVM::Instructions.each do |i| <%= i.bin %>, % end VM_INSTRUCTION_SIZE }; @@ -7,7 +7,6 @@ %# conditions mentioned in the file COPYING are met. Consult the file for %# details. % raise ':FIXME:TBW' if RubyVM::VmOptsH['INSTRUCTIONS_UNIFICATION'] -% n = RubyVM::Instructions.size <%= render 'copyright' %> <%= render 'notice', locals: { this_file: 'is for threaded code', @@ -16,6 +15,4 @@ /* Let .bss section automatically initialize this variable */ /* cf. Section 6.7.8 of ISO/IEC 9899:1999 */ -static const int *const *const unified_insns_data[<%= n %>]; - -ASSERT_VM_INSTRUCTION_SIZE(unified_insns_data); @@ -6,6 +6,9 @@ %# granted, to either redistribute and/or modify this file, provided that the %# conditions mentioned in the file COPYING are met. Consult the file for %# details. <%= render 'copyright' -%> <%= render 'notice', locals: { this_file: 'is for threaded code', @@ -13,9 +16,14 @@ } -%> static const void *const insns_address_table[] = { -% RubyVM::Instructions.each do |i| LABEL_PTR(<%= i.name %>), % end }; ASSERT_VM_INSTRUCTION_SIZE(insns_address_table); @@ -949,19 +949,7 @@ pub const YARVINSN_trace_setlocal_WC_0: ruby_vminsn_type = 218; pub const YARVINSN_trace_setlocal_WC_1: ruby_vminsn_type = 219; pub const YARVINSN_trace_putobject_INT2FIX_0_: ruby_vminsn_type = 220; pub const YARVINSN_trace_putobject_INT2FIX_1_: ruby_vminsn_type = 221; -pub const YARVINSN_zjit_opt_send_without_block: ruby_vminsn_type = 222; -pub const YARVINSN_zjit_opt_plus: ruby_vminsn_type = 223; -pub const YARVINSN_zjit_opt_minus: ruby_vminsn_type = 224; -pub const YARVINSN_zjit_opt_mult: ruby_vminsn_type = 225; -pub const YARVINSN_zjit_opt_div: ruby_vminsn_type = 226; -pub const YARVINSN_zjit_opt_mod: ruby_vminsn_type = 227; -pub const YARVINSN_zjit_opt_eq: ruby_vminsn_type = 228; -pub const YARVINSN_zjit_opt_neq: ruby_vminsn_type = 229; -pub const YARVINSN_zjit_opt_lt: ruby_vminsn_type = 230; -pub const YARVINSN_zjit_opt_le: ruby_vminsn_type = 231; -pub const YARVINSN_zjit_opt_gt: ruby_vminsn_type = 232; -pub const YARVINSN_zjit_opt_ge: ruby_vminsn_type = 233; -pub const VM_INSTRUCTION_SIZE: ruby_vminsn_type = 234; pub type ruby_vminsn_type = u32; pub type rb_iseq_callback = ::std::option::Option< unsafe extern "C" fn(arg1: *const rb_iseq_t, arg2: *mut ::std::os::raw::c_void), |