Decode trace insns properly

This commit is contained in:
Takashi Kokubun 2023-02-10 17:41:59 -08:00
parent b30392f8ab
commit 14acf9b0a3
2 changed files with 5 additions and 3 deletions

View File

@ -268,9 +268,10 @@ module RubyVM::MJIT # :nodoc: all
}
end
# Convert encoded VM pointers to insn BINs.
# Convert an encoded VM pointer to an insn BIN.
def rb_vm_insn_decode(encoded)
Primitive.cexpr! 'INT2NUM(rb_vm_insn_decode(NUM2PTR(encoded)))'
# Using rb_vm_insn_addr2opcode to return trace_ insns
Primitive.cexpr! 'INT2NUM(rb_vm_insn_addr2opcode((void *)NUM2PTR(encoded)))'
end
# Convert insn BINs to encoded VM pointers. This one is not used by the compiler, but useful for debugging.

View File

@ -16,11 +16,11 @@ module RubyVM::MJIT # :nodoc: all
INSNS = {
% RubyVM::Instructions.each_with_index do |insn, i|
% next if insn.name.start_with?('trace_')
<%= i %> => Instruction.new(
name: :<%= insn.name %>,
bin: <%= i %>, # BIN(<%= insn.name %>)
len: <%= insn.width %>, # insn_len
% unless insn.name.start_with?('trace_')
expr: <<-EXPR,
<%= insn.expr.expr.dump.sub(/\A"/, '').sub(/"\z/, '').gsub(/\\n/, "\n").gsub(/\\t/, ' ' * 8) %>
EXPR
@ -32,6 +32,7 @@ module RubyVM::MJIT # :nodoc: all
always_leaf?: <%= insn.always_leaf? %>,
leaf_without_check_ints?: <%= insn.leaf_without_check_ints? %>,
handles_sp?: <%= insn.handles_sp? %>,
% end
),
% end
}