aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 15bb65cf74f..16257469aa6 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -360,13 +360,13 @@ static struct gcstat
360 object_ct total_intervals, total_free_intervals; 360 object_ct total_intervals, total_free_intervals;
361 object_ct total_buffers; 361 object_ct total_buffers;
362 362
363 /* Size of the ancillary arrays of live hash-table objects. 363 /* Size of the ancillary arrays of live hash-table and obarray objects.
364 The objects themselves are not included (counted as vectors above). */ 364 The objects themselves are not included (counted as vectors above). */
365 byte_ct total_hash_table_bytes; 365 byte_ct total_hash_table_bytes;
366} gcstat; 366} gcstat;
367 367
368/* Total size of ancillary arrays of all allocated hash-table objects, 368/* Total size of ancillary arrays of all allocated hash-table and obarray
369 both dead and alive. This number is always kept up-to-date. */ 369 objects, both dead and alive. This number is always kept up-to-date. */
370static ptrdiff_t hash_table_allocated_bytes = 0; 370static ptrdiff_t hash_table_allocated_bytes = 0;
371 371
372/* Points to memory space allocated as "spare", to be freed if we run 372/* Points to memory space allocated as "spare", to be freed if we run
@@ -3443,7 +3443,7 @@ cleanup_vector (struct Lisp_Vector *vector)
3443 struct Lisp_Hash_Table *h = PSEUDOVEC_STRUCT (vector, Lisp_Hash_Table); 3443 struct Lisp_Hash_Table *h = PSEUDOVEC_STRUCT (vector, Lisp_Hash_Table);
3444 if (h->table_size > 0) 3444 if (h->table_size > 0)
3445 { 3445 {
3446 eassert (h->index_size > 1); 3446 eassert (h->index_bits > 0);
3447 xfree (h->index); 3447 xfree (h->index);
3448 xfree (h->key_and_value); 3448 xfree (h->key_and_value);
3449 xfree (h->next); 3449 xfree (h->next);
@@ -3451,10 +3451,19 @@ cleanup_vector (struct Lisp_Vector *vector)
3451 ptrdiff_t bytes = (h->table_size * (2 * sizeof *h->key_and_value 3451 ptrdiff_t bytes = (h->table_size * (2 * sizeof *h->key_and_value
3452 + sizeof *h->hash 3452 + sizeof *h->hash
3453 + sizeof *h->next) 3453 + sizeof *h->next)
3454 + h->index_size * sizeof *h->index); 3454 + hash_table_index_size (h) * sizeof *h->index);
3455 hash_table_allocated_bytes -= bytes; 3455 hash_table_allocated_bytes -= bytes;
3456 } 3456 }
3457 } 3457 }
3458 break;
3459 case PVEC_OBARRAY:
3460 {
3461 struct Lisp_Obarray *o = PSEUDOVEC_STRUCT (vector, Lisp_Obarray);
3462 xfree (o->buckets);
3463 ptrdiff_t bytes = obarray_size (o) * sizeof *o->buckets;
3464 hash_table_allocated_bytes -= bytes;
3465 }
3466 break;
3458 /* Keep the switch exhaustive. */ 3467 /* Keep the switch exhaustive. */
3459 case PVEC_NORMAL_VECTOR: 3468 case PVEC_NORMAL_VECTOR:
3460 case PVEC_FREE: 3469 case PVEC_FREE:
@@ -3951,7 +3960,7 @@ Its value is void, and its function definition and property list are nil. */)
3951 if (symbol_free_list) 3960 if (symbol_free_list)
3952 { 3961 {
3953 ASAN_UNPOISON_SYMBOL (symbol_free_list); 3962 ASAN_UNPOISON_SYMBOL (symbol_free_list);
3954 XSETSYMBOL (val, symbol_free_list); 3963 val = make_lisp_symbol (symbol_free_list);
3955 symbol_free_list = symbol_free_list->u.s.next; 3964 symbol_free_list = symbol_free_list->u.s.next;
3956 } 3965 }
3957 else 3966 else
@@ -3967,7 +3976,7 @@ Its value is void, and its function definition and property list are nil. */)
3967 } 3976 }
3968 3977
3969 ASAN_UNPOISON_SYMBOL (&symbol_block->symbols[symbol_block_index]); 3978 ASAN_UNPOISON_SYMBOL (&symbol_block->symbols[symbol_block_index]);
3970 XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index]); 3979 val = make_lisp_symbol (&symbol_block->symbols[symbol_block_index]);
3971 symbol_block_index++; 3980 symbol_block_index++;
3972 } 3981 }
3973 3982
@@ -5632,7 +5641,8 @@ valid_lisp_object_p (Lisp_Object obj)
5632 return 0; 5641 return 0;
5633} 5642}
5634 5643
5635/* Like xmalloc, but makes allocation count toward the total consing. 5644/* Like xmalloc, but makes allocation count toward the total consing
5645 and hash table or obarray usage.
5636 Return NULL for a zero-sized allocation. */ 5646 Return NULL for a zero-sized allocation. */
5637void * 5647void *
5638hash_table_alloc_bytes (ptrdiff_t nbytes) 5648hash_table_alloc_bytes (ptrdiff_t nbytes)
@@ -5959,7 +5969,8 @@ purecopy_hash_table (struct Lisp_Hash_Table *table)
5959 for (ptrdiff_t i = 0; i < nvalues; i++) 5969 for (ptrdiff_t i = 0; i < nvalues; i++)
5960 pure->key_and_value[i] = purecopy (table->key_and_value[i]); 5970 pure->key_and_value[i] = purecopy (table->key_and_value[i]);
5961 5971
5962 ptrdiff_t index_bytes = table->index_size * sizeof *table->index; 5972 ptrdiff_t index_bytes = hash_table_index_size (table)
5973 * sizeof *table->index;
5963 pure->index = pure_alloc (index_bytes, -(int)sizeof *table->index); 5974 pure->index = pure_alloc (index_bytes, -(int)sizeof *table->index);
5964 memcpy (pure->index, table->index, index_bytes); 5975 memcpy (pure->index, table->index, index_bytes);
5965 } 5976 }
@@ -6033,8 +6044,7 @@ purecopy (Lisp_Object obj)
6033 return obj; /* Don't hash cons it. */ 6044 return obj; /* Don't hash cons it. */
6034 } 6045 }
6035 6046
6036 struct Lisp_Hash_Table *h = purecopy_hash_table (table); 6047 obj = make_lisp_hash_table (purecopy_hash_table (table));
6037 XSET_HASH_TABLE (obj, h);
6038 } 6048 }
6039 else if (COMPILEDP (obj) || VECTORP (obj) || RECORDP (obj)) 6049 else if (COMPILEDP (obj) || VECTORP (obj) || RECORDP (obj))
6040 { 6050 {
@@ -7310,6 +7320,14 @@ process_mark_stack (ptrdiff_t base_sp)
7310 break; 7320 break;
7311 } 7321 }
7312 7322
7323 case PVEC_OBARRAY:
7324 {
7325 struct Lisp_Obarray *o = (struct Lisp_Obarray *)ptr;
7326 set_vector_marked (ptr);
7327 mark_stack_push_values (o->buckets, obarray_size (o));
7328 break;
7329 }
7330
7313 case PVEC_CHAR_TABLE: 7331 case PVEC_CHAR_TABLE:
7314 case PVEC_SUB_CHAR_TABLE: 7332 case PVEC_SUB_CHAR_TABLE:
7315 mark_char_table (ptr, (enum pvec_type) pvectype); 7333 mark_char_table (ptr, (enum pvec_type) pvectype);
@@ -7380,12 +7398,8 @@ process_mark_stack (ptrdiff_t base_sp)
7380 mark_stack_push_value (SYMBOL_VAL (ptr)); 7398 mark_stack_push_value (SYMBOL_VAL (ptr));
7381 break; 7399 break;
7382 case SYMBOL_VARALIAS: 7400 case SYMBOL_VARALIAS:
7383 { 7401 mark_stack_push_value (make_lisp_symbol (SYMBOL_ALIAS (ptr)));
7384 Lisp_Object tem; 7402 break;
7385 XSETSYMBOL (tem, SYMBOL_ALIAS (ptr));
7386 mark_stack_push_value (tem);
7387 break;
7388 }
7389 case SYMBOL_LOCALIZED: 7403 case SYMBOL_LOCALIZED:
7390 { 7404 {
7391 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr); 7405 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr);