From: Jerry J. <log...@gm...> - 2010-06-24 01:58:12
|
I'm working my way through the compiler notes on a small project, trying to understand what each one means (and fix those that are fixable). I've encountered some notes relating to the use of the system-area-pointer type, which is used to interface with some C code. I can distill my question down to this code: (proclaim '(optimize (debug 0) (safety 0) (space 1) (speed 3) (compilation-speed 3))) ;; Gets a compiler note about SAP to pointer coercion (defun sap-test1 (ptr fun) (declare (type system-area-pointer ptr) (type (function (system-area-pointer) fixnum) fun)) (funcall fun (sb-sys:sap+ ptr 10))) ;; Doesn't get a compiler note (defun sap-test2 (ptr fun) (declare (type system-area-pointer ptr) (type (function (system-area-pointer) fixnum) fun)) (funcall fun ptr)) which produces this output when compiled: ; compiling file "/tmp/test.lisp" (written 23 JUN 2010 07:48:20 PM): ; compiling (PROCLAIM (QUOTE #)) ; compiling (DEFUN SAP-TEST1 ...) ; file: /tmp/test.lisp ; in: DEFUN SAP-TEST1 ; (FUNCALL FUN (SB-SYS:SAP+ PTR 10)) ; ==> ; (SB-C::%FUNCALL (SB-KERNEL:%COERCE-CALLABLE-TO-FUN FUN) (SB-SYS:SAP+ PTR 10)) ; ; note: doing SAP to pointer coercion (cost 20) ; compiling (DEFUN SAP-TEST2 ...); ; compilation unit finished ; printed 1 note ; /tmp/test.fasl written ; compilation finished in 0:00:00.003 Why is the SAP to pointer coercion taking place in the first version? Thanks, -- Jerry James http://www.jamezone.org/ |