1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

insns.inc.tmpl: ensure info size

* template/insns.inc.tmpl (ASSERT_VM_INSTRUCTION_SIZE): static
  assertion for VM instruction info tables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-08-22 03:07:01 +00:00
parent 066e9a8b4a
commit 1f89414c20
6 changed files with 16 additions and 1 deletions

View file

@ -6737,7 +6737,7 @@ rb_insns_name_array(void)
{
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);

View file

@ -18,3 +18,5 @@ enum ruby_vminsn_type {
VM_INSTRUCTION_SIZE = <%= @insns.size %>
};
#define ASSERT_VM_INSTRUCTION_SIZE(array) \
STATIC_ASSERT(numberof_##array, numberof(array) == VM_INSTRUCTION_SIZE)

View file

@ -15,18 +15,26 @@ static const char *const insn_name_info[] = {
<%= 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

View file

@ -26,7 +26,10 @@ static const VALUE sc_insn_info[][SC_STATE_SIZE] = {
<%= 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);

View file

@ -33,3 +33,4 @@
#undef GET_INSN_NAME
ASSERT_VM_INSTRUCTION_SIZE(unified_insns_data);

View file

@ -16,3 +16,4 @@ static const void *const insns_address_table[] = {
<%= insns_table %>
};
ASSERT_VM_INSTRUCTION_SIZE(insns_address_table);