summaryrefslogtreecommitdiff
path: root/mjit.rb
blob: 64c1c69c1a20f466e3fbfd4ea30c72688204a0b6 (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
module RubyVM::MJIT
  def self.enabled?
    Primitive.cexpr! 'RBOOL(mjit_enabled)'
  end

  def self.pause(wait: true)
    Primitive.cexpr! 'mjit_pause(RTEST(wait))'
  end

  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

  RubyVM::MJIT::C = Object.new # forward declaration for mjit/compiler
  require "mjit/c_type"
  require "mjit/instruction"
  require "mjit/compiler"

  module RubyVM::MJIT
    private_constant(*constants)
  end
end