From 14acf9b0a3c5c06cd8a1bf60c929b25c6e7fee66 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 10 Feb 2023 17:41:59 -0800 Subject: [PATCH] Decode trace insns properly --- mjit_c.rb | 5 +++-- tool/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mjit_c.rb b/mjit_c.rb index 6208e4772f..4b8aeaed9f 100644 --- a/mjit_c.rb +++ b/mjit_c.rb @@ -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. diff --git a/tool/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb b/tool/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb index 38b9c1f92e..16c10a9928 100644 --- a/tool/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb +++ b/tool/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb @@ -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 }