Raymond Toy pushed to branch issue-243-weak-pointer-to-static-array at cmucl / cmucl
Commits: bf9f9d5e by Raymond Toy at 2024-02-23T12:43:35-08:00 Revert "Remove visited weak pointer to static vector in phase 2"
This reverts commit a9b2d0819cfdeb20badfe5a9a7a146866136ca3a.
We're going to do the removal in a different way.
- - - - -
1 changed file:
- src/lisp/gencgc.c
Changes:
===================================== src/lisp/gencgc.c ===================================== @@ -5421,8 +5421,7 @@ size_weak_pointer(lispobj * where) static void scan_static_vectors(struct weak_pointer *static_vector_list) { - struct weak_pointer *wp = static_vector_list; - struct weak_pointer *previous = wp; + struct weak_pointer *wp;
DPRINTF(debug_static_array_p, (stdout, "Phase 2: Visit unused static vectors\n")); @@ -5433,9 +5432,7 @@ scan_static_vectors(struct weak_pointer *static_vector_list) * in the header to say we've visited it. If we've already * visited the static vector, break the weak pointer. */ - - while (wp) { - struct weak_pointer *next = wp->next; + for (wp = static_vector_list; wp; wp = wp->next) { lispobj *header = (lispobj *) PTR(wp->value);
DPRINTF(debug_static_array_p, @@ -5459,32 +5456,8 @@ scan_static_vectors(struct weak_pointer *static_vector_list)
wp->value = NIL; wp->broken = T; - /* - * Remove this weak pointer from static_vector_list; - * we're done processing it. - * - * Three cases here: - * - * 1. wp is the first in the list; update - * static_vector_list to skip over this pointer. - * - * 2. wp is the last (next = NULL); set the next - * slot of the previous pointer to NULL. - * - * 3. wp is in the middle; update the next slot of - * the previous pointer to the next value. - */ - if (wp == static_vector_list) { - static_vector_list = next; - } else if (next == NULL) { - previous->next = NULL; - } else { - previous->next = next; - } } } - previous = wp; - wp = next; }
@@ -5500,31 +5473,29 @@ scan_static_vectors(struct weak_pointer *static_vector_list) * free the static vector. Also break the weak pointer too, since * the space has been freed. */ - wp = static_vector_list; - while (wp) { - struct weak_pointer *next = wp->next; - lispobj *header = (lispobj *) PTR(wp->value); + for (wp = static_vector_list; wp; wp = wp->next) { /* Skip over broken weak pointers */ + if (wp->broken == NIL) { + lispobj *header = (lispobj *) PTR(wp->value);
- DPRINTF(debug_static_array_p, - (stdout, " wp %p value %p header 0x%08lx\n", - wp, (lispobj*) wp->value, *header)); - - gc_assert(wp->broken == NIL); - /* - * Only free the arrays where the mark bit is clear. - */ - if ((*header & STATIC_VECTOR_MARK_BIT) == 0) { - lispobj *static_array = (lispobj *) PTR(wp->value); DPRINTF(debug_static_array_p, - (stdout, " Free static vector\n")); + (stdout, " wp %p value %p header 0x%08lx\n", + wp, (lispobj*) wp->value, *header));
- wp->value = NIL; - wp->broken = T; + /* + * Only free the arrays where the mark bit is clear. + */ + if ((*header & STATIC_VECTOR_MARK_BIT) == 0) { + lispobj *static_array = (lispobj *) PTR(wp->value); + DPRINTF(debug_static_array_p, + (stdout, " Free static vector\n")); + + wp->value = NIL; + wp->broken = T;
- free(static_array); + free(static_array); + } } - wp = next; }
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/bf9f9d5edc0427a57a5d2e1e...