[前][次][番号順一覧][スレッド一覧]

ruby-changes:54740

From: shyouhei <ko1@a...>
Date: Thu, 31 Jan 2019 13:46:08 +0900 (JST)
Subject: [ruby-changes:54740] shyouhei:r66957 (trunk): _insn_name_info.erb: use C99

shyouhei	2019-01-31 13:46:03 +0900 (Thu, 31 Jan 2019)

  New Revision: 66957

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66957

  Log:
    _insn_name_info.erb: use C99
    
    C99 allows string literals of at least 4095 characters (cf: ISO/IEC
    9899:1999 section 5.2.4.1) so the previous complex struct layout is no
    longer necessary.  Just dump the verbatim memory contents we want.

  Modified files:
    trunk/tool/ruby_vm/views/_insn_name_info.erb
Index: tool/ruby_vm/views/_insn_name_info.erb
===================================================================
--- tool/ruby_vm/views/_insn_name_info.erb	(revision 66956)
+++ tool/ruby_vm/views/_insn_name_info.erb	(revision 66957)
@@ -12,39 +12,27 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_insn_name_info.erb#L12
 % c.pop
 %
 CONSTFUNC(MAYBE_UNUSED(static const char *insn_name(VALUE insn)));
-extern const char *rb_vm_insn_name_info;
-MJIT_SYMBOL_EXPORT_BEGIN
-extern const unsigned short rb_vm_insn_name_offset[];
-MJIT_SYMBOL_EXPORT_END
 
 #ifdef RUBY_VM_INSNS_INFO
-const unsigned short rb_vm_insn_name_offset[] = {
-% c.each_slice 12 do |d|
-    <%= d.map {|i| sprintf("%4d", i) }.join(', ') %>,
-% end
-};
-const int rb_vm_max_insn_name_size = <%= RubyVM::Instructions.map {|i| i.name.size }.max %>;
-ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_name_offset);
+const int rb_vm_max_insn_name_size = <%= a.map(&:size).max %>;
+#endif
 
-PACKED_STRUCT(struct rb_vm_insn_name_info_tag {
-% b.each_slice 3 do |d|
-    <%= d.map {|i|
-        sprintf("const char L%03d[%2d]", i, a[i].length + 1)
-    }.join('; ') %>;
+const char *
+insn_name(VALUE i)
+{
+    static const char x[] =
+% a.each do |i|
+        <%=cstr i%> "\0"
 % end
-});
+        ;
 
-static const struct rb_vm_insn_name_info_tag rb_vm_insn_name_base = {
-% a.each_slice 2 do |d|
-    <%= d.map {|i| sprintf("%-30s", cstr(i)) }.join(', ') %>,
+    static const unsigned short y[] = {
+% c.each_slice 12 do |d|
+        <%= d.map {|i| sprintf("%4d", i) }.join(', ') %>,
 % end
-};
+    };
 
-const char *rb_vm_insn_name_info = (const char *)&rb_vm_insn_name_base;
-#endif
+    ASSERT_VM_INSTRUCTION_SIZE(y);
 
-const char *
-insn_name(VALUE i)
-{
-    return &rb_vm_insn_name_info[rb_vm_insn_name_offset[i]];
+    return &x[y[i]];
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]