[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/hash-table-perf 8811c5d81e7 27/35: Don't dump Qunbound
From: |
Mattias Engdegård |
Subject: |
scratch/hash-table-perf 8811c5d81e7 27/35: Don't dump Qunbound |
Date: |
Fri, 12 Jan 2024 10:53:26 -0500 (EST) |
branch: scratch/hash-table-perf
commit 8811c5d81e71d75268f0d81cfcbbe93be8e0035e
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Don't dump Qunbound
The dumper uses a hash table to keep track of dumped objects but as
this clashes with the use of Qunbound for marking unused hash table
entries, don't dump that value at all. The symbol name is fixed up
after loading.
An alternative solution would be to use a different unique value for
unused entries.
* src/pdumper.c (dump_object_needs_dumping_p): Skip Qunbound.
(dump_vectorlike_generic): New function.
(pdumper_load): Call it.
---
src/fns.c | 1 +
src/pdumper.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/fns.c b/src/fns.c
index a051a155723..48c0e603c5d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4812,6 +4812,7 @@ ptrdiff_t
hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value,
hash_hash_t hash)
{
+ eassert (!BASE_EQ (key, Qunbound));
/* Increment count after resizing because resizing may fail. */
maybe_resize_hash_table (h);
h->count++;
diff --git a/src/pdumper.c b/src/pdumper.c
index bc7d8fac5fe..3f6240a5076 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -1337,7 +1337,9 @@ dump_object_needs_dumping_p (Lisp_Object object)
included in the dump despite all references to them being
bitwise-invariant. */
return (!dump_object_self_representing_p (object)
- || dump_object_emacs_ptr (object));
+ || (dump_object_emacs_ptr (object)
+ /* Don't dump Qunbound -- it's not a legal hash table key. */
+ && !BASE_EQ (object, Qunbound)));
}
static void
@@ -2551,6 +2553,19 @@ dump_symbol (struct dump_context *ctx,
return offset;
}
+/* Give Qunbound its name.
+ All other symbols are dumped and loaded but not Qunbound because it
+ cannot be used as a key in a hash table.
+ FIXME: A better solution would be to use a value other than Qunbound
+ as a marker for unused entries in hash tables. */
+static void
+pdumper_init_symbol_unbound (void)
+{
+ eassert (NILP (SYMBOL_NAME (Qunbound)));
+ const char *name = "unbound";
+ init_symbol (Qunbound, make_pure_c_string (name, strlen (name)));
+}
+
static dump_off
dump_vectorlike_generic (struct dump_context *ctx,
const union vectorlike_header *header)
@@ -5749,6 +5764,8 @@ pdumper_load (const char *dump_filename, char *argv0)
for (int i = 0; i < nr_dump_hooks; ++i)
dump_hooks[i] ();
+ pdumper_init_symbol_unbound ();
+
#ifdef HAVE_NATIVE_COMP
pdumper_set_emacs_execdir (argv0);
#else
- scratch/hash-table-perf 422c91a822a 02/35: ; * src/pdumper.c (dump_hash_table): Remove unused argument., (continued)
- scratch/hash-table-perf 422c91a822a 02/35: ; * src/pdumper.c (dump_hash_table): Remove unused argument., Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf f2d6e2713c0 07/35: Refactor hash table vector reallocation, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf dd4ee2c634b 15/35: Represent hash table weakness as an enum internally, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 615d3e4cdc6 17/35: Leaner hash table dumping and thawing, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf d003b84c484 19/35: Use non-Lisp allocation for internal hash-table vectors, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf afd2185bfdb 20/35: Store hash values as integers instead of Lisp_Object, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf c98ba3d4fa6 21/35: Inlined and specialised hash table look-up, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 414470d1e24 23/35: Share hash table test structs, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 589318470c1 24/35: ; Reorder structs (hash and test), Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf bf1f1c5a9a4 25/35: Faster hash table growth, starting smaller, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 8811c5d81e7 27/35: Don't dump Qunbound,
Mattias Engdegård <=
- scratch/hash-table-perf ef0323e9029 30/35: Adapt hash functions to produce a hash_hash_t eventually, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf c805d2173f8 33/35: Use a static index vector for zero-sized tables, Mattias Engdegård, 2024/01/12
- scratch/hash-table-perf 8884720dce8 34/35: Change default hash table size to 0, Mattias Engdegård, 2024/01/12