diff options
| author | Kim F. Storm | 2004-05-25 11:18:07 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-05-25 11:18:07 +0000 |
| commit | 6b67a5180dcb7547e0bbb63d1047031df63dbf3f (patch) | |
| tree | bd52a9e5217a98ac11a88e0ef064e9f0d3a62a4c /src/alloc.c | |
| parent | 1566f511f1f71aebb1eac3dc7fceddd1e6448a3b (diff) | |
| download | emacs-6b67a5180dcb7547e0bbb63d1047031df63dbf3f.tar.gz emacs-6b67a5180dcb7547e0bbb63d1047031df63dbf3f.zip | |
(marker_blocks_pending_free): New var.
(gc_sweep): Store free marker blocks on that list.
(Fgarbage_collect): Free them after undo-list cleanup.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c index 865675d96ad..bea6943c26e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2865,6 +2865,10 @@ int marker_block_index; | |||
| 2865 | 2865 | ||
| 2866 | union Lisp_Misc *marker_free_list; | 2866 | union Lisp_Misc *marker_free_list; |
| 2867 | 2867 | ||
| 2868 | /* Marker blocks which should be freed at end of GC. */ | ||
| 2869 | |||
| 2870 | struct marker_block *marker_blocks_pending_free; | ||
| 2871 | |||
| 2868 | /* Total number of marker blocks now in use. */ | 2872 | /* Total number of marker blocks now in use. */ |
| 2869 | 2873 | ||
| 2870 | int n_marker_blocks; | 2874 | int n_marker_blocks; |
| @@ -2875,6 +2879,7 @@ init_marker () | |||
| 2875 | marker_block = NULL; | 2879 | marker_block = NULL; |
| 2876 | marker_block_index = MARKER_BLOCK_SIZE; | 2880 | marker_block_index = MARKER_BLOCK_SIZE; |
| 2877 | marker_free_list = 0; | 2881 | marker_free_list = 0; |
| 2882 | marker_blocks_pending_free = 0; | ||
| 2878 | n_marker_blocks = 0; | 2883 | n_marker_blocks = 0; |
| 2879 | } | 2884 | } |
| 2880 | 2885 | ||
| @@ -4529,6 +4534,18 @@ returns nil, because real GC can't be done. */) | |||
| 4529 | } | 4534 | } |
| 4530 | } | 4535 | } |
| 4531 | 4536 | ||
| 4537 | /* Undo lists have been cleaned up, so we can free marker blocks now. */ | ||
| 4538 | |||
| 4539 | { | ||
| 4540 | struct marker_block *mblk; | ||
| 4541 | |||
| 4542 | while ((mblk = marker_blocks_pending_free) != 0) | ||
| 4543 | { | ||
| 4544 | marker_blocks_pending_free = mblk->next; | ||
| 4545 | lisp_free (mblk); | ||
| 4546 | } | ||
| 4547 | } | ||
| 4548 | |||
| 4532 | /* Clear the mark bits that we set in certain root slots. */ | 4549 | /* Clear the mark bits that we set in certain root slots. */ |
| 4533 | 4550 | ||
| 4534 | unmark_byte_stack (); | 4551 | unmark_byte_stack (); |
| @@ -5437,6 +5454,7 @@ gc_sweep () | |||
| 5437 | register int num_free = 0, num_used = 0; | 5454 | register int num_free = 0, num_used = 0; |
| 5438 | 5455 | ||
| 5439 | marker_free_list = 0; | 5456 | marker_free_list = 0; |
| 5457 | marker_blocks_pending_free = 0; | ||
| 5440 | 5458 | ||
| 5441 | for (mblk = marker_block; mblk; mblk = *mprev) | 5459 | for (mblk = marker_block; mblk; mblk = *mprev) |
| 5442 | { | 5460 | { |
| @@ -5467,19 +5485,20 @@ gc_sweep () | |||
| 5467 | /* If this block contains only free markers and we have already | 5485 | /* If this block contains only free markers and we have already |
| 5468 | seen more than two blocks worth of free markers then deallocate | 5486 | seen more than two blocks worth of free markers then deallocate |
| 5469 | this block. */ | 5487 | this block. */ |
| 5470 | #if 0 | ||
| 5471 | /* There may still be pointers to these markers from a buffer's | ||
| 5472 | undo list, so don't free them. KFS 2004-05-21 / | ||
| 5473 | if (this_free == MARKER_BLOCK_SIZE && num_free > MARKER_BLOCK_SIZE) | 5488 | if (this_free == MARKER_BLOCK_SIZE && num_free > MARKER_BLOCK_SIZE) |
| 5474 | { | 5489 | { |
| 5475 | *mprev = mblk->next; | 5490 | *mprev = mblk->next; |
| 5476 | /* Unhook from the free list. */ | 5491 | /* Unhook from the free list. */ |
| 5477 | marker_free_list = mblk->markers[0].u_free.chain; | 5492 | marker_free_list = mblk->markers[0].u_free.chain; |
| 5478 | lisp_free (mblk); | ||
| 5479 | n_marker_blocks--; | 5493 | n_marker_blocks--; |
| 5494 | |||
| 5495 | /* It is not safe to free the marker block at this stage, | ||
| 5496 | since there may still be pointers to these markers from | ||
| 5497 | a buffer's undo list. KFS 2004-05-25. */ | ||
| 5498 | mblk->next = marker_blocks_pending_free; | ||
| 5499 | marker_blocks_pending_free = mblk; | ||
| 5480 | } | 5500 | } |
| 5481 | else | 5501 | else |
| 5482 | #endif | ||
| 5483 | { | 5502 | { |
| 5484 | num_free += this_free; | 5503 | num_free += this_free; |
| 5485 | mprev = &mblk->next; | 5504 | mprev = &mblk->next; |