[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 1.3.2 + Sys.7 VM



> 
> I understand that one of the reasons for upgrading to MCL 2.0 is to take
> advantage of VM.  BUT, to what extent is 1.3.2 incompatible with VM?  I
> have noticed occasional, but _not_ regular, crashes during GC.
> 
> ----------------------------------------------------------------------
> Espen J. Vestre                              e-mail: espen@math.uio.no
> Department of Mathematics
> Univ. of Oslo, PO. Box 1053 Blindern,        tel.: +47 (2) 45 59 39
> N-0316 OSLO 3, Norway
> 
> 

1.3.2 is generally -not- compatible with System 7:

  1) It won't work at all in 32-bit mode; it assumes a 24-bit memory manager.

  2) The entire Multifinder partition has to reside in the first 8MB of
     memory.  With VM enabled, Multifinder may try to load the lisp into
     higher addresses; one may have to launch other applications first and/or
     adjust the lisp's suggested memory size in order to ensure that the lisp
     loads into the low 8MB.

  3) Most seriously, the lisp's "growzone" function - the function which the
     Mac Memory Manager calls when it can't otherwise satisfy a memory
     allocation request - erroneously assumes that it doesn't need to
     preserve the registers that it modifies.  (Prior to System 7.0, the
     Memory Manager code that called an application's "growzone" function
     saved and restored all registers around the call, but that doesn't seem
     to have been its documented behavior.)

     The enclosed patch seems to fix this problem, which would seem to
     be responsible for the "crashes sometimes during GC" behavior you 
     reported.  The patch assumes version 1.3.2; I'm not sure whether
     it would work in older versions, and it has nothing to do with 2.0.

  4) There are almost certainly other bugs; those that I'm aware of are more
     cosmetic than fatal (e.g., drawing into the wrong grafport when windoids
     are active.)

It's unfortunate that whatever claims of 1.3.2's 7.0 compatibility have been
made were based on misinformation.


-------------------------------------------------------------------------------
(in-package :ccl)
(eval-when (compile eval)
  (require "TRAPS"))

(defun fix-sys7-growzone ()
  (let* ((code '(#x202F #x4             ; move.l 4(sp),d0
                 #x48E7 #x1F3E          ; movem.l d3-d7/a2-a6,-(sp)
                 #x2F38 #x904           ; move.l currentA5,-(sp)
                 #x42A7                 ; clr.l -(sp)
                 #x2F00                 ; move.l d0,-(sp)
                 #x2A7C #x123 #x4567    ; move.l #$01234567,a5 (fixed below)
                 #x21CD #x904           ; move.l a5,currentA5
                 #x4EAD #x1112          ; jsr lispgrowzone(a5)
                 #x201F                 ; move.l (sp)+,d0
                 #x21df #x904           ; move.l (sp)+,currentA5
                 #x4CDF #x7CF8          ; movem.l (sp)+,d3-d7/a2-a6
                 #x205F                 ; move.l (sp)+,a0
                 #x584F                 ; addq #4,sp
                 #x2E80                 ; move.l d0,(sp)
                 #x4ED0))               ; jmp (a0)
         (code-length (length code))
         (ptr (_NewPtr :errchk :d0 (* 2 code-length) :a0))
         (a5Now (%get-ptr (%int-to-ptr #x904))))
    (dotimes (i code-length)
      (%put-word ptr (pop code) (+ i i)))
; Fix the reference to A5
    (%put-ptr ptr a5now 18)		; replace #x01234567 with "real" A5
    (_SetGrowZone :a0 ptr)))

; Install the growzone patch, unless it's already there.  Make sure it's run 
; whenever a saved image is restored.

(unless (member 'fix-sys7-growzone *restore-lisp-functions* 
                :key #'ccl::function-name)
  (push #'fix-sys7-growzone *restore-lisp-functions*)
  (fix-sys7-growzone))