From 62ec621f8c7457374d1f08aec97138ac1b7bdf2a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 18 Sep 2022 14:16:08 +0900 Subject: Preserve the directory structure under tool/ruby_vm/views for nested target directories --- tool/ruby_vm/helpers/dumper.rb | 3 +- tool/ruby_vm/views/instruction.rb.erb | 40 -------------------------- tool/ruby_vm/views/lib/mjit/instruction.rb.erb | 40 ++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 41 deletions(-) delete mode 100644 tool/ruby_vm/views/instruction.rb.erb create mode 100644 tool/ruby_vm/views/lib/mjit/instruction.rb.erb (limited to 'tool/ruby_vm') diff --git a/tool/ruby_vm/helpers/dumper.rb b/tool/ruby_vm/helpers/dumper.rb index 7aec9c7631..c4294e1b3e 100644 --- a/tool/ruby_vm/helpers/dumper.rb +++ b/tool/ruby_vm/helpers/dumper.rb @@ -25,10 +25,11 @@ class RubyVM::Dumper end def new_erb spec + srcdir = Pathname.new(__dir__).parent.parent.parent path = Pathname.new(__FILE__) path = (path.relative_path_from(Pathname.pwd) rescue path).dirname path += '../views' - path += File.basename(spec) + path += Pathname.pwd.join(spec).to_s.sub("#{srcdir}/", '') src = path.read mode: 'rt:utf-8:utf-8' rescue Errno::ENOENT raise "don't know how to generate #{path}" diff --git a/tool/ruby_vm/views/instruction.rb.erb b/tool/ruby_vm/views/instruction.rb.erb deleted file mode 100644 index 1c462de53a..0000000000 --- a/tool/ruby_vm/views/instruction.rb.erb +++ /dev/null @@ -1,40 +0,0 @@ -module RubyVM::MJIT - Instruction = Struct.new( - :name, - :bin, - :len, - :expr, - :declarations, - :preamble, - :opes, - :pops, - :rets, - :always_leaf?, - :leaf_without_check_ints?, - :handles_sp?, - ) - - 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 - expr: <<-EXPR, -<%= insn.expr.expr.dump.sub(/\A"/, '').sub(/"\z/, '').gsub(/\\n/, "\n").gsub(/\\t/, ' ' * 8) %> - EXPR - declarations: <%= insn.declarations.inspect %>, - preamble: <%= insn.preamble.map(&:expr).inspect %>, - opes: <%= insn.opes.inspect %>, - pops: <%= insn.pops.inspect %>, - rets: <%= insn.rets.inspect %>, - always_leaf?: <%= insn.always_leaf? %>, - leaf_without_check_ints?: <%= insn.leaf_without_check_ints? %>, - handles_sp?: <%= insn.handles_sp? %>, - ), -% end - } - - private_constant(*constants) -end if RubyVM::MJIT.enabled? diff --git a/tool/ruby_vm/views/lib/mjit/instruction.rb.erb b/tool/ruby_vm/views/lib/mjit/instruction.rb.erb new file mode 100644 index 0000000000..1c462de53a --- /dev/null +++ b/tool/ruby_vm/views/lib/mjit/instruction.rb.erb @@ -0,0 +1,40 @@ +module RubyVM::MJIT + Instruction = Struct.new( + :name, + :bin, + :len, + :expr, + :declarations, + :preamble, + :opes, + :pops, + :rets, + :always_leaf?, + :leaf_without_check_ints?, + :handles_sp?, + ) + + 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 + expr: <<-EXPR, +<%= insn.expr.expr.dump.sub(/\A"/, '').sub(/"\z/, '').gsub(/\\n/, "\n").gsub(/\\t/, ' ' * 8) %> + EXPR + declarations: <%= insn.declarations.inspect %>, + preamble: <%= insn.preamble.map(&:expr).inspect %>, + opes: <%= insn.opes.inspect %>, + pops: <%= insn.pops.inspect %>, + rets: <%= insn.rets.inspect %>, + always_leaf?: <%= insn.always_leaf? %>, + leaf_without_check_ints?: <%= insn.leaf_without_check_ints? %>, + handles_sp?: <%= insn.handles_sp? %>, + ), +% end + } + + private_constant(*constants) +end if RubyVM::MJIT.enabled? -- cgit v1.2.1