Jonathan J Simpson <[EMAIL PROTECTED]> writes:

> (declaim (optimize (speed 3) (safety 0)))
> 
> (defstruct vec4
>   (x 0d0 :type double-float)
>   (y 0d0 :type double-float)
>   (z 0d0 :type double-float)
>   (w 0d0 :type double-float))
> 
> Produces four compiler notes:
> 
>  In: DEFSTRUCT VEC4
> 
> ;   (DEFSTRUCT VEC4
> ;     (X 0.0d0 :TYPE DOUBLE-FLOAT)
> ;     (Y 0.0d0 :TYPE DOUBLE-FLOAT)
> ;     (Z 0.0d0 :TYPE DOUBLE-FLOAT)
> ;     ...)
> ; Note: Doing float to pointer coercion (cost 13) to "<return value>".
> 
> 
> I thought that in cmucl, structs could have unboxed slots.

They have. But global functions, returning floats, must box them. The
notes are produced for VEC4-X, -Y, -Z, -W. Is the code using these
accessors they are inline expanded and do not need to box the return
values. E.g. in

  (defun foo (v)
    (declare (type vec4 v))
    (+ (vec4-x v) (vec4-y v) (vec4-z v)))

arguments of + (which is open-coded) are not boxed, but the result,
which is returned from FOO, is. See the discussion of local calls and
inline expansion in "CMU Common Lisp User's Manual".

-- 
Regards,
Alexey Dejneka

"Alas, the spheres of truth are less transparent than those of
illusion." -- L.E.J. Brouwer

Reply via email to