mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
Implement a no-op JIT compiler
This commit is contained in:
parent
baa120ee80
commit
fd04e1b4db
6 changed files with 97 additions and 18 deletions
|
@ -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 == '<main>'
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue