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:
parent
066e9a8b4a
commit
1f89414c20
6 changed files with 16 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -33,3 +33,4 @@
|
|||
|
||||
#undef GET_INSN_NAME
|
||||
|
||||
ASSERT_VM_INSTRUCTION_SIZE(unified_insns_data);
|
||||
|
|
|
@ -16,3 +16,4 @@ static const void *const insns_address_table[] = {
|
|||
<%= insns_table %>
|
||||
};
|
||||
|
||||
ASSERT_VM_INSTRUCTION_SIZE(insns_address_table);
|
||||
|
|
Loading…
Add table
Reference in a new issue