2023-03-07 10:15:30 +03:00
|
|
|
module RubyVM::RJIT
|
2023-12-22 03:18:30 +03:00
|
|
|
# Return true if \RJIT is enabled.
|
2022-06-15 20:19:33 +03:00
|
|
|
def self.enabled?
|
2023-03-09 10:14:33 +03:00
|
|
|
Primitive.cexpr! 'RBOOL(rb_rjit_enabled)'
|
2022-06-15 20:19:33 +03:00
|
|
|
end
|
|
|
|
|
2023-12-22 03:18:30 +03:00
|
|
|
# Start JIT compilation after \--rjit-disable.
|
2023-12-22 01:24:10 +03:00
|
|
|
def self.enable
|
2023-03-10 09:43:38 +03:00
|
|
|
Primitive.cstmt! %{
|
|
|
|
rb_rjit_call_p = true;
|
|
|
|
return Qnil;
|
|
|
|
}
|
2022-06-15 20:19:33 +03:00
|
|
|
end
|
2022-12-28 10:57:16 +03:00
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
if Primitive.rjit_stats_enabled_p
|
2023-02-07 11:00:09 +03:00
|
|
|
at_exit do
|
2023-03-07 10:17:25 +03:00
|
|
|
Primitive.rjit_stop_stats
|
2023-02-07 11:00:09 +03:00
|
|
|
print_stats
|
|
|
|
end
|
2022-12-28 10:57:16 +03:00
|
|
|
end
|
2023-03-12 23:55:39 +03:00
|
|
|
if Primitive.rjit_trace_exits_enabled_p
|
|
|
|
at_exit do
|
|
|
|
Primitive.rjit_stop_stats
|
|
|
|
dump_trace_exits
|
|
|
|
end
|
|
|
|
end
|
2022-06-15 20:19:33 +03:00
|
|
|
end
|
2022-11-27 02:10:58 +03:00
|
|
|
|
2023-03-07 10:15:30 +03:00
|
|
|
if RubyVM::RJIT.enabled?
|
2022-11-27 02:10:58 +03:00
|
|
|
begin
|
|
|
|
require 'fiddle'
|
|
|
|
require 'fiddle/import'
|
|
|
|
rescue LoadError
|
2023-03-07 10:15:30 +03:00
|
|
|
return # miniruby doesn't support RJIT
|
2022-11-27 02:10:58 +03:00
|
|
|
end
|
|
|
|
|
2023-03-07 10:17:25 +03:00
|
|
|
require 'ruby_vm/rjit/c_type'
|
|
|
|
require 'ruby_vm/rjit/compiler'
|
|
|
|
require 'ruby_vm/rjit/hooks'
|
|
|
|
require 'ruby_vm/rjit/stats'
|
2022-11-27 02:10:58 +03:00
|
|
|
end
|