summaryrefslogtreecommitdiff
path: root/rjit.rb
blob: ebad3529ef78e5af202e4f58194874c03ea2881b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module RubyVM::RJIT
  # Return true if RJIT is enabled.
  def self.enabled?
    Primitive.cexpr! 'RBOOL(rb_rjit_enabled)'
  end

  # Start generating JITed code again after --rjit-pause.
  def self.resume
    Primitive.cstmt! %{
      rb_rjit_call_p = true;
      return Qnil;
    }
  end

  if Primitive.rjit_stats_enabled_p
    at_exit do
      Primitive.rjit_stop_stats
      print_stats
    end
  end
  if Primitive.rjit_trace_exits_enabled_p
    at_exit do
      Primitive.rjit_stop_stats
      dump_trace_exits
    end
  end
end

if RubyVM::RJIT.enabled?
  begin
    require 'fiddle'
    require 'fiddle/import'
  rescue LoadError
    return # miniruby doesn't support RJIT
  end

  require 'ruby_vm/rjit/c_type'
  require 'ruby_vm/rjit/compiler'
  require 'ruby_vm/rjit/hooks'
  require 'ruby_vm/rjit/stats'
end