Raymond Toy pushed to branch issue-243-weak-pointer-to-static-array at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/code/array.lisp
    ... ... @@ -374,40 +374,20 @@
    374 374
     				    sys:system-area-pointer))
    
    375 375
           (sys:int-sap addr)))))
    
    376 376
     
    
    377
    -(defun clear-static-vector-mark ()
    
    378
    -  ;; Run down the list of weak pointers to static vectors.  For each
    
    379
    -  ;; vector, clear the mark.
    
    380
    -  (dolist  (wp *static-vectors*)
    
    381
    -    (let ((vector (weak-pointer-value wp)))
    
    382
    -      ;; The value should never be NIL here?
    
    383
    -      (when vector
    
    384
    -	(let* ((sap (sys:vector-sap vector))
    
    385
    -	       (header (sys:sap-ref-32 sap (* -2 vm:word-bytes))))
    
    386
    -	  (when *debug-static-array-p*
    
    387
    -	    (format t (intl:gettext "static vector ~A.  header = ~X~%")
    
    388
    -		    vector header))
    
    389
    -          (setf (sys:sap-ref-32 sap (* -2 vm:word-bytes))
    
    390
    -                (logand header #x7fffffff)))))))
    
    391
    -
    
    392 377
     (defun finalize-static-vectors ()
    
    393
    -  ;; Run down the list of weak-pointers to static vectors.  Look at
    
    394
    -  ;; the static vector and see if vector is marked.  If so, clear the
    
    395
    -  ;; mark, and do nothing.  If the mark is not set, then the vector is
    
    396
    -  ;; free, so free it, and remove this weak-pointer from the list.
    
    397
    -  ;; The mark bit the MSB of the header word.  Look at scavenge in
    
    398
    -  ;; gencgc.c.
    
    378
    +  ;; Run down the list of weak-pointers to static vectors and remove
    
    379
    +  ;; any weak pointers that have been broken.
    
    399 380
       (when *static-vectors*
    
    400 381
         (when *debug-static-array-p*
    
    401 382
           (let ((*print-array* nil))
    
    402 383
     	(format t (intl:gettext "Finalizing static vectors ~S~%") *static-vectors*)))
    
    403
    -    ;; Remove any weak pointers that whose value is NIL.  The
    
    384
    +    ;; Remove any weak pointers that have been broken.  The
    
    404 385
         ;; corresponding static array has been freed by GC.
    
    405 386
         (setf *static-vectors*
    
    406
    -	  (delete-if-not #'weak-pointer-value *static-vectors*))))
    
    387
    +	  (delete-if-not #'(lambda (wp)
    
    388
    +                             (nth-value 1 (weak-pointer-value wp)))
    
    389
    +                         *static-vectors*))))
    
    407 390
     
    
    408
    -;; Clear the mark bit of all of static vectors before GC
    
    409
    -#+nil
    
    410
    -(pushnew 'clear-static-vector-mark *before-gc-hooks*)
    
    411 391
     ;; Clean up any unreferenced static vectors after GC has run.
    
    412 392
     (pushnew 'finalize-static-vectors *after-gc-hooks*)
    
    413 393
     
    

  • src/i18n/locale/cmucl.pot
    ... ... @@ -2379,10 +2379,6 @@ msgstr ""
    2379 2379
     msgid "~&Freeing foreign vector at #x~X~%"
    
    2380 2380
     msgstr ""
    
    2381 2381
     
    
    2382
    -#: src/code/array.lisp
    
    2383
    -msgid "static vector ~A.  header = ~X~%"
    
    2384
    -msgstr ""
    
    2385
    -
    
    2386 2382
     #: src/code/array.lisp
    
    2387 2383
     msgid "Finalizing static vectors ~S~%"
    
    2388 2384
     msgstr ""
    

  • src/lisp/gencgc.c
    ... ... @@ -5532,7 +5532,7 @@ scan_static_vectors(void)
    5532 5532
                 if ((*header & STATIC_VECTOR_MARK_BIT) == 0)  {
    
    5533 5533
                     lispobj *static_array = (lispobj *) PTR(wp->value);
    
    5534 5534
                     if (debug_static_array_p) {
    
    5535
    -                    printf("    Free wp\n");
    
    5535
    +                    printf("    Free static vector\n");
    
    5536 5536
                     }
    
    5537 5537
     
    
    5538 5538
                     wp->value = NIL;