special-case ERROR 'TYPE-ERROR

Bug #663918 reported by Nikodemus Siivola
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Triaged
Wishlist
Unassigned

Bug Description

Many internal functions end up containing code such as

;......AB8:.......488B15A1FCFFFF...MOV RDX, [RIP-863].........; 'TYPE-ERROR
;......ABF:.......488B3DA2FCFFFF...MOV RDI, [RIP-862].........; :DATUM
;......AC6:.......488BF0...........MOV RSI, RAX
;......AC9:.......488B05A0FCFFFF...MOV RAX, [RIP-864].........; :EXPECTED-TYPE
;......AD0:.......488943F0.........MOV [RBX-16], RAX
;......AD4:.......488B059DFCFFFF...MOV RAX, [RIP-867].........; 'LIST
;......ADB:.......488943E8.........MOV [RBX-24], RAX
;......ADF:.......488B059AFCFFFF...MOV RAX, [RIP-870] ; #<FDEFINITION object for ERROR>

where

;......B05: L30:..0F0B0A...........BREAK 10...................; error trap
;......B08:.......02...............BYTE #X02
;......B09:.......02...............BYTE #X02..................; OBJECT-NOT-LIST-ERROR
;......B0A:.......95...............BYTE #X95..................; RDX

would do just as well. A compiler macro to generate calls to %TYPE-ERROR or some such, and a bit of backend code should do.

Tags: optimization
Revision history for this message
Douglas Katzman (dougk) wrote :

Mostly resolved by https://sourceforge.net/p/sbcl/sbcl/ci/87318119bd57b893a6dce02009b80514cf2c2caa/
I'm missing some transformations but I think those can be added with relative ease.
(e.g. 'FUNCTION -> OBJECT-NOT-FUN-ERROR is named inconsistently with my simplistic approach)

Unless you were looking for something to actually change Lisp-level calls to (error 'type-error ...) into the primitive trap *whenever* it is possible to do so, that's far more ambitious, and moreover "interr.lisp" is going to have to be informed not to do that because it's trying to convert the trap into really a Lisp error. Maybe just a (notinline error) declaration would suffice.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.