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
|
2022-12-28 10:57:16 +03:00
|
|
|
|
|
|
|
if Primitive.mjit_stats_enabled_p
|
2023-02-07 11:00:09 +03:00
|
|
|
at_exit do
|
|
|
|
Primitive.mjit_stop_stats
|
|
|
|
print_stats
|
|
|
|
end
|
2022-12-28 10:57:16 +03:00
|
|
|
end
|
2022-06-15 20:19:33 +03:00
|
|
|
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-28 10:04:53 +03:00
|
|
|
require 'ruby_vm/mjit/c_type'
|
|
|
|
require 'ruby_vm/mjit/compiler'
|
2023-02-04 09:42:13 +03:00
|
|
|
require 'ruby_vm/mjit/hooks'
|
2022-12-28 10:04:53 +03:00
|
|
|
require 'ruby_vm/mjit/stats'
|
2022-11-27 02:10:58 +03:00
|
|
|
end
|