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

ruby-changes:49473

From: nobu <ko1@a...>
Date: Thu, 4 Jan 2018 10:30:25 +0900 (JST)
Subject: [ruby-changes:49473] nobu:r61589 (trunk): insns_info.inc: position independent

nobu	2018-01-04 10:30:20 +0900 (Thu, 04 Jan 2018)

  New Revision: 61589

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

  Log:
    insns_info.inc: position independent
    
    * template/insns_info.inc.tmpl (insn_name_info): make position
      independent for large strings.

  Modified files:
    trunk/template/insns_info.inc.tmpl
Index: template/insns_info.inc.tmpl
===================================================================
--- template/insns_info.inc.tmpl	(revision 61588)
+++ template/insns_info.inc.tmpl	(revision 61589)
@@ -13,13 +13,6 @@ https://github.com/ruby/ruby/blob/trunk/template/insns_info.inc.tmpl#L13
 #define <%=t%> '<%=c%>'
 % end
 
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
-static const char *insn_name_info[] = {
-% @insns.each do |insn|
-    "<%= insn.name %>",
-% end
-};
-#else
 static const unsigned short insn_name_info_offset[] = {
 % insn_name_length = @insns.inject(0) do |ofs, insn|
     <%= ofs %>,
@@ -29,14 +22,17 @@ static const unsigned short insn_name_in https://github.com/ruby/ruby/blob/trunk/template/insns_info.inc.tmpl#L22
 
 ASSERT_VM_INSTRUCTION_SIZE(insn_name_info_offset);
 
-static const char insn_name_info_base[<%=insn_name_length%>] = ""
+static const struct {
+% @insns.each_with_index do |insn, i|
+    char L<%=i%>[<%= insn.name.size+1 %>];
+% end
+} insn_name_info_base = {
 % @insns.each do |insn|
-    "<%= insn.name %>\0"
+    "<%= insn.name %>",
 % end
-;
+};
 
-#define insn_name_info insn_name_info_base+insn_name_info_offset
-#endif
+#define insn_name_info insn_name_info_base.L0+insn_name_info_offset
 
 static const char insn_operand_info[][8] = {
 % @insns.each do |insn|

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

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