From: Douglas K. <sn...@us...> - 2017-07-19 04:00:59
|
The branch "master" has been updated in SBCL: via 8a7dd22d50fcbcba32b8a074a6a1110b32bac822 (commit) from 7ce3ffd97597cdf114a72a7454a62a8251d4506e (commit) - Log ----------------------------------------------------------------- commit 8a7dd22d50fcbcba32b8a074a6a1110b32bac822 Author: Douglas Katzman <do...@go...> Date: Tue Jul 18 23:54:48 2017 -0400 Remove *ENTER-ALIEN-CALLBACK* symbol. Loading fdefn-fun from ENTER-ALIEN-CALLBACK (no asterisks) works properly if that function is redefined, and doesn't merit 100 lines of commentary. --- package-data-list.lisp-expr | 2 +- src/code/target-alieneval.lisp | 5 ----- src/compiler/arm/c-call.lisp | 11 ++--------- src/compiler/arm/parms.lisp | 5 ----- src/compiler/arm64/c-call.lisp | 11 ++--------- src/compiler/arm64/parms.lisp | 6 ------ src/compiler/generic/parms.lisp | 1 + src/compiler/generic/utils.lisp | 7 +++++++ src/compiler/mips/c-call.lisp | 1 + src/compiler/ppc/c-call.lisp | 28 ++++------------------------ src/compiler/ppc/parms.lisp | 8 +------- src/compiler/x86-64/c-call.lisp | 10 +--------- src/compiler/x86-64/parms.lisp | 5 ----- src/compiler/x86/c-call.lisp | 9 ++------- src/compiler/x86/parms.lisp | 7 +------ src/runtime/thread.c | 2 +- 16 files changed, 24 insertions(+), 94 deletions(-) diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index 2baffea..6445e60 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -130,7 +130,7 @@ of SBCL which maintained the CMU-CL-style split into two packages.)" "DEFINE-ALIEN-TYPE-METHOD" "DEFINE-ALIEN-TYPE-TRANSLATOR" "DEPORT" "DEPORT-ALLOC" "DISPOSE-LOCAL-ALIEN" - "*ENTER-ALIEN-CALLBACK*" "ENTER-ALIEN-CALLBACK" + "ENTER-ALIEN-CALLBACK" "FIND-SAVED-FP-AND-PC" "HEAP-ALIEN-INFO" "HEAP-ALIEN-INFO-P" "HEAP-ALIEN-INFO-SAP-FORM" "HEAP-ALIEN-INFO-TYPE" "INVOKE-ALIEN-TYPE-METHOD" diff --git a/src/code/target-alieneval.lisp b/src/code/target-alieneval.lisp index 78a93f2..282f388 100644 --- a/src/code/target-alieneval.lisp +++ b/src/code/target-alieneval.lisp @@ -1037,11 +1037,6 @@ ENTER-ALIEN-CALLBACK pulls the corresponding trampoline out and calls it.") 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 (let () diff --git a/src/compiler/arm/c-call.lisp b/src/compiler/arm/c-call.lisp index 4830fa6..303334f 100644 --- a/src/compiler/arm/c-call.lisp +++ b/src/compiler/arm/c-call.lisp @@ -483,15 +483,8 @@ (t (bug "Unknown alien floating point type: ~S" type))))) ;; arg0 to FUNCALL3 (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 expect anyone - ;; to rebind the variable. -- JES, 2006-01-01 - (load-immediate-word r0-tn (+ nil-value (static-symbol-offset - 'sb!alien::*enter-alien-callback*))) - (loadw r0-tn r0-tn symbol-value-slot other-pointer-lowtag) + (load-immediate-word r0-tn (static-fdefn-fun-addr 'enter-alien-callback)) + (loadw r0-tn r0-tn 0 0) ;; arg0 to ENTER-ALIEN-CALLBACK (trampoline index) (inst mov r1-tn (fixnumize index)) ;; arg1 to ENTER-ALIEN-CALLBACK (pointer to argument vector) diff --git a/src/compiler/arm/parms.lisp b/src/compiler/arm/parms.lisp index a564715..f5f5c8d 100644 --- a/src/compiler/arm/parms.lisp +++ b/src/compiler/arm/parms.lisp @@ -149,11 +149,6 @@ ;; interrupt handling *pseudo-atomic-atomic* *pseudo-atomic-interrupted* - - ;; 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* #!+gencgc *restart-lisp-function*) #'equalp) diff --git a/src/compiler/arm64/c-call.lisp b/src/compiler/arm64/c-call.lisp index 726e2dd..755c4e8 100644 --- a/src/compiler/arm64/c-call.lisp +++ b/src/compiler/arm64/c-call.lisp @@ -376,15 +376,8 @@ (t (bug "Unknown alien type: ~S" type))))) ;; arg0 to FUNCALL3 (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 expect anyone - ;; to rebind the variable. -- JES, 2006-01-01 - (load-immediate-word r0-tn (+ nil-value (static-symbol-offset - 'sb!alien::*enter-alien-callback*))) - (loadw r0-tn r0-tn symbol-value-slot other-pointer-lowtag) + (load-immediate-word r0-tn (static-fdefn-fun-addr 'enter-alien-callback)) + (loadw r0-tn r0-tn 0 0) ;; arg0 to ENTER-ALIEN-CALLBACK (trampoline index) (inst mov r1-tn (fixnumize index)) ;; arg1 to ENTER-ALIEN-CALLBACK (pointer to argument vector) diff --git a/src/compiler/arm64/parms.lisp b/src/compiler/arm64/parms.lisp index f511ee3..f55f5c2 100644 --- a/src/compiler/arm64/parms.lisp +++ b/src/compiler/arm64/parms.lisp @@ -126,12 +126,6 @@ *pseudo-atomic-interrupted*) *allocation-pointer* ;; interrupt handling - - - ;; 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* #!+gencgc *restart-lisp-function* ,@+common-static-symbols+) #'equalp) diff --git a/src/compiler/generic/parms.lisp b/src/compiler/generic/parms.lisp index 545beb2..8ecd09b 100644 --- a/src/compiler/generic/parms.lisp +++ b/src/compiler/generic/parms.lisp @@ -128,6 +128,7 @@ sb!di::handle-single-step-trap #!+win32 sb!kernel::handle-win32-exception #!+sb-thruption sb!thread::run-interruption + enter-alien-callback #!+sb-thread sb!thread::enter-foreign-callback #!+(and sb-safepoint-strictly (not win32)) sb!unix::signal-handler-callback) diff --git a/src/compiler/generic/utils.lisp b/src/compiler/generic/utils.lisp index a60b430..655fad3 100644 --- a/src/compiler/generic/utils.lisp +++ b/src/compiler/generic/utils.lisp @@ -57,6 +57,13 @@ (* static-fun-index (pad-data-block fdefn-size)) other-pointer-lowtag))) +;;; Return absolute address of the 'fun' slot in static fdefn NAME. +(defun static-fdefn-fun-addr (name) + (+ nil-value + (static-fdefn-offset name) + (- other-pointer-lowtag) + (ash fdefn-fun-slot word-shift))) + ;;; Return the (byte) offset from NIL to the raw-addr slot of the ;;; fdefn object for the static function NAME. (defun static-fun-offset (name) diff --git a/src/compiler/mips/c-call.lisp b/src/compiler/mips/c-call.lisp index 75186fd..040245d 100644 --- a/src/compiler/mips/c-call.lisp +++ b/src/compiler/mips/c-call.lisp @@ -435,6 +435,7 @@ and a pointer to the arguments." (inst sw ra sp (- n-frame-bytes n-word-bytes)) ;; Setup the args and make the call. + ;; FIXME- should go through the static fdefn for enter-alien-callback (inst li a0 (get-lisp-obj-address #'enter-alien-callback)) (inst li t9 (foreign-symbol-address "funcall3")) (inst li a1 (fixnumize index)) diff --git a/src/compiler/ppc/c-call.lisp b/src/compiler/ppc/c-call.lisp index ddb38ff..abe55cc 100644 --- a/src/compiler/ppc/c-call.lisp +++ b/src/compiler/ppc/c-call.lisp @@ -641,9 +641,8 @@ (destructuring-bind (arg1 arg2 arg3 arg4) (mapcar #'make-gpr '(3 4 5 6)) - (load-address-into arg1 (+ nil-value (static-symbol-offset - 'sb!alien::*enter-alien-callback*))) - (loadw arg1 arg1 symbol-value-slot other-pointer-lowtag) + (load-address-into arg1 (static-fdefn-fun-addr 'enter-alien-callback)) + (loadw arg1 arg1 0 0) (inst li arg2 (fixnumize index)) (inst addi arg3 stack-pointer (- arg-store-pos)) (inst addi arg4 stack-pointer (- return-area-pos))) @@ -788,27 +787,8 @@ (inst lis reg high) (inst ori reg reg low)))) ;; Setup the args - - ;; CLH 2006/02/10 -Following JES' logic in - ;; x86-64/c-call.lisp, we need to access - ;; ENTER-ALIEN-CALLBACK through the symbol-value slot - ;; of SB-ALIEN::*ENTER-ALIEN-CALLBACK* to ensure that - ;; it works if GC moves ENTER-ALIEN-CALLBACK. - ;; - ;; old way: - ;; (load-address-into arg1 (get-lisp-obj-address #'enter-alien-callback)) - - ;; new way: - ;; (load-symbol arg1 'sb!alien::*enter-alien-callback*) - ;; - ;; whoops: can't use load-symbol here as null-tn might - ;; not be loaded with the proper value as we are - ;; coming in from C code. Use nil-value constant - ;; instead, following the logic in x86-64/c-call.lisp. - (load-address-into arg1 (+ nil-value (static-symbol-offset - 'sb!alien::*enter-alien-callback*))) - (loadw arg1 arg1 symbol-value-slot other-pointer-lowtag) - + (load-address-into arg1 (static-fdefn-fun-addr 'enter-alien-callback)) + (loadw arg1 arg1 fdefn-fun-slot other-pointer-lowtag) (inst li arg2 (fixnumize index)) (inst addi arg3 sp n-foreign-linkage-area-bytes) ;; FIXME: This was (- (* RETURN-AREA-SIZE N-WORD-BYTES)), while diff --git a/src/compiler/ppc/parms.lisp b/src/compiler/ppc/parms.lisp index eb9df2f..205c476 100644 --- a/src/compiler/ppc/parms.lisp +++ b/src/compiler/ppc/parms.lisp @@ -175,13 +175,7 @@ ;;; (defconstant-eqx +static-symbols+ `#(,@+common-static-symbols+ - #!+gencgc *restart-lisp-function* - - ;; CLH: 20060210 Taken from x86-64/parms.lisp per JES' suggestion - ;; 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*) + #!+gencgc *restart-lisp-function*) #'equalp) (defconstant-eqx +static-fdefns+ diff --git a/src/compiler/x86-64/c-call.lisp b/src/compiler/x86-64/c-call.lisp index ae1d002..9353185 100644 --- a/src/compiler/x86-64/c-call.lisp +++ b/src/compiler/x86-64/c-call.lisp @@ -447,15 +447,7 @@ #!-sb-thread (progn ;; arg0 to FUNCALL3 (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 expect 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) + (inst mov rdi (make-ea :qword :disp (static-fdefn-fun-addr 'enter-alien-callback))) ;; arg0 to ENTER-ALIEN-CALLBACK (trampoline index) (inst mov rsi (fixnumize index)) ;; arg1 to ENTER-ALIEN-CALLBACK (pointer to argument vector) diff --git a/src/compiler/x86-64/parms.lisp b/src/compiler/x86-64/parms.lisp index 83b1539..98a3092 100644 --- a/src/compiler/x86-64/parms.lisp +++ b/src/compiler/x86-64/parms.lisp @@ -155,11 +155,6 @@ ;; 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* ) #'equalp) diff --git a/src/compiler/x86/c-call.lisp b/src/compiler/x86/c-call.lisp index cd41497..09eed1f 100644 --- a/src/compiler/x86/c-call.lisp +++ b/src/compiler/x86/c-call.lisp @@ -434,13 +434,8 @@ pointer to the arguments." #!-sb-thread (progn - ;; 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 - (load-symbol-value eax sb!alien::*enter-alien-callback*) - (inst push eax) ; function + (inst push (make-ea :dword ; function + :disp (static-fdefn-fun-addr 'enter-alien-callback))) (inst mov eax (foreign-symbol-address "funcall3")) (inst call eax)) diff --git a/src/compiler/x86/parms.lisp b/src/compiler/x86/parms.lisp index b9b3a20..8ef6310 100644 --- a/src/compiler/x86/parms.lisp +++ b/src/compiler/x86/parms.lisp @@ -253,12 +253,7 @@ *fp-constant-ln2* ;; 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*) + *restart-lisp-function*) #'equalp) (defconstant-eqx +static-fdefns+ diff --git a/src/runtime/thread.c b/src/runtime/thread.c index b4bea1c..eadfa4d 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -594,7 +594,7 @@ callback_wrapper_trampoline( WITH_GC_AT_SAFEPOINTS_ONLY() #endif { - funcall3(SymbolValue(ENTER_ALIEN_CALLBACK, 0), arg0, arg1, arg2); + funcall3(StaticSymbolFunction(ENTER_ALIEN_CALLBACK), arg0, arg1, arg2); } } ----------------------------------------------------------------------- hooks/post-receive -- SBCL |