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

Commits:

1 changed file:

Changes:

  • src/lisp/gencgc.c
    ... ... @@ -2130,6 +2130,7 @@ static lispobj(*transother[256]) (lispobj object);
    2130 2130
     static int (*sizetab[256]) (lispobj * where);
    
    2131 2131
     
    
    2132 2132
     static struct weak_pointer *weak_pointers;
    
    2133
    +static struct weak_pointer *inuse_static_vector_list;
    
    2133 2134
     static struct scavenger_hook *scavenger_hooks = (struct scavenger_hook *) NIL;
    
    2134 2135
     
    
    2135 2136
     /* Like (ceiling x y), but y is constrained to be a power of two */
    
    ... ... @@ -5496,6 +5497,9 @@ scan_static_vectors_2(struct weak_pointer *static_vector_list,
    5496 5497
                 }
    
    5497 5498
             }
    
    5498 5499
         }
    
    5500
    +
    
    5501
    +    DPRINTF(debug_static_array_p,
    
    5502
    +            (stdout, "Phase 2 done\n"));
    
    5499 5503
     }
    
    5500 5504
     
    
    5501 5505
     /*
    
    ... ... @@ -5535,13 +5539,20 @@ scan_static_vectors_3(struct weak_pointer *freeable_list)
    5535 5539
     
    
    5536 5540
             free(static_array);
    
    5537 5541
         }
    
    5542
    +
    
    5543
    +    DPRINTF(debug_static_array_p,
    
    5544
    +            (stdout, "Phase 3 done\n"));
    
    5538 5545
     }
    
    5539 5546
     
    
    5540 5547
     /*
    
    5541
    - * Unmark all the vectors in inuse_list
    
    5548
    + * Unmark all the vectors in inuse_list.  This needs to be called at
    
    5549
    + * the end of GC to unmark any live static vectors so that for the
    
    5550
    + * next GC we can tell if the static vector is used or not.
    
    5551
    + * Otherwise, the vectors will always look as if they're in use
    
    5552
    + * because the mark bit is never changed.
    
    5542 5553
      */
    
    5543 5554
     static void
    
    5544
    -scan_static_vectors_4(struct weak_pointer *inuse_list)
    
    5555
    +unmark_static_vectors_in_use(struct weak_pointer *inuse_list)
    
    5545 5556
     {
    
    5546 5557
         struct weak_pointer *wp;
    
    5547 5558
     
    
    ... ... @@ -5571,6 +5582,9 @@ scan_static_vectors_4(struct weak_pointer *inuse_list)
    5571 5582
                 *header &= ~STATIC_VECTOR_MARK_BIT;
    
    5572 5583
             }
    
    5573 5584
         }
    
    5585
    +
    
    5586
    +    DPRINTF(debug_static_array_p,
    
    5587
    +            (stdout, "Phase 4 done\n"));
    
    5574 5588
     }
    
    5575 5589
     
    
    5576 5590
     static void
    
    ... ... @@ -5579,20 +5593,14 @@ scan_static_vectors(struct weak_pointer *static_vector_list)
    5579 5593
         /* List of weak pointers to static vectors that can be freed. */
    
    5580 5594
         struct weak_pointer *freeable_list = NULL;
    
    5581 5595
     
    
    5582
    -    /* List of weak pointers to static vectors that are in in use. */
    
    5583
    -    struct weak_pointer *inuse_list = NULL;
    
    5584
    -
    
    5585 5596
         /*
    
    5586 5597
          * For each weak pointer, add it either the inuse list or the
    
    5587 5598
          * freeable list.
    
    5588 5599
          */
    
    5589
    -    scan_static_vectors_2(static_vector_list, &freeable_list, &inuse_list);
    
    5600
    +    scan_static_vectors_2(static_vector_list, &freeable_list, &inuse_static_vector_list);
    
    5590 5601
     
    
    5591 5602
         /* Free the unused unique static vectors. */
    
    5592 5603
         scan_static_vectors_3(freeable_list);
    
    5593
    -
    
    5594
    -    /* Unmark all the static vectors that are still alive. */
    
    5595
    -    scan_static_vectors_4(inuse_list);
    
    5596 5604
     }
    
    5597 5605
     
    
    5598 5606
     void
    
    ... ... @@ -8241,6 +8249,8 @@ collect_garbage(unsigned last_gen)
    8241 8249
         int gen_to_wp;
    
    8242 8250
         int i;
    
    8243 8251
     
    
    8252
    +    inuse_static_vectors_lisit = NULL;
    
    8253
    +
    
    8244 8254
         boxed_region.free_pointer = (void *) get_current_region_free();
    
    8245 8255
     
    
    8246 8256
         /* Check last_gen */
    
    ... ... @@ -8380,6 +8390,13 @@ collect_garbage(unsigned last_gen)
    8380 8390
     	}
    
    8381 8391
     	scavenger_hooks = (struct scavenger_hook *) NIL;
    
    8382 8392
         }
    
    8393
    +
    
    8394
    +    /*
    
    8395
    +     * Unmark any live static vectors.  This needs to be done at the
    
    8396
    +     * very end when all GCs are done, lest we accidentally free a
    
    8397
    +     * static vector that was actually in use.
    
    8398
    +     */
    
    8399
    +    unmark_static_vectors_in_use(inuse_static_vector_list);
    
    8383 8400
     }
    
    8384 8401
     
    
    8385 8402