On Tue, Jul 29, 2008 at 5:14 AM, Andy Hefner <ahefner@...> wrote:
> I observed the same error using SBCL's ffi (noted at the end of my
> June 5 mail to sbcl-devel), which I reduced down to the following:
> (defun unused-alien ()
> (SB-ALIEN:WITH-ALIEN ((ALIEN1923 (ARRAY (SB-ALIEN:UNSIGNED 8) 72)))
Thanks for test-case reduction again! This is the same issue that
plagued Elephant a while back, and had an ill-adviced bandaid applied
for a while.
I finally figured out the real cause: When TRULY-THE was changed a
while back, (TRULY-THE ... (%PRIMITIVE ...)) stopped annotating the
call in a way that ensured correct result type selection during IR2.
...though I still don't know how *using* the alien hid this. I would
have thought that the same problem should have affected both used and
unused local aliens.
Anyways, this fixes the issue:
(defoptimizer (%%primitive derive-type) ((template info &rest args))
(let ((type (template-type (lvar-value template))))
(if (fun-type-p type)
A secondary issue is that FIND-TEMPLATE-RESULT-TYPES does not do what
it says on the tin, but rather just returns the appropriate number of
primitive-types from the argument-types of the call: specifically, it
does not check that these match the template selection logic. This is,
I think, a non-issue outside direct uses of %PRIMITIVE, since the
template selection logic *has* fired, and hence the types will be OK.
This is not the case for %PRIMITIVE. Not sure what TRT is there, aside
from fixing the comment, and sticking an AVER there -- so the the next
time we have a problem like this. the location is less mysterious.