Explicitly declare VM instruction dependencies (#14509)

instead of mutating RubyVM::Instructions and letting the order of
`require` impact its behavior.

Now that we have both RubyVM::TraceInstruction and
RubyVM::ZJITInstruction, it feels too much of a tight coupling to rely
on `require` to be ordered properly.
This commit is contained in:
Takashi Kokubun 2025-09-10 14:18:44 -07:00 committed by GitHub
parent 9401f4e7f2
commit bd4de1245f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 14 deletions

View File

@ -12,11 +12,12 @@
require_relative 'bare_instruction'
require_relative 'operands_unification'
require_relative 'instructions_unification'
require_relative 'trace_instruction'
require_relative 'zjit_instruction'
RubyVM::Instructions = RubyVM::BareInstruction.all +
RubyVM::OperandsUnification.all +
RubyVM::InstructionsUnification.all
require_relative 'trace_instruction'
require_relative 'zjit_instruction'
RubyVM::InstructionsUnification.all +
RubyVM::TraceInstruction.all +
RubyVM::ZJITInstruction.all
RubyVM::Instructions.freeze

View File

@ -58,17 +58,13 @@ class RubyVM::TraceInstruction
return false
end
def zjit_profile?
return false
end
private
@instances = RubyVM::Instructions.map {|i| new i }
@instances = (RubyVM::BareInstruction.all +
RubyVM::OperandsUnification.all +
RubyVM::InstructionsUnification.all).map {|i| new(i) }
def self.all
@instances
end
RubyVM::Instructions.push(*all)
end

View File

@ -48,11 +48,9 @@ class RubyVM::ZJITInstruction
return false
end
@instances = RubyVM::Instructions.filter(&:zjit_profile?).map {|i| new(i) }
@instances = RubyVM::BareInstruction.all.filter(&:zjit_profile?).map {|i| new(i) }
def self.all
@instances
end
RubyVM::Instructions.push(*all)
end