EmitCx::arena_slot remembered the slot where it was first asked for.
dispatch::emit_entry asks in the entry hooks, after the floor's tail
guard (push::emit_tail_guard) closed a construct, and the memo keeps an
entry only where it was made in the entry block, the block the hooks
end in or the open block's spine: a later hook construct leaves the
slot behind, and every block that reaches the arena derives it again
(24 instructions each). Lane ksizeread counted 2,965 such derivations
in the 780M library's 628,489-weight kernel.
- The slot is now made in the function's first block wherever it is
first asked for (FunctionBuilder::in_entry_block, remembered at
entry): its operands are the pushed arena address load_push_fields
loads there, the invocation's built-ins and constants.
- The entry block is recorded before the hooks run (begin_hooks), so a
hook after the tail guard's construct recalls the push fields the
first block loaded instead of loading them again.
- The tail guard reads the tail field from that same load where the
function reads the field from its member (EmitCx::derives names the
fields a function derives elsewhere); the tail word, and a derived
field, are still loaded by the guard.
Test: tests/engine_device_arena.rs, an owned kernel whose 7176-word
arena is reached in four blocks. On every identity profile, with the
default inputs and with partial_threadgroups, the slot is derived once
and each push member is loaded once. Without this change, on the same
kernel at 0429ff1bd4 (m3-max-64752), one member was loaded twice by
default and one three times with partial threadgroups; the slot was
derived once there, so the kernel does not reproduce the re-derivation
the 628,489 kernel shows.