Improve packing of iseq_constant_body struct

By moving the two bools into a packing gap above the mark_bits
pointer/union we can save 8 bytes in the struct and avoid an extra cache
line (328 bytes vs 320 bytes).

Co-authored-by: Adam Hess <HParker@github.com>
This commit is contained in:
John Hawthorn 2022-12-01 11:51:18 -08:00
Родитель dcbea7671b
Коммит def258e775
2 изменённых файлов: 8 добавлений и 6 удалений

Просмотреть файл

@ -518,13 +518,13 @@ module RubyVM::MJIT
icvarc_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), icvarc_size)")],
ci_size: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), ci_size)")],
stack_max: [CType::Immediate.parse("unsigned int"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), stack_max)")],
catch_except_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), catch_except_p)")],
builtin_inline_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), builtin_inline_p)")],
mark_bits: [CType::Union.new(
"", Primitive.cexpr!("SIZEOF(((struct rb_iseq_constant_body *)NULL)->mark_bits)"),
list: CType::Pointer.new { self.iseq_bits_t },
single: self.iseq_bits_t,
), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), mark_bits)")],
catch_except_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), catch_except_p)")],
builtin_inline_p: [self._Bool, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), builtin_inline_p)")],
outer_variables: [CType::Pointer.new { self.rb_id_table }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), outer_variables)")],
mandatory_only_iseq: [CType::Pointer.new { self.rb_iseq_t }, Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), mandatory_only_iseq)")],
jit_func: [CType::Immediate.parse("void *"), Primitive.cexpr!("OFFSETOF((*((struct rb_iseq_constant_body *)NULL)), jit_func)")],

Просмотреть файл

@ -483,10 +483,6 @@ struct rb_iseq_constant_body {
unsigned int icvarc_size; // Number of ICVARC caches
unsigned int ci_size;
unsigned int stack_max; /* for stack overflow check */
union {
iseq_bits_t * list; /* Find references for GC */
iseq_bits_t single;
} mark_bits;
bool catch_except_p; // If a frame of this ISeq may catch exception, set true.
// If true, this ISeq is leaf *and* backtraces are not used, for example,
@ -495,6 +491,12 @@ struct rb_iseq_constant_body {
// ObjectSpace#trace_object_allocations.
// For more details, see: https://bugs.ruby-lang.org/issues/16956
bool builtin_inline_p;
union {
iseq_bits_t * list; /* Find references for GC */
iseq_bits_t single;
} mark_bits;
struct rb_id_table *outer_variables;
const rb_iseq_t *mandatory_only_iseq;