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

Commits:

1 changed file:

Changes:

  • src/lisp/gencgc.c
    ... ... @@ -5421,8 +5421,7 @@ size_weak_pointer(lispobj * where)
    5421 5421
     static void
    
    5422 5422
     scan_static_vectors(struct weak_pointer *static_vector_list)
    
    5423 5423
     {
    
    5424
    -    struct weak_pointer *wp = static_vector_list;
    
    5425
    -    struct weak_pointer *previous = wp;
    
    5424
    +    struct weak_pointer *wp;
    
    5426 5425
     
    
    5427 5426
         DPRINTF(debug_static_array_p,
    
    5428 5427
                 (stdout, "Phase 2: Visit unused static vectors\n"));
    
    ... ... @@ -5433,9 +5432,7 @@ scan_static_vectors(struct weak_pointer *static_vector_list)
    5433 5432
          * in the header to say we've visited it.  If we've already
    
    5434 5433
          * visited the static vector, break the weak pointer.
    
    5435 5434
          */
    
    5436
    -
    
    5437
    -    while (wp) {
    
    5438
    -        struct weak_pointer *next = wp->next;
    
    5435
    +    for (wp = static_vector_list; wp; wp = wp->next) {
    
    5439 5436
             lispobj *header = (lispobj *) PTR(wp->value);
    
    5440 5437
     
    
    5441 5438
             DPRINTF(debug_static_array_p,
    
    ... ... @@ -5459,32 +5456,8 @@ scan_static_vectors(struct weak_pointer *static_vector_list)
    5459 5456
     
    
    5460 5457
                     wp->value = NIL;
    
    5461 5458
                     wp->broken = T;
    
    5462
    -                /*
    
    5463
    -                 * Remove this weak pointer from static_vector_list;
    
    5464
    -                 * we're done processing it.
    
    5465
    -                 *
    
    5466
    -                 * Three cases here:
    
    5467
    -                 *
    
    5468
    -                 *   1. wp is the first in the list; update
    
    5469
    -                 *   static_vector_list to skip over this pointer.
    
    5470
    -                 *
    
    5471
    -                 *   2. wp is the last (next = NULL); set the next
    
    5472
    -                 *   slot of the previous pointer to NULL.
    
    5473
    -                 *
    
    5474
    -                 *   3. wp is in the middle; update the next slot of
    
    5475
    -                 *   the previous pointer to the next value.
    
    5476
    -                 */
    
    5477
    -                if (wp == static_vector_list) {
    
    5478
    -                    static_vector_list = next;
    
    5479
    -                } else if (next == NULL) {
    
    5480
    -                    previous->next = NULL;
    
    5481
    -                } else {
    
    5482
    -                    previous->next = next;
    
    5483
    -                }
    
    5484 5459
                 }
    
    5485 5460
             }
    
    5486
    -        previous = wp;
    
    5487
    -        wp = next;
    
    5488 5461
         }
    
    5489 5462
         
    
    5490 5463
     
    
    ... ... @@ -5500,31 +5473,29 @@ scan_static_vectors(struct weak_pointer *static_vector_list)
    5500 5473
          * free the static vector.  Also break the weak pointer too, since
    
    5501 5474
          * the space has been freed.
    
    5502 5475
          */
    
    5503
    -    wp = static_vector_list;
    
    5504
    -    while (wp) {
    
    5505
    -        struct weak_pointer *next = wp->next;
    
    5506
    -        lispobj *header = (lispobj *) PTR(wp->value);
    
    5476
    +    for (wp = static_vector_list; wp; wp = wp->next) {
    
    5507 5477
             /* Skip over broken weak pointers */
    
    5478
    +        if (wp->broken == NIL) {
    
    5479
    +            lispobj *header = (lispobj *) PTR(wp->value);
    
    5508 5480
     
    
    5509
    -        DPRINTF(debug_static_array_p,
    
    5510
    -                (stdout, "  wp %p value %p header 0x%08lx\n",
    
    5511
    -                 wp, (lispobj*) wp->value, *header));
    
    5512
    -
    
    5513
    -        gc_assert(wp->broken == NIL);
    
    5514
    -        /*
    
    5515
    -         * Only free the arrays where the mark bit is clear.
    
    5516
    -         */
    
    5517
    -        if ((*header & STATIC_VECTOR_MARK_BIT) == 0)  {
    
    5518
    -            lispobj *static_array = (lispobj *) PTR(wp->value);
    
    5519 5481
                 DPRINTF(debug_static_array_p,
    
    5520
    -                    (stdout, "    Free static vector\n"));
    
    5482
    +                    (stdout, "  wp %p value %p header 0x%08lx\n",
    
    5483
    +                     wp, (lispobj*) wp->value, *header));
    
    5521 5484
     
    
    5522
    -            wp->value = NIL;
    
    5523
    -            wp->broken = T;
    
    5485
    +            /*
    
    5486
    +             * Only free the arrays where the mark bit is clear.
    
    5487
    +             */
    
    5488
    +            if ((*header & STATIC_VECTOR_MARK_BIT) == 0)  {
    
    5489
    +                lispobj *static_array = (lispobj *) PTR(wp->value);
    
    5490
    +                DPRINTF(debug_static_array_p,
    
    5491
    +                        (stdout, "    Free static vector\n"));
    
    5492
    +
    
    5493
    +                wp->value = NIL;
    
    5494
    +                wp->broken = T;
    
    5524 5495
     
    
    5525
    -            free(static_array);
    
    5496
    +                free(static_array);
    
    5497
    +            }
    
    5526 5498
             }
    
    5527
    -        wp = next;
    
    5528 5499
         }
    
    5529 5500
         
    
    5530 5501