SAPs are not stack-allocated

Bug #2052730 reported by Andrew Kravchuk
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

I'm trying to optimize performance of some code heavily relying on CFFI and I want to stack-allocate C pointers. But the following minimal code

((lambda (x)
   (declare (type sb-sys:system-area-pointer x))
   (let ((p (sb-sys:sap+ x 42)))
     (declare (dynamic-extent p))
     (print (sb-introspect:allocation-information p))
     (print p)))
 (sb-sys:int-sap 0))

being tested on latest SBCL 2.4.1 (both Linux and Windows build), prints :HEAP despite dynamic-extent declaration on P; the results of DISASSEMBLE confirm that P pointer is indeed a 16 bytes allocated on heap via ALLOC-TRAMP.

Is it perhaps because SAPs have some complex internal structure that can't be laid out on stack?

description: updated
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.