mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
_insn_name_info.erb: use C99
C99 allows string literals of at least 4095 characters (cf: ISO/IEC 9899:1999 section 5.2.4.1) so the previous complex struct layout is no longer necessary. Just dump the verbatim memory contents we want. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69431818f4
commit
72e318f118
1 changed files with 16 additions and 28 deletions
|
@ -12,39 +12,27 @@
|
||||||
% c.pop
|
% c.pop
|
||||||
%
|
%
|
||||||
CONSTFUNC(MAYBE_UNUSED(static const char *insn_name(VALUE insn)));
|
CONSTFUNC(MAYBE_UNUSED(static const char *insn_name(VALUE insn)));
|
||||||
extern const char *rb_vm_insn_name_info;
|
|
||||||
MJIT_SYMBOL_EXPORT_BEGIN
|
|
||||||
extern const unsigned short rb_vm_insn_name_offset[];
|
|
||||||
MJIT_SYMBOL_EXPORT_END
|
|
||||||
|
|
||||||
#ifdef RUBY_VM_INSNS_INFO
|
#ifdef RUBY_VM_INSNS_INFO
|
||||||
const unsigned short rb_vm_insn_name_offset[] = {
|
const int rb_vm_max_insn_name_size = <%= a.map(&:size).max %>;
|
||||||
% c.each_slice 12 do |d|
|
|
||||||
<%= d.map {|i| sprintf("%4d", i) }.join(', ') %>,
|
|
||||||
% end
|
|
||||||
};
|
|
||||||
const int rb_vm_max_insn_name_size = <%= RubyVM::Instructions.map {|i| i.name.size }.max %>;
|
|
||||||
ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_name_offset);
|
|
||||||
|
|
||||||
PACKED_STRUCT(struct rb_vm_insn_name_info_tag {
|
|
||||||
% b.each_slice 3 do |d|
|
|
||||||
<%= d.map {|i|
|
|
||||||
sprintf("const char L%03d[%2d]", i, a[i].length + 1)
|
|
||||||
}.join('; ') %>;
|
|
||||||
% end
|
|
||||||
});
|
|
||||||
|
|
||||||
static const struct rb_vm_insn_name_info_tag rb_vm_insn_name_base = {
|
|
||||||
% a.each_slice 2 do |d|
|
|
||||||
<%= d.map {|i| sprintf("%-30s", cstr(i)) }.join(', ') %>,
|
|
||||||
% end
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *rb_vm_insn_name_info = (const char *)&rb_vm_insn_name_base;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
insn_name(VALUE i)
|
insn_name(VALUE i)
|
||||||
{
|
{
|
||||||
return &rb_vm_insn_name_info[rb_vm_insn_name_offset[i]];
|
static const char x[] =
|
||||||
|
% a.each do |i|
|
||||||
|
<%=cstr i%> "\0"
|
||||||
|
% end
|
||||||
|
;
|
||||||
|
|
||||||
|
static const unsigned short y[] = {
|
||||||
|
% c.each_slice 12 do |d|
|
||||||
|
<%= d.map {|i| sprintf("%4d", i) }.join(', ') %>,
|
||||||
|
% end
|
||||||
|
};
|
||||||
|
|
||||||
|
ASSERT_VM_INSTRUCTION_SIZE(y);
|
||||||
|
|
||||||
|
return &x[y[i]];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue