diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-22 03:07:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-22 03:07:01 +0000 |
commit | 1f89414c20edbe0b36fac7351917f401ccee63a1 (patch) | |
tree | ac09286c71c8630484367b47934a99a0631fac50 /template | |
parent | 066e9a8b4ac36907f8e7915b5f94fdc7ca851de0 (diff) | |
download | bundler-1f89414c20edbe0b36fac7351917f401ccee63a1.tar.gz |
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
Diffstat (limited to 'template')
-rw-r--r-- | template/insns.inc.tmpl | 2 | ||||
-rw-r--r-- | template/insns_info.inc.tmpl | 8 | ||||
-rw-r--r-- | template/opt_sc.inc.tmpl | 3 | ||||
-rw-r--r-- | template/optunifs.inc.tmpl | 1 | ||||
-rw-r--r-- | template/vmtc.inc.tmpl | 1 |
5 files changed, 15 insertions, 0 deletions
diff --git a/template/insns.inc.tmpl b/template/insns.inc.tmpl index 203273f92b..13b6cb9638 100644 --- a/template/insns.inc.tmpl +++ b/template/insns.inc.tmpl @@ -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) diff --git a/template/insns_info.inc.tmpl b/template/insns_info.inc.tmpl index 14b4ef50ab..c7f0094a7a 100644 --- a/template/insns_info.inc.tmpl +++ b/template/insns_info.inc.tmpl @@ -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 diff --git a/template/opt_sc.inc.tmpl b/template/opt_sc.inc.tmpl index 41492b2bb6..4c85f96c0f 100644 --- a/template/opt_sc.inc.tmpl +++ b/template/opt_sc.inc.tmpl @@ -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); diff --git a/template/optunifs.inc.tmpl b/template/optunifs.inc.tmpl index af313a9b45..63ac4d85ca 100644 --- a/template/optunifs.inc.tmpl +++ b/template/optunifs.inc.tmpl @@ -33,3 +33,4 @@ #undef GET_INSN_NAME +ASSERT_VM_INSTRUCTION_SIZE(unified_insns_data); diff --git a/template/vmtc.inc.tmpl b/template/vmtc.inc.tmpl index 5f1f51a08b..3d9935dcaa 100644 --- a/template/vmtc.inc.tmpl +++ b/template/vmtc.inc.tmpl @@ -16,3 +16,4 @@ static const void *const insns_address_table[] = { <%= insns_table %> }; +ASSERT_VM_INSTRUCTION_SIZE(insns_address_table); |