mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00

I noticed this while running test_yjit with --mjit-call-threshold=1, which redefines `Integer#<`. When Ruby is monkey-patched, MJIT itself could be broken. Similarly, Ruby scripts could break MJIT in many different ways. I prepared the same set of hooks as YJIT so that we could possibly override it and disable it on those moments. Every constant under RubyVM::MJIT is private and thus it's an unsupported behavior though.
37 lines
801 B
Ruby
37 lines
801 B
Ruby
module RubyVM::MJIT
|
|
# Return true if MJIT is enabled.
|
|
def self.enabled?
|
|
Primitive.cexpr! 'RBOOL(mjit_enabled)'
|
|
end
|
|
|
|
# Stop generating JITed code.
|
|
def self.pause(wait: true)
|
|
Primitive.cexpr! 'mjit_pause(RTEST(wait))'
|
|
end
|
|
|
|
# Start generating JITed code again after pause.
|
|
def self.resume
|
|
Primitive.cexpr! 'mjit_resume()'
|
|
end
|
|
end
|
|
|
|
if RubyVM::MJIT.enabled?
|
|
begin
|
|
require 'fiddle'
|
|
require 'fiddle/import'
|
|
rescue LoadError
|
|
return # miniruby doesn't support MJIT
|
|
end
|
|
|
|
# forward declaration for ruby_vm/mjit/compiler
|
|
RubyVM::MJIT::C = Object.new # :nodoc:
|
|
|
|
require 'ruby_vm/mjit/c_type'
|
|
require 'ruby_vm/mjit/instruction'
|
|
require 'ruby_vm/mjit/compiler'
|
|
require 'ruby_vm/mjit/hooks'
|
|
|
|
module RubyVM::MJIT
|
|
private_constant(*constants)
|
|
end
|
|
end
|