зеркало из https://github.com/github/ruby.git
insns_info.inc.tmpl: share large tablese
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e43fec9a6f
Коммит
8a233a2b0b
|
@ -6,15 +6,18 @@
|
||||||
%# conditions mentioned in the file COPYING are met. Consult the file for
|
%# conditions mentioned in the file COPYING are met. Consult the file for
|
||||||
%# details.
|
%# details.
|
||||||
CONSTFUNC(MAYBE_UNUSED(static int insn_len(VALUE insn)));
|
CONSTFUNC(MAYBE_UNUSED(static int insn_len(VALUE insn)));
|
||||||
|
extern const char rb_vm_insn_len_info[];
|
||||||
|
|
||||||
|
#ifdef RUBY_VM_INSNS_INFO
|
||||||
|
const char rb_vm_insn_len_info[] = {
|
||||||
|
% RubyVM::Instructions.each_slice 25 do |a|
|
||||||
|
<%= a.map(&:width).join(', ') -%>,
|
||||||
|
% end
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
insn_len(VALUE i)
|
insn_len(VALUE i)
|
||||||
{
|
{
|
||||||
static const char t[] = {
|
return rb_vm_insn_len_info[i];
|
||||||
% RubyVM::Instructions.each_slice 16 do |a|
|
|
||||||
<%= a.map(&:width).join(', ') -%>,
|
|
||||||
% end
|
|
||||||
};
|
|
||||||
|
|
||||||
return t[i];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,31 +12,36 @@
|
||||||
% 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;
|
||||||
|
extern const unsigned short rb_vm_insn_name_offset[];
|
||||||
|
|
||||||
const char *
|
#ifdef RUBY_VM_INSNS_INFO
|
||||||
insn_name(VALUE i)
|
const unsigned short rb_vm_insn_name_offset[] = {
|
||||||
{
|
|
||||||
static const unsigned short o[] = {
|
|
||||||
% c.each_slice 12 do |d|
|
% c.each_slice 12 do |d|
|
||||||
<%= d.map {|i| sprintf("%4d", i) }.join(', ') %>,
|
<%= d.map {|i| sprintf("%4d", i) }.join(', ') %>,
|
||||||
% end
|
% end
|
||||||
};
|
};
|
||||||
|
ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_name_offset);
|
||||||
|
|
||||||
PACKED_STRUCT(static const struct {
|
PACKED_STRUCT(struct rb_vm_insn_name_info_tag {
|
||||||
% b.each_slice 3 do |d|
|
% b.each_slice 3 do |d|
|
||||||
<%= d.map {|i|
|
<%= d.map {|i|
|
||||||
sprintf("const char L%03d[%2d]", i, a[i].length + 1)
|
sprintf("const char L%03d[%2d]", i, a[i].length + 1)
|
||||||
}.join('; ') %>;
|
}.join('; ') %>;
|
||||||
% end
|
% end
|
||||||
|
});
|
||||||
|
|
||||||
}) t = {
|
static const struct rb_vm_insn_name_info_tag rb_vm_insn_name_base = {
|
||||||
% a.each_slice 2 do |d|
|
% a.each_slice 2 do |d|
|
||||||
<%= d.map {|i| sprintf("%-30s", cstr(i)) }.join(', ') %>,
|
<%= d.map {|i| sprintf("%-30s", cstr(i)) }.join(', ') %>,
|
||||||
% end
|
% end
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_VM_INSTRUCTION_SIZE(o);
|
const char *rb_vm_insn_name_info = (const char *)&rb_vm_insn_name_base;
|
||||||
static const char *p = (const char *)&t;
|
#endif
|
||||||
|
|
||||||
return &p[o[i]];
|
const char *
|
||||||
|
insn_name(VALUE i)
|
||||||
|
{
|
||||||
|
return &rb_vm_insn_name_info[rb_vm_insn_name_offset[i]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,35 +11,40 @@
|
||||||
% c = a.inject([0]) {|r, i| r << (r[-1] + i.length + 1) }
|
% c = a.inject([0]) {|r, i| r << (r[-1] + i.length + 1) }
|
||||||
% c.pop
|
% c.pop
|
||||||
%
|
%
|
||||||
MAYBE_UNUSED(static const char *insn_op_types(VALUE insn));
|
CONSTFUNC(MAYBE_UNUSED(static const char *insn_op_types(VALUE insn)));
|
||||||
MAYBE_UNUSED(static int insn_op_type(VALUE insn, long pos));
|
CONSTFUNC(MAYBE_UNUSED(static int insn_op_type(VALUE insn, long pos)));
|
||||||
|
extern const char *rb_vm_insn_op_info;
|
||||||
|
extern const unsigned short rb_vm_insn_op_offset[];
|
||||||
|
|
||||||
const char *
|
#ifdef RUBY_VM_INSNS_INFO
|
||||||
insn_op_types(VALUE i)
|
const unsigned short rb_vm_insn_op_offset[] = {
|
||||||
{
|
|
||||||
static const unsigned short o[] = {
|
|
||||||
% c.each_slice 14 do |d|
|
% c.each_slice 14 do |d|
|
||||||
<%= d.map {|i| sprintf("%3d", i) }.join(', ') %>,
|
<%= d.map {|i| sprintf("%3d", i) }.join(', ') %>,
|
||||||
% end
|
% end
|
||||||
};
|
};
|
||||||
|
ASSERT_VM_INSTRUCTION_SIZE(rb_vm_insn_op_offset);
|
||||||
|
|
||||||
PACKED_STRUCT(static const struct {
|
PACKED_STRUCT(struct rb_vm_insn_op_info_tag {
|
||||||
% b.each_slice 3 do |d|
|
% b.each_slice 3 do |d|
|
||||||
<%= d.map {|i|
|
<%= d.map {|i|
|
||||||
sprintf("const char L%03d[%2d]", i, a[i].length + 1)
|
sprintf("const char L%03d[%2d]", i, a[i].length + 1)
|
||||||
}.join('; ') %>;
|
}.join('; ') %>;
|
||||||
% end
|
% end
|
||||||
|
});
|
||||||
|
|
||||||
}) t = {
|
static const struct rb_vm_insn_op_info_tag rb_vm_insn_op_base = {
|
||||||
% a.each_slice 8 do |d|
|
% a.each_slice 8 do |d|
|
||||||
<%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(', ') %>,
|
<%= d.map {|i| sprintf("%-6s", cstr(i)) }.join(', ') %>,
|
||||||
% end
|
% end
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_VM_INSTRUCTION_SIZE(o);
|
const char *rb_vm_insn_op_info = (const char *)&rb_vm_insn_op_base;
|
||||||
static const char *p = (const char *)&t;
|
#endif
|
||||||
|
|
||||||
return &p[o[i]];
|
const char *
|
||||||
|
insn_op_types(VALUE i)
|
||||||
|
{
|
||||||
|
return &rb_vm_insn_op_info[rb_vm_insn_op_offset[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Загрузка…
Ссылка в новой задаче