summaryrefslogtreecommitdiff
path: root/lib/ruby_vm
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2022-12-30 22:05:53 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 22:11:20 -0800
commit7abff797b434ead0653c89f5429490bd0f716f88 (patch)
treec3c73a306fa2b00d981ce0f5f4170e2f9a0859fc /lib/ruby_vm
parentc51baf9404373c8cb37a1fb887c50c0216576186 (diff)
Use the term "compile" in different places
Diffstat (limited to 'lib/ruby_vm')
-rw-r--r--lib/ruby_vm/mjit/code_block.rb4
-rw-r--r--lib/ruby_vm/mjit/compiler.rb4
-rw-r--r--lib/ruby_vm/mjit/x86_assembler.rb14
3 files changed, 15 insertions, 7 deletions
diff --git a/lib/ruby_vm/mjit/code_block.rb b/lib/ruby_vm/mjit/code_block.rb
index e47f5fbc0a..17e2a0053d 100644
--- a/lib/ruby_vm/mjit/code_block.rb
+++ b/lib/ruby_vm/mjit/code_block.rb
@@ -10,14 +10,14 @@ module RubyVM::MJIT
end
# @param asm [RubyVM::MJIT::X86Assembler]
- def compile(asm)
+ def write(asm)
return 0 if @write_pos + asm.size >= @mem_size
start_addr = write_addr
# Write machine code
C.mjit_mark_writable
- @write_pos += asm.compile(start_addr)
+ @write_pos += asm.assemble(start_addr)
C.mjit_mark_executable
end_addr = write_addr
diff --git a/lib/ruby_vm/mjit/compiler.rb b/lib/ruby_vm/mjit/compiler.rb
index c5a7380226..f872c05bce 100644
--- a/lib/ruby_vm/mjit/compiler.rb
+++ b/lib/ruby_vm/mjit/compiler.rb
@@ -37,7 +37,7 @@ module RubyVM::MJIT
end
# @param iseq [RubyVM::MJIT::CPointer::Struct]
- def call(iseq)
+ def compile(iseq)
# TODO: Support 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}")
compile_prologue(asm)
compile_block(asm, iseq)
- iseq.body.jit_func = @cb.compile(asm)
+ iseq.body.jit_func = @cb.write(asm)
rescue Exception => e
$stderr.puts e.full_message # TODO: check verbose
end
diff --git a/lib/ruby_vm/mjit/x86_assembler.rb b/lib/ruby_vm/mjit/x86_assembler.rb
index 11f99cc78d..9856d4e4ac 100644
--- a/lib/ruby_vm/mjit/x86_assembler.rb
+++ b/lib/ruby_vm/mjit/x86_assembler.rb
@@ -10,8 +10,6 @@ module RubyVM::MJIT
# REX = 0100WR0B
REX_W = 0b01001000
- attr_reader :comments
-
def initialize
@bytes = []
@labels = {}
@@ -19,7 +17,7 @@ module RubyVM::MJIT
@comments = Hash.new { |h, k| h[k] = [] }
end
- def compile(addr)
+ def assemble(addr)
link_labels
writer = ByteWriter.new(addr)
# If you pack bytes containing \x00, Ruby fails to recognize bytes after \x00.
@@ -36,6 +34,10 @@ module RubyVM::MJIT
@bytes.size
end
+ #
+ # Instructions
+ #
+
def add(dst, src)
case [dst, src]
# ADD r/m64, imm8 (Mod 11)
@@ -228,6 +230,12 @@ module RubyVM::MJIT
end
end
+ #
+ # Utilities
+ #
+
+ attr_reader :comments
+
def comment(message)
@comments[@bytes.size] << message
end