2022-06-15 20:19:33 +03:00
|
|
|
module RubyVM::MJIT
|
2022-12-23 01:30:07 +03:00
|
|
|
# Return true if MJIT is enabled.
|
2022-06-15 20:19:33 +03:00
|
|
|
def self.enabled?
|
|
|
|
Primitive.cexpr! 'RBOOL(mjit_enabled)'
|
|
|
|
end
|
|
|
|
|
2022-12-23 01:30:07 +03:00
|
|
|
# Stop generating JITed code.
|
2022-06-15 20:19:33 +03:00
|
|
|
def self.pause(wait: true)
|
|
|
|
Primitive.cexpr! 'mjit_pause(RTEST(wait))'
|
|
|
|
end
|
|
|
|
|
2022-12-23 01:30:07 +03:00
|
|
|
# Start generating JITed code again after pause.
|
2022-06-15 20:19:33 +03:00
|
|
|
def self.resume
|
|
|
|
Primitive.cexpr! 'mjit_resume()'
|
|
|
|
end
|
|
|
|
end
|
2022-11-27 02:10:58 +03:00
|
|
|
|
|
|
|
if RubyVM::MJIT.enabled?
|
|
|
|
begin
|
|
|
|
require 'fiddle'
|
|
|
|
require 'fiddle/import'
|
|
|
|
rescue LoadError
|
|
|
|
return # miniruby doesn't support MJIT
|
|
|
|
end
|
|
|
|
|
2022-12-12 08:42:25 +03:00
|
|
|
require 'mjit/c_type'
|
|
|
|
require 'mjit/compiler'
|
2022-12-27 09:46:40 +03:00
|
|
|
require 'mjit/stats'
|
2022-11-27 02:10:58 +03:00
|
|
|
end
|