From fd04e1b4dbbb0dae130f3de79d69ca94ecdf883e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 11 Dec 2022 21:42:25 -0800 Subject: Implement a no-op JIT compiler --- lib/ruby_vm/mjit/compiler.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'lib/ruby_vm') diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb index cb2930246a..c42f75bf4d 100644 --- a/lib/ruby_vm/mjit/compiler.rb +++ b/lib/ruby_vm/mjit/compiler.rb @@ -1,6 +1,14 @@ +require 'mjit/x86_64/assembler' + class RubyVM::MJIT::Compiler - C = RubyVM::MJIT.const_get(:C, false) - INSNS = RubyVM::MJIT.const_get(:INSNS, false) + # MJIT internals + Assembler = RubyVM::MJIT::Assembler + C = RubyVM::MJIT::C + + # Ruby constants + Qundef = Fiddle::Qundef + + attr_accessor :write_pos # @param mem_block [Integer] JIT buffer address def initialize(mem_block) @@ -10,6 +18,16 @@ class RubyVM::MJIT::Compiler # @param iseq [RubyVM::MJIT::CPointer::Struct] def compile(iseq) - # TODO: implement + return if iseq.body.location.label == '
' + + iseq.body.jit_func = write_addr + asm = Assembler.new + asm.mov(:eax, Qundef) + asm.ret + asm.compile(self) + end + + def write_addr + @mem_block + @write_pos end end -- cgit v1.2.3