emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/igc 38c1470aeac: Obarray bucket allocation


From: Gerd Moellmann
Subject: scratch/igc 38c1470aeac: Obarray bucket allocation
Date: Thu, 18 Apr 2024 14:26:41 -0400 (EDT)

branch: scratch/igc
commit 38c1470aeac5bbd2e30e9262a9dead12278e032a
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>

    Obarray bucket allocation
---
 src/alloc.c |  4 ++--
 src/lisp.h  |  2 +-
 src/lread.c | 10 +++++++++-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 07c453deeda..dccdbb3d5ea 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5800,7 +5800,7 @@ hash_table_free_bytes (void *p, ptrdiff_t nbytes)
 }
 
 Lisp_Object *
-hash_table_alloc_kv (struct Lisp_Hash_Table *h, ptrdiff_t nobjs)
+hash_table_alloc_kv (void *h, ptrdiff_t nobjs)
 {
   if (nobjs == 0)
     return NULL;
@@ -5809,7 +5809,7 @@ hash_table_alloc_kv (struct Lisp_Hash_Table *h, ptrdiff_t 
nobjs)
      keys/values, we have a problem with dumped hash tables because we
      can scan the dump, but don't see the malloc'd parts. So, we have to
      create additional roots for that. This will go away when
-     implementing weak tables. */
+     implementing weak tables. Similar for obarrays. */
   if (pdumper_object_p (h))
     return igc_xalloc_lisp_objs_exact (nobjs);
 #endif
diff --git a/src/lisp.h b/src/lisp.h
index dd558badb4d..98ee07b0409 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4687,7 +4687,7 @@ extern int valid_lisp_object_p (Lisp_Object);
 
 void *hash_table_alloc_bytes (ptrdiff_t nbytes) ATTRIBUTE_MALLOC_SIZE ((1));
 void hash_table_free_bytes (void *p, ptrdiff_t nbytes);
-Lisp_Object *hash_table_alloc_kv (struct Lisp_Hash_Table *h, ptrdiff_t nobjs);
+Lisp_Object *hash_table_alloc_kv (void *h, ptrdiff_t nobjs);
 void hash_table_free_kv (struct Lisp_Hash_Table *h, Lisp_Object *p);
 
 /* Defined in gmalloc.c.  */
diff --git a/src/lread.c b/src/lread.c
index b0ab51797f4..5a770a94133 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -5245,7 +5245,11 @@ make_obarray (unsigned bits)
   o->count = 0;
   o->size_bits = bits;
   ptrdiff_t size = (ptrdiff_t)1 << bits;
+#ifdef HAVE_MPS
+  o->buckets = hash_table_alloc_kv (o, size);
+#else
   o->buckets = hash_table_alloc_bytes (size * sizeof *o->buckets);
+#endif
   for (ptrdiff_t i = 0; i < size; i++)
     o->buckets[i] = make_fixnum (0);
   return make_lisp_obarray (o);
@@ -5268,8 +5272,12 @@ grow_obarray (struct Lisp_Obarray *o)
   int new_bits = o->size_bits + 1;
   if (new_bits > obarray_max_bits)
     error ("Obarray too big");
-  ptrdiff_t new_size = (ptrdiff_t)1 << new_bits;
+  ptrdiff_t new_size = (ptrdiff_t) 1 << new_bits;
+#ifdef HAVE_MPS
+  o->buckets = hash_table_alloc_kv (o, new_size);
+#else
   o->buckets = hash_table_alloc_bytes (new_size * sizeof *o->buckets);
+#endif
   for (ptrdiff_t i = 0; i < new_size; i++)
     o->buckets[i] = make_fixnum (0);
   o->size_bits = new_bits;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]