mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
Use the term "compile" in different places
This commit is contained in:
parent
c51baf9404
commit
7abff797b4
4 changed files with 16 additions and 8 deletions
|
@ -10,14 +10,14 @@ module RubyVM::MJIT
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param asm [RubyVM::MJIT::X86Assembler]
|
# @param asm [RubyVM::MJIT::X86Assembler]
|
||||||
def compile(asm)
|
def write(asm)
|
||||||
return 0 if @write_pos + asm.size >= @mem_size
|
return 0 if @write_pos + asm.size >= @mem_size
|
||||||
|
|
||||||
start_addr = write_addr
|
start_addr = write_addr
|
||||||
|
|
||||||
# Write machine code
|
# Write machine code
|
||||||
C.mjit_mark_writable
|
C.mjit_mark_writable
|
||||||
@write_pos += asm.compile(start_addr)
|
@write_pos += asm.assemble(start_addr)
|
||||||
C.mjit_mark_executable
|
C.mjit_mark_executable
|
||||||
|
|
||||||
end_addr = write_addr
|
end_addr = write_addr
|
||||||
|
|
|
@ -37,7 +37,7 @@ module RubyVM::MJIT
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param iseq [RubyVM::MJIT::CPointer::Struct]
|
# @param iseq [RubyVM::MJIT::CPointer::Struct]
|
||||||
def call(iseq)
|
def compile(iseq)
|
||||||
# TODO: Support has_opt
|
# TODO: Support has_opt
|
||||||
return if iseq.body.param.flags.has_opt
|
return if iseq.body.param.flags.has_opt
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ module RubyVM::MJIT
|
||||||
asm.comment("Block: #{iseq.body.location.label}@#{pathobj_path(iseq.body.location.pathobj)}:#{iseq.body.location.first_lineno}")
|
asm.comment("Block: #{iseq.body.location.label}@#{pathobj_path(iseq.body.location.pathobj)}:#{iseq.body.location.first_lineno}")
|
||||||
compile_prologue(asm)
|
compile_prologue(asm)
|
||||||
compile_block(asm, iseq)
|
compile_block(asm, iseq)
|
||||||
iseq.body.jit_func = @cb.compile(asm)
|
iseq.body.jit_func = @cb.write(asm)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
$stderr.puts e.full_message # TODO: check verbose
|
$stderr.puts e.full_message # TODO: check verbose
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,8 +10,6 @@ module RubyVM::MJIT
|
||||||
# REX = 0100WR0B
|
# REX = 0100WR0B
|
||||||
REX_W = 0b01001000
|
REX_W = 0b01001000
|
||||||
|
|
||||||
attr_reader :comments
|
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@bytes = []
|
@bytes = []
|
||||||
@labels = {}
|
@labels = {}
|
||||||
|
@ -19,7 +17,7 @@ module RubyVM::MJIT
|
||||||
@comments = Hash.new { |h, k| h[k] = [] }
|
@comments = Hash.new { |h, k| h[k] = [] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile(addr)
|
def assemble(addr)
|
||||||
link_labels
|
link_labels
|
||||||
writer = ByteWriter.new(addr)
|
writer = ByteWriter.new(addr)
|
||||||
# If you pack bytes containing \x00, Ruby fails to recognize bytes after \x00.
|
# If you pack bytes containing \x00, Ruby fails to recognize bytes after \x00.
|
||||||
|
@ -36,6 +34,10 @@ module RubyVM::MJIT
|
||||||
@bytes.size
|
@bytes.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Instructions
|
||||||
|
#
|
||||||
|
|
||||||
def add(dst, src)
|
def add(dst, src)
|
||||||
case [dst, src]
|
case [dst, src]
|
||||||
# ADD r/m64, imm8 (Mod 11)
|
# ADD r/m64, imm8 (Mod 11)
|
||||||
|
@ -228,6 +230,12 @@ module RubyVM::MJIT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Utilities
|
||||||
|
#
|
||||||
|
|
||||||
|
attr_reader :comments
|
||||||
|
|
||||||
def comment(message)
|
def comment(message)
|
||||||
@comments[@bytes.size] << message
|
@comments[@bytes.size] << message
|
||||||
end
|
end
|
||||||
|
|
2
mjit.c
2
mjit.c
|
@ -334,7 +334,7 @@ rb_mjit_compile(const rb_iseq_t *iseq)
|
||||||
mjit_stats_p = false; // Avoid impacting JIT stats by itself
|
mjit_stats_p = false; // Avoid impacting JIT stats by itself
|
||||||
|
|
||||||
VALUE iseq_ptr = rb_funcall(rb_cMJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq));
|
VALUE iseq_ptr = rb_funcall(rb_cMJITIseqPtr, rb_intern("new"), 1, SIZET2NUM((size_t)iseq));
|
||||||
rb_funcall(rb_MJITCompiler, rb_intern("call"), 1, iseq_ptr);
|
rb_funcall(rb_MJITCompiler, rb_intern("compile"), 1, iseq_ptr);
|
||||||
|
|
||||||
mjit_stats_p = mjit_opts.stats;
|
mjit_stats_p = mjit_opts.stats;
|
||||||
mjit_call_p = original_call_p;
|
mjit_call_p = original_call_p;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue