summaryrefslogtreecommitdiff
path: root/lib/mjit
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2022-12-26 22:06:43 -0800
committerTakashi Kokubun <[email protected]>2023-03-05 22:11:20 -0800
commit4fe5efbf7f784803f8ac48824f350b6dc91d644c (patch)
treed118d8b82041448d17c6d0b0da27bd802cd97dec /lib/mjit
parent652d63789f5fd37865c5000712236a214ced9fbf (diff)
Implement asm comments
Diffstat (limited to 'lib/mjit')
-rw-r--r--lib/mjit/insn_compiler.rb4
-rw-r--r--lib/mjit/x86_assembler.rb9
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/mjit/insn_compiler.rb b/lib/mjit/insn_compiler.rb
index 8fd8dfcef8..9c3e2f2a95 100644
--- a/lib/mjit/insn_compiler.rb
+++ b/lib/mjit/insn_compiler.rb
@@ -19,14 +19,14 @@ module RubyVM::MJIT
def leave(jit, ctx, asm)
assert_eq!(ctx.stack_size, 1)
- # Check interrupts
+ asm.comment("RUBY_VM_CHECK_INTS(ec)")
asm.mov(:eax, [EC, C.rb_execution_context_t.offsetof(:interrupt_flag)])
asm.test(:eax, :eax)
asm.jz(not_interrupted = asm.new_label(:not_interrupted))
Compiler.compile_exit(jit, ctx, asm) # TODO: use ocb
asm.write_label(not_interrupted)
- # Pop the current frame (ec->cfp++)
+ asm.comment("pop stack frame")
asm.add(CFP, C.rb_control_frame_t.size) # cfp = cfp + 1
asm.mov([EC, C.rb_execution_context_t.offsetof(:cfp)], CFP) # ec->cfp = cfp
diff --git a/lib/mjit/x86_assembler.rb b/lib/mjit/x86_assembler.rb
index 1d010411db..ad194185ae 100644
--- a/lib/mjit/x86_assembler.rb
+++ b/lib/mjit/x86_assembler.rb
@@ -10,10 +10,13 @@ module RubyVM::MJIT
# REX = 0100WR0B
REX_W = 0b01001000
+ attr_reader :comments
+
def initialize
@bytes = []
- @label_id = 0
@labels = {}
+ @label_id = 0
+ @comments = Hash.new { |h, k| h[k] = [] }
end
def compile(addr)
@@ -173,6 +176,10 @@ module RubyVM::MJIT
end
end
+ def comment(message)
+ @comments[@bytes.size] << message
+ end
+
def new_label(name)
Label.new(id: @label_id += 1, name:)
end