Index: package-data-list.lisp-expr =================================================================== RCS file: /cvsroot/sbcl/sbcl/package-data-list.lisp-expr,v retrieving revision 1.342 diff -u -r1.342 package-data-list.lisp-expr --- package-data-list.lisp-expr 28 Dec 2005 22:37:14 -0000 1.342 +++ package-data-list.lisp-expr 1 Jan 2006 10:52:37 -0000 @@ -109,7 +109,7 @@ "COMPUTE-NATURALIZE-LAMBDA" "DEFINE-ALIEN-TYPE-CLASS" "DEFINE-ALIEN-TYPE-METHOD" "DEFINE-ALIEN-TYPE-TRANSLATOR" "DEPORT" "DEPOSIT-ALIEN-VALUE" "DISPOSE-LOCAL-ALIEN" - "ENTER-ALIEN-CALLBACK" + "*ENTER-ALIEN-CALLBACK*" "ENTER-ALIEN-CALLBACK" "EXTRACT-ALIEN-VALUE" "HEAP-ALIEN-INFO" "HEAP-ALIEN-INFO-P" "HEAP-ALIEN-INFO-SAP-FORM" "HEAP-ALIEN-INFO-TYPE" "INVOKE-ALIEN-TYPE-METHOD" "LOCAL-ALIEN" Index: src/code/target-alieneval.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/target-alieneval.lisp,v retrieving revision 1.37 diff -u -r1.37 target-alieneval.lisp --- src/code/target-alieneval.lisp 15 Oct 2005 12:55:53 -0000 1.37 +++ src/code/target-alieneval.lisp 1 Jan 2006 10:52:38 -0000 @@ -864,6 +864,11 @@ return arguments)) +;;; To ensure that callback wrapper functions continue working even +;;; if #'ENTER-ALIEN-CALLBACK moves in memory, access to it is indirected +;;; through the *ENTER-ALIEN-CALLBACK* static symbol. -- JES, 2006-01-01 +(defvar *enter-alien-callback* #'enter-alien-callback) + ;;;; interface (not public, yet) for alien callbacks (defmacro alien-callback (specifier function &environment env) Index: src/compiler/x86/c-call.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/x86/c-call.lisp,v retrieving revision 1.27 diff -u -r1.27 c-call.lisp --- src/compiler/x86/c-call.lisp 14 Jul 2005 19:13:47 -0000 1.27 +++ src/compiler/x86/c-call.lisp 1 Jan 2006 10:52:38 -0000 @@ -380,7 +380,16 @@ (inst add eax 16) ; arguments (inst push eax) ; arg1 (inst push (ash index 2)) ; arg0 - (inst push (get-lisp-obj-address #'enter-alien-callback)) ; function + + ;; Indirect the access to ENTER-ALIEN-CALLBACK through + ;; the symbol-value slot of SB-ALIEN::*ENTER-ALIEN-CALLBACK* + ;; to ensure it'll work even if the GC moves ENTER-ALIEN-CALLBACK. + ;; Skip any SB-THREAD TLS magic, since we don't expecte anyone + ;; to rebind the variable. -- JES, 2006-01-01 + (inst mov eax (+ nil-value (static-symbol-offset + 'sb!alien::*enter-alien-callback*))) + (loadw eax eax symbol-value-slot other-pointer-lowtag) + (inst push eax) ; function (inst mov eax (foreign-symbol-address "funcall3")) (inst call eax) ;; now put the result into the right register Index: src/compiler/x86/parms.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/x86/parms.lisp,v retrieving revision 1.53 diff -u -r1.53 parms.lisp --- src/compiler/x86/parms.lisp 14 Dec 2005 03:39:23 -0000 1.53 +++ src/compiler/x86/parms.lisp 1 Jan 2006 10:52:38 -0000 @@ -345,6 +345,10 @@ ;; For GC-AND-SAVE *restart-lisp-function* + ;; Needed for callbacks to work across saving cores. see + ;; ALIEN-CALLBACK-ASSEMBLER-WRAPPER in c-call.lisp for gory details. + sb!alien::*enter-alien-callback* + ;; The ..SLOT-UNBOUND.. symbol is static in order to optimise the ;; common slot unbound check. ;; Index: src/compiler/x86-64/c-call.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/x86-64/c-call.lisp,v retrieving revision 1.14 diff -u -r1.14 c-call.lisp --- src/compiler/x86-64/c-call.lisp 1 Dec 2005 04:16:00 -0000 1.14 +++ src/compiler/x86-64/c-call.lisp 1 Jan 2006 10:52:38 -0000 @@ -408,7 +408,15 @@ (bug "Unknown alien floating point type: ~S" type))))) ;; arg0 to FUNCALL3 (function) - (inst mov rdi (get-lisp-obj-address #'enter-alien-callback)) + ;; + ;; Indirect the access to ENTER-ALIEN-CALLBACK through + ;; the symbol-value slot of SB-ALIEN::*ENTER-ALIEN-CALLBACK* + ;; to ensure it'll work even if the GC moves ENTER-ALIEN-CALLBACK. + ;; Skip any SB-THREAD TLS magic, since we don't expecte anyone + ;; to rebind the variable. -- JES, 2006-01-01 + (inst mov rdi (+ nil-value (static-symbol-offset + 'sb!alien::*enter-alien-callback*))) + (loadw rdi rdi symbol-value-slot other-pointer-lowtag) ;; arg0 to ENTER-ALIEN-CALLBACK (trampoline index) (inst mov rsi (fixnumize index)) ;; arg1 to ENTER-ALIEN-CALLBACK (pointer to argument vector) Index: src/compiler/x86-64/parms.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/x86-64/parms.lisp,v retrieving revision 1.16 diff -u -r1.16 parms.lisp --- src/compiler/x86-64/parms.lisp 14 Dec 2005 03:39:23 -0000 1.16 +++ src/compiler/x86-64/parms.lisp 1 Jan 2006 10:52:38 -0000 @@ -225,6 +225,10 @@ ;; For GC-AND-SAVE *restart-lisp-function* + ;; Needed for callbacks to work across saving cores. see + ;; ALIEN-CALLBACK-ASSEMBLER-WRAPPER in c-call.lisp for gory details. + sb!alien::*enter-alien-callback* + ;; The ..SLOT-UNBOUND.. symbol is static in order to optimise the ;; common slot unbound check. ;;