(FILECREATED "10-Sep-84 22:48:44" {ERIS}<LISP>CAROL>PATCHES>BIGREFCNTPATCH.;1 2568   

      changes to:  (VARS BIGREFCNTPATCHCOMS))


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT BIGREFCNTPATCHCOMS)

(RPAQQ BIGREFCNTPATCHCOMS ((FNS \GC.MODIFY.BIGREFCNT)))
(DEFINEQ

(\GC.MODIFY.BIGREFCNT
  (LAMBDA (ENTRY CASE PTR)                                   (* JonL "10-Sep-84 22:38")

          (* Called from .MODENTRY. to do one of the 4 reference counting cases on PTR. ENTRY is the gc table entry whose 
	  CNT field is \MAXHTCNT)


    (PROG ((OVENTRY \HTBIGCOUNT)
	   TMP CNT)
          (COND
	    ((ODDP (\LOLOC PTR))                             (* This should be an error, but accomodate it for now)
	      (SETQ PTR (\ADDBASE PTR -1))))
      LP  (COND
	    ((NEQ (SETQ TMP (fetch OVFLPTR of OVENTRY))
		  PTR)
	      (COND
		((NULL TMP)
		  (\GC.BIGREFCNT.MISSING PTR)
		  (RETURN)))
	      (SETQ OVENTRY (\ADDBASE OVENTRY \HTBIGENTRYSIZE))
	      (GO LP)))
          (SELECTC CASE
		   (\ADDREFCASE (replace OVFLCNTLO of OVENTRY
				   with (COND
					  ((ILESSP (SETQ TMP (fetch OVFLCNTLO of OVENTRY))
						   MAX.SMALLP)
					    (ADD1 TMP))
					  (T (add (fetch OVFLCNTHI of OVENTRY)
						  1)
					     0))))
		   (\DELREFCASE (replace OVFLCNTLO of OVENTRY
				   with (COND
					  ((IGEQ (SETQ TMP (SUB1 (fetch OVFLCNTLO of OVENTRY)))
						 \MAXHTCNT)
					    TMP)
					  ((EQ 0 (fetch OVFLCNTHI of OVENTRY))
                                                             (* Ref cnt has fallen below max, bring it out)
					    (replace (GC CNT) of ENTRY with TMP)
					    (replace OVFLPTR of OVENTRY with T)
                                                             (* mark deleted)
					    TMP)
					  ((ILESSP TMP 0)
					    (add (fetch OVFLCNTHI of OVENTRY)
						 -1)
					    MAX.SMALLP)
					  (T TMP))))
		   (\SCANREFCASE (replace (GC STKBIT) of ENTRY with T))
		   (\UNSCANREFCASE (replace (GC STKBIT) of ENTRY with NIL))
		   NIL)                                      (* Must worry about SCANREF cases since the main entry 
							     is inspected by others, regardless of the refcnt)
                                                             (* Value is NIL to tell .MODENTRY.
							     that cnt ~= 1)
          (RETURN NIL))))
)
(PUTPROPS BIGREFCNTPATCH COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (303 2483 (\GC.MODIFY.BIGREFCNT 313 . 2481)))))
STOP