cleanup backend memory accessors
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Opinion
|
Low
|
Unassigned |
Bug Description
There's quite a bit of code duplication in several places in the backends:
- Between array accessors and SAP accessors;
- Between various accessors for primitive types.
There's some effort to address these concerns with things like WORD-INDEX-REF, SLOT-SET, CELL-SET, and DEFINE-FULL-REFFER, but we still have a lot of very similar VOPs running about--especially with things like DEFINE-FULL-REFFER. This costs us core size as well as complicating future IR2 optimizers that want to look at memory references etc., since we don't have a uniform set of primitives.
One way to address this would be to introduce something like a MEMORY-REF family of VOPs:
(MEMORY-REF/TYPE BASE INDEX OFFSET LOWTAG)
and similarly for MEMORY-SET. OFFSET and LOWTAG would be constants; OFFSET would be in units of the TYPE being referenced, similar to how the -OFFSET constants generated by primitive type definition work. We could have separate /TYPE variants for all sizes of data (similar to how array accessors are done) or we could have separate /TYPE variants for the storage class of the result datum (this would require adding another parameter describing the size of the result datum). The latter is probably more efficient size-of-
Along with this, there would need to be ir2-convert optimizers for AREF, SAP-REF-X, etc. to expand into MEMORY-{REF,SET} as appropriate.
I don't have time to work on this right now--it's a big project to modify all the backends, but it's not particularly difficult conceptually.
tags: |
added: cleanup removed: cleanups |
Also, bonus points if the eventual design can eliminate the raw slot accessors for structures in favor of this framework.