ruby-changes:47519
From: nobu <ko1@a...>
Date: Tue, 22 Aug 2017 12:07:11 +0900 (JST)
Subject: [ruby-changes:47519] nobu:r59635 (trunk): insns.inc.tmpl: ensure info size
nobu 2017-08-22 12:07:01 +0900 (Tue, 22 Aug 2017) New Revision: 59635 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59635 Log: insns.inc.tmpl: ensure info size * template/insns.inc.tmpl (ASSERT_VM_INSTRUCTION_SIZE): static assertion for VM instruction info tables. Modified files: trunk/compile.c trunk/template/insns.inc.tmpl trunk/template/insns_info.inc.tmpl trunk/template/opt_sc.inc.tmpl trunk/template/optunifs.inc.tmpl trunk/template/vmtc.inc.tmpl Index: compile.c =================================================================== --- compile.c (revision 59634) +++ compile.c (revision 59635) @@ -6737,7 +6737,7 @@ rb_insns_name_array(void) https://github.com/ruby/ruby/blob/trunk/compile.c#L6737 { VALUE ary = rb_ary_new(); int i; - for (i = 0; i < numberof(insn_name_info); i++) { + for (i = 0; i < VM_INSTRUCTION_SIZE; i++) { rb_ary_push(ary, rb_fstring_cstr(insn_name_info[i])); } return rb_obj_freeze(ary); Index: template/insns_info.inc.tmpl =================================================================== --- template/insns_info.inc.tmpl (revision 59634) +++ template/insns_info.inc.tmpl (revision 59635) @@ -15,18 +15,26 @@ static const char *const insn_name_info[ https://github.com/ruby/ruby/blob/trunk/template/insns_info.inc.tmpl#L15 <%= insn_names %> }; +ASSERT_VM_INSTRUCTION_SIZE(insn_name_info); + static const char *const insn_operand_info[] = { <%= operands_info %> }; +ASSERT_VM_INSTRUCTION_SIZE(insn_operand_info); + static const int insn_len_info[] = { <%= operands_num_info %> }; +ASSERT_VM_INSTRUCTION_SIZE(insn_len_info); + #ifdef USE_INSN_RET_NUM static const int insn_stack_push_num_info[] = { <%= stack_num_info %> }; + +ASSERT_VM_INSTRUCTION_SIZE(insn_stack_push_num_info); #endif #ifdef USE_INSN_STACK_INCREASE Index: template/optunifs.inc.tmpl =================================================================== --- template/optunifs.inc.tmpl (revision 59634) +++ template/optunifs.inc.tmpl (revision 59635) @@ -33,3 +33,4 @@ https://github.com/ruby/ruby/blob/trunk/template/optunifs.inc.tmpl#L33 #undef GET_INSN_NAME +ASSERT_VM_INSTRUCTION_SIZE(unified_insns_data); Index: template/vmtc.inc.tmpl =================================================================== --- template/vmtc.inc.tmpl (revision 59634) +++ template/vmtc.inc.tmpl (revision 59635) @@ -16,3 +16,4 @@ static const void *const insns_address_t https://github.com/ruby/ruby/blob/trunk/template/vmtc.inc.tmpl#L16 <%= insns_table %> }; +ASSERT_VM_INSTRUCTION_SIZE(insns_address_table); Index: template/opt_sc.inc.tmpl =================================================================== --- template/opt_sc.inc.tmpl (revision 59634) +++ template/opt_sc.inc.tmpl (revision 59635) @@ -26,7 +26,10 @@ static const VALUE sc_insn_info[][SC_STA https://github.com/ruby/ruby/blob/trunk/template/opt_sc.inc.tmpl#L26 <%= sc_insn_info %> }; +ASSERT_VM_INSTRUCTION_SIZE(sc_insn_info); + static const VALUE sc_insn_next[] = { <%= sc_insn_next %> }; +ASSERT_VM_INSTRUCTION_SIZE(sc_insn_next); Index: template/insns.inc.tmpl =================================================================== --- template/insns.inc.tmpl (revision 59634) +++ template/insns.inc.tmpl (revision 59635) @@ -18,3 +18,5 @@ enum ruby_vminsn_type { https://github.com/ruby/ruby/blob/trunk/template/insns.inc.tmpl#L18 VM_INSTRUCTION_SIZE = <%= @insns.size %> }; +#define ASSERT_VM_INSTRUCTION_SIZE(array) \ + STATIC_ASSERT(numberof_##array, numberof(array) == VM_INSTRUCTION_SIZE) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/