WITH-ALIEN binds *alien-stack* even when not necessary

Bug #645121 reported by Todd Williamson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Low
Unassigned

Bug Description

A foreign function call defined like this:

 (defun microseconds-now (now)
        (declare (type system-area-pointer now))
        (with-alien ((microseconds-now (function void (* int)) :extern "microseconds_now_p"))
          (alien-funcall microseconds-now now)))

generates code that does an unnecessary binding of *alien-stack*, which is a lot of overhead for a foreign function call, especially since nothing is actually allocated on the alien stack. Changing it to avoid the WITH-ALIEN (using extern-alien instead) solves the problem, so this is not really a big deal, though I think this would occur if all alien variables were allocated on the heap as well.

Perhaps the binding could be conditionalized on whether WITH-ALIEN actually allocates anything on the stack.

Tested version: 1.0.17.39
Platform: Linux x86-64

Changed in sbcl:
importance: Undecided → Low
status: New → Triaged
tags: added: alien optimization
Revision history for this message
Stas Boukarev (stassats) wrote :

In 639b29cbdf3e9ff7d0897d299e7feb1889f09fd5

Changed in sbcl:
status: Triaged → Fix Committed
Stas Boukarev (stassats)
Changed in sbcl:
status: Fix Committed → Fix Released
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.