1.0.24.21: call stub needed to switch between hpux heap-spaces
authorNikodemus Siivola <nikodemus@random-state.net>
Sun, 4 Jan 2009 07:35:53 +0000 (07:35 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Sun, 4 Jan 2009 07:35:53 +0000 (07:35 +0000)
 * Patch by Larry Valkama.

src/assembly/hppa/assem-rtns.lisp
src/code/cold-init.lisp
src/code/early-impl.lisp
src/code/save.lisp
src/code/toplevel.lisp
src/compiler/generic/parms.lisp
src/compiler/hppa/system.lisp
src/runtime/hppa-assem.S
src/runtime/runtime.c
version.lisp-expr

index 4cae72b..b90b2cb 100644 (file)
 
   (inst b *unwind-entry-point*)
   (inst move catch target))
+
+#!+hpux
+(define-assembly-routine
+  (return-from-lisp-stub (:return-style :none))
+  ((:temp lip interior-reg lip-offset)
+   (:temp nl0 descriptor-reg nl0-offset)
+   (:temp nl1 descriptor-reg nl1-offset)
+   (:temp lra descriptor-reg lra-offset))
+  ; before calling into lisp we must save our return address (reg_LRA)
+  (store-symbol-value lra *c-lra*)
+  ; note the lra we calculate next must "simulate" an fixnum,
+  ; because compute-calling-frame will use fixnump on this value.
+  ; either use 16 or 20, finetune it...
+  (inst addi 19 nl0 lra) ; then setup the new LRA (rest of this routine after branch)
+  (inst bv lip :nullify t)
+  (inst word return-pc-header-widetag)
+  ; ok, we are back from the lisp-call, lets return to c
+  ; FIX-lav: steal more stuff from call_into_lisp here, ideally the whole thing
+  (inst move ocfp-tn csp-tn) ; dont think we should ever get here
+  (inst nop)
+  (load-symbol-value nl0 *c-lra*)
+  (inst addi 1 nl0 nl0)
+  (inst ble 0 c-text-space nl0 :nullify t))
index 57c5c12..2b26328 100644 (file)
   (/show0 "done initializing, setting *COLD-INIT-COMPLETE-P*")
   (setf *cold-init-complete-p* t)
 
+  ; hppa heap is segmented, lisp and c uses a stub to call eachother
+  #!+hpux (sb!sys:%primitive sb!vm::setup-return-from-lisp-stub)
   ;; The system is finally ready for GC.
   (/show0 "enabling GC")
   (gc-on)
index 430b1c7..3cd6dc8 100644 (file)
@@ -33,6 +33,7 @@
                   ;; pseudo-atomicity too, but they handle it without
                   ;; messing with special variables.)
                   #!+(or x86 x86-64) *pseudo-atomic-bits*
+                  #!+(or hpux) sb!vm::*c-lra*
                   *allow-with-interrupts*
                   *interrupts-enabled*
                   *interrupt-pending*
index 486bc97..d4f183e 100644 (file)
@@ -125,6 +125,7 @@ sufficiently motivated to do lengthy fixes."
   (labels ((restart-lisp ()
              (handling-end-of-the-world
                (reinit)
+               #!+hpux (sb!sys:%primitive sb!vm::setup-return-from-lisp-stub)
                (funcall toplevel)))
            (foreign-bool (value)
              (if value 1 0))
index bc46818..bbebd5b 100644 (file)
@@ -20,6 +20,7 @@
 (progn
   (defvar sb!vm::*current-catch-block*)
   (defvar sb!vm::*current-unwind-protect-block*)
+  #!+hpux (defvar sb!vm::*c-lra*)
   (defvar *free-interrupt-context-index*))
 \f
 ;;; specials initialized by !COLD-INIT
index c134c87..df1f733 100644 (file)
@@ -44,6 +44,8 @@
     *current-catch-block*
     *current-unwind-protect-block*
 
+    #!+hpux *c-lra*
+
     ;; stack pointers
     *binding-stack-start*
     *control-stack-start*
index 8246323..9246fae 100644 (file)
   (:generator 1
     (inst break halt-trap)))
 
+#+hpux
+(define-vop (setup-return-from-lisp-stub)
+  (:results)
+  (:save-p t)
+  (:temporary (:sc any-reg :offset nl0-offset) nl0)
+  (:temporary (:sc any-reg :offset cfunc-offset) cfunc)
+  (:temporary (:sc control-stack :offset nfp-save-offset) nfp-save)
+  (:temporary (:scs (non-descriptor-reg)) temp)
+  (:vop-var vop)
+  (:generator 100
+    (let ((stub (make-fixup 'return-from-lisp-stub :assembly-routine)))
+      (inst li stub nl0))
+    (let ((cur-nfp (current-nfp-tn vop)))
+      (when cur-nfp
+        (store-stack-tn nfp-save cur-nfp))
+      (inst li (make-fixup "setup_return_from_lisp_stub" :foreign) cfunc)
+      (let ((fixup (make-fixup "call_into_c" :foreign)))
+        (inst ldil fixup temp)
+        (inst ble fixup c-text-space temp))
+      (inst addi  64 nsp-tn nsp-tn)
+      (inst addi -64 nsp-tn nsp-tn)
+      (when cur-nfp
+        (load-stack-tn cur-nfp nfp-save)))))
 \f
 ;;;; Dynamic vop count collection support
 
       (inst ldw offset count-vector count)
       (inst addi 1 count count)
       (inst stw count offset count-vector))))
+
index fd2068f..25cb29d 100644 (file)
@@ -108,12 +108,16 @@ call_into_lisp:
 
        /* Indirect the closure */
        ldw     CLOSURE_FUN_OFFSET(0,reg_LEXENV),reg_CODE
-       addi    6*4-FUN_POINTER_LOWTAG,reg_CODE,reg_LIP
-
-       /* And into lisp we go. */
-       .export break_here
-break_here:    
-       be,n    0(%sr5,reg_LIP)
+  addi  SIMPLE_FUN_CODE_OFFSET,reg_CODE,reg_LIP
+
+#ifdef LISP_FEATURE_HPUX
+  /*  Get the stub address, ie assembly-routine return-from-lisp */
+  addil   L%return_from_lisp_stub-$global$,%dp
+  ldw     R%return_from_lisp_stub-$global$(0,%r1),reg_NL0
+  be,n  0(%sr5,reg_NL0)
+#else                 
+  be,n  0(%sr5,reg_NL0)
+#endif
 
        break   0,0
 
index 6c2df40..159d7f6 100644 (file)
 #define SBCL_HOME "/usr/local/lib/sbcl/"
 #endif
 
+#ifdef LISP_FEATURE_HPUX
+extern void *return_from_lisp_stub;
+#endif
+
 \f
 /* SIGINT handler that invokes the monitor (for when Lisp isn't up to it) */
 static void
@@ -426,6 +430,10 @@ main(int argc, char *argv[], char *envp[])
     if (initial_function == NIL) {
         lose("couldn't find initial function\n");
     }
+#ifdef LISP_FEATURE_HPUX
+    return_from_lisp_stub = (void *) ((char *)*((unsigned long *)
+                 ((char *)initial_function - 1)) + 23);
+#endif
 
     gc_initialize_pointers();
 
index 000af67..e8a18e8 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.24.20"
+"1.0.24.21"