diff --git a/tool/ruby_vm/views/_insn_len_info.erb b/tool/ruby_vm/views/_insn_len_info.erb index b292f42fb5..569dca5845 100644 --- a/tool/ruby_vm/views/_insn_len_info.erb +++ b/tool/ruby_vm/views/_insn_len_info.erb @@ -7,15 +7,22 @@ %# details. CONSTFUNC(MAYBE_UNUSED(static int insn_len(VALUE insn))); +RUBY_SYMBOL_EXPORT_BEGIN /* for debuggers */ +extern const uint8_t rb_vm_insn_len_info[VM_INSTRUCTION_SIZE]; +RUBY_SYMBOL_EXPORT_END + +#ifdef RUBY_VM_INSNS_INFO +const uint8_t rb_vm_insn_len_info[] = { +% RubyVM::Instructions.each_slice 23 do |a| + <%= a.map(&:width).join(', ') -%>, +% end +}; + +ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_len_info); +#endif + int insn_len(VALUE i) { - static const char t[] = { -% RubyVM::Instructions.each_slice 23 do |a| - <%= a.map(&:width).join(', ') -%>, -% end - }; - - ASSERT_VM_INSTRUCTION_SIZE(t); - return t[i]; + return rb_vm_insn_len_info[i]; } diff --git a/tool/ruby_vm/views/_insn_name_info.erb b/tool/ruby_vm/views/_insn_name_info.erb index 767346093e..e7ded75e65 100644 --- a/tool/ruby_vm/views/_insn_name_info.erb +++ b/tool/ruby_vm/views/_insn_name_info.erb @@ -13,26 +13,32 @@ % CONSTFUNC(MAYBE_UNUSED(static const char *insn_name(VALUE insn))); +RUBY_SYMBOL_EXPORT_BEGIN /* for debuggers */ +extern const int rb_vm_max_insn_name_size; +extern const char rb_vm_insn_name_base[]; +extern const unsigned short rb_vm_insn_name_offset[VM_INSTRUCTION_SIZE]; +RUBY_SYMBOL_EXPORT_END + #ifdef RUBY_VM_INSNS_INFO const int rb_vm_max_insn_name_size = <%= a.map(&:size).max %>; + +const char rb_vm_insn_name_base[] = +% a.each do |i| + <%=cstr i%> "\0" +% end + ; + +const unsigned short rb_vm_insn_name_offset[] = { +% c.each_slice 12 do |d| + <%= d.map {|i| sprintf("%4d", i) }.join(', ') %>, +% end +}; + +ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_name_offset); #endif const char * insn_name(VALUE i) { - static const char x[] = -% a.each do |i| - <%=cstr i%> "\0" -% end - ; - - static const unsigned short y[] = { -% c.each_slice 12 do |d| - <%= d.map {|i| sprintf("%4d", i) }.join(', ') %>, -% end - }; - - ASSERT_VM_INSTRUCTION_SIZE(y); - - return &x[y[i]]; + return &rb_vm_insn_name_base[rb_vm_insn_name_offset[i]]; } diff --git a/tool/ruby_vm/views/_insn_operand_info.erb b/tool/ruby_vm/views/_insn_operand_info.erb index 69d361521a..996c33e960 100644 --- a/tool/ruby_vm/views/_insn_operand_info.erb +++ b/tool/ruby_vm/views/_insn_operand_info.erb @@ -14,24 +14,31 @@ CONSTFUNC(MAYBE_UNUSED(static const char *insn_op_types(VALUE insn))); CONSTFUNC(MAYBE_UNUSED(static int insn_op_type(VALUE insn, long pos))); +RUBY_SYMBOL_EXPORT_BEGIN /* for debuggers */ +extern const char rb_vm_insn_op_base[]; +extern const unsigned short rb_vm_insn_op_offset[VM_INSTRUCTION_SIZE]; +RUBY_SYMBOL_EXPORT_END + +#ifdef RUBY_VM_INSNS_INFO +const char rb_vm_insn_op_base[] = +% a.each_slice 5 do |d| + <%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(' "\0" ') %> "\0" +% end + ; + +const unsigned short rb_vm_insn_op_offset[] = { +% c.each_slice 12 do |d| + <%= d.map {|i| sprintf("%3d", i) }.join(', ') %>, +% end +}; + +ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_op_offset); +#endif + const char * insn_op_types(VALUE i) { - static const char x[] = -% a.each_slice 5 do |d| - <%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(' "\0" ') %> "\0" -% end - ; - - static const unsigned short y[] = { -% c.each_slice 12 do |d| - <%= d.map {|i| sprintf("%3d", i) }.join(', ') %>, -% end - }; - - ASSERT_VM_INSTRUCTION_SIZE(y); - - return &x[y[i]]; + return &rb_vm_insn_op_base[rb_vm_insn_op_offset[i]]; } int