Raymond Toy pushed to branch issue-243-weak-pointer-to-static-array at cmucl / cmucl
Commits: 4ccd8d2a by Raymond Toy at 2024-02-17T12:58:07-08:00 Remove unneeded clear-static-vector-mark
Remove `clear-static-vector-mark` because GC does that for us now in `scan_static_vectors`.
Fix up some comments in `finalize-static-vectors`, and be a bit more careful in only removing an item from `lisp::*static-vectors*` only if the weak pointer was broken.
Minor tweak to a debugging print.
Update cmucl.pot.
- - - - -
3 changed files:
- src/code/array.lisp - src/i18n/locale/cmucl.pot - src/lisp/gencgc.c
Changes:
===================================== src/code/array.lisp ===================================== @@ -374,40 +374,20 @@ sys:system-area-pointer)) (sys:int-sap addr)))))
-(defun clear-static-vector-mark () - ;; Run down the list of weak pointers to static vectors. For each - ;; vector, clear the mark. - (dolist (wp *static-vectors*) - (let ((vector (weak-pointer-value wp))) - ;; The value should never be NIL here? - (when vector - (let* ((sap (sys:vector-sap vector)) - (header (sys:sap-ref-32 sap (* -2 vm:word-bytes)))) - (when *debug-static-array-p* - (format t (intl:gettext "static vector ~A. header = ~X~%") - vector header)) - (setf (sys:sap-ref-32 sap (* -2 vm:word-bytes)) - (logand header #x7fffffff))))))) - (defun finalize-static-vectors () - ;; Run down the list of weak-pointers to static vectors. Look at - ;; the static vector and see if vector is marked. If so, clear the - ;; mark, and do nothing. If the mark is not set, then the vector is - ;; free, so free it, and remove this weak-pointer from the list. - ;; The mark bit the MSB of the header word. Look at scavenge in - ;; gencgc.c. + ;; Run down the list of weak-pointers to static vectors and remove + ;; any weak pointers that have been broken. (when *static-vectors* (when *debug-static-array-p* (let ((*print-array* nil)) (format t (intl:gettext "Finalizing static vectors ~S~%") *static-vectors*))) - ;; Remove any weak pointers that whose value is NIL. The + ;; Remove any weak pointers that have been broken. The ;; corresponding static array has been freed by GC. (setf *static-vectors* - (delete-if-not #'weak-pointer-value *static-vectors*)))) + (delete-if-not #'(lambda (wp) + (nth-value 1 (weak-pointer-value wp))) + *static-vectors*))))
-;; Clear the mark bit of all of static vectors before GC -#+nil -(pushnew 'clear-static-vector-mark *before-gc-hooks*) ;; Clean up any unreferenced static vectors after GC has run. (pushnew 'finalize-static-vectors *after-gc-hooks*)
===================================== src/i18n/locale/cmucl.pot ===================================== @@ -2379,10 +2379,6 @@ msgstr "" msgid "~&Freeing foreign vector at #x~X~%" msgstr ""
-#: src/code/array.lisp -msgid "static vector ~A. header = ~X~%" -msgstr "" - #: src/code/array.lisp msgid "Finalizing static vectors ~S~%" msgstr ""
===================================== src/lisp/gencgc.c ===================================== @@ -5532,7 +5532,7 @@ scan_static_vectors(void) if ((*header & STATIC_VECTOR_MARK_BIT) == 0) { lispobj *static_array = (lispobj *) PTR(wp->value); if (debug_static_array_p) { - printf(" Free wp\n"); + printf(" Free static vector\n"); }
wp->value = NIL;
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/4ccd8d2a9bbd8d4965722c77...