The problem
Improve an unfamiliar Universal Machine implementation without changing its instruction semantics. Frequently accessed runtime state initially relied on higher-overhead container abstractions.
The changes
We progressively moved segment and reusable-ID representations from Hanson sequences to UArrays and then flatter arrays. Consolidating execution paths reduced indirection and improved locality.
A consolidation pass unexpectedly exhausted stack space after moving state into local scope. Allocating the large runtime state on the heap resolved that issue.
Validation
Callgrind identified instruction dispatch as the dominant hot path. Inspection of generated assembly confirmed that the compiler lowered the opcode switch to a jump table and kept frequently used state largely in registers.
The process connected a profiling observation to a representation change, then checked what the compiler actually emitted.
No numeric speedup is claimed here. This was a team project; source remains private in accordance with course policy.