diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-09-10 14:18:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 14:18:44 -0700 |
| commit | bd4de1245f9899463a817d43863bcee520741e50 (patch) | |
| tree | ab2f0a8316bc9318039127e5d20bd531240eba3f | |
| parent | 9401f4e7f28af7cb9e1476c4e513e67ca2a782cd (diff) | |
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.
| -rw-r--r-- | tool/ruby_vm/models/instructions.rb | 9 | ||||
| -rw-r--r-- | tool/ruby_vm/models/trace_instruction.rb | 10 | ||||
| -rw-r--r-- | tool/ruby_vm/models/zjit_instruction.rb | 4 |
3 files changed, 9 insertions, 14 deletions
diff --git a/tool/ruby_vm/models/instructions.rb b/tool/ruby_vm/models/instructions.rb index f2c6562d37..7be7064b14 100644 --- a/tool/ruby_vm/models/instructions.rb +++ b/tool/ruby_vm/models/instructions.rb @@ -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 diff --git a/tool/ruby_vm/models/trace_instruction.rb b/tool/ruby_vm/models/trace_instruction.rb index 2a5b67eaa2..6a3ad53c44 100644 --- a/tool/ruby_vm/models/trace_instruction.rb +++ b/tool/ruby_vm/models/trace_instruction.rb @@ -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 diff --git a/tool/ruby_vm/models/zjit_instruction.rb b/tool/ruby_vm/models/zjit_instruction.rb index dc1925b095..04764e4c61 100644 --- a/tool/ruby_vm/models/zjit_instruction.rb +++ b/tool/ruby_vm/models/zjit_instruction.rb @@ -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 |
