[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3c8167ec0f9: Fit symbol_redirect snugly in two bits
From: |
Mattias Engdegård |
Subject: |
master 3c8167ec0f9: Fit symbol_redirect snugly in two bits |
Date: |
Sun, 16 Apr 2023 08:46:39 -0400 (EDT) |
branch: master
commit 3c8167ec0f9647e6fc33e65b0a0324f96cb795ee
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Fit symbol_redirect snugly in two bits
This allows the C compiler to do away with all default clauses when
switching on the `redirect` field.
* src/lisp.h (enum symbol_redirect): Use values in the 0..3 range,
which also matches the old comment in struct Lisp_Symbol.
(enum symbol_interned, enum symbol_redirect)
(enum symbol_trapped_write): Comment members. Remove explicit values.
(struct Lisp_Symbol): Shrink the `redirect` member to 2 bits.
Use the correct type for the `interned` field.
Move value comments to their types.
* src/pdumper.c (dump_symbol): Update hashes.
---
src/lisp.h | 36 ++++++++++++++----------------------
src/pdumper.c | 4 ++--
2 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/src/lisp.h b/src/lisp.h
index 78b68880702..4e17e369312 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -810,24 +810,24 @@ typedef struct { void const *fwdptr; } lispfwd;
enum symbol_interned
{
- SYMBOL_UNINTERNED = 0,
- SYMBOL_INTERNED = 1,
- SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2
+ SYMBOL_UNINTERNED, /* not interned anywhere */
+ SYMBOL_INTERNED, /* interned but not in initial obarray */
+ SYMBOL_INTERNED_IN_INITIAL_OBARRAY /* interned in initial obarray */
};
enum symbol_redirect
{
- SYMBOL_PLAINVAL = 4,
- SYMBOL_VARALIAS = 1,
- SYMBOL_LOCALIZED = 2,
- SYMBOL_FORWARDED = 3
+ SYMBOL_PLAINVAL, /* plain var, value is in the `value' field */
+ SYMBOL_VARALIAS, /* var alias, value is really in the `alias' symbol */
+ SYMBOL_LOCALIZED, /* localized var, value is in the `blv' object */
+ SYMBOL_FORWARDED /* forwarding var, value is in `forward' */
};
enum symbol_trapped_write
{
- SYMBOL_UNTRAPPED_WRITE = 0,
- SYMBOL_NOWRITE = 1,
- SYMBOL_TRAPPED_WRITE = 2
+ SYMBOL_UNTRAPPED_WRITE, /* normal case, just set the value */
+ SYMBOL_NOWRITE, /* constant, cannot set, e.g. nil, t, :keyword */
+ SYMBOL_TRAPPED_WRITE /* trap the write, call watcher functions */
};
struct Lisp_Symbol
@@ -838,21 +838,13 @@ struct Lisp_Symbol
{
bool_bf gcmarkbit : 1;
- /* Indicates where the value can be found:
- 0 : it's a plain var, the value is in the `value' field.
- 1 : it's a varalias, the value is really in the `alias' symbol.
- 2 : it's a localized var, the value is in the `blv' object.
- 3 : it's a forwarding variable, the value is in `forward'. */
- ENUM_BF (symbol_redirect) redirect : 3;
+ /* Indicates where the value can be found. */
+ ENUM_BF (symbol_redirect) redirect : 2;
- /* 0 : normal case, just set the value
- 1 : constant, cannot set, e.g. nil, t, :keywords.
- 2 : trap the write, call watcher functions. */
ENUM_BF (symbol_trapped_write) trapped_write : 2;
- /* Interned state of the symbol. This is an enumerator from
- enum symbol_interned. */
- unsigned interned : 2;
+ /* Interned state of the symbol. */
+ ENUM_BF (symbol_interned) interned : 2;
/* True means that this variable has been explicitly declared
special (with `defvar' etc), and shouldn't be lexically bound. */
diff --git a/src/pdumper.c b/src/pdumper.c
index 2c3828081fa..339aed1f657 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2459,10 +2459,10 @@ dump_symbol (struct dump_context *ctx,
Lisp_Object object,
dump_off offset)
{
-#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_999DC26DEC
+#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_61B174C9F4
# error "Lisp_Symbol changed. See CHECK_STRUCTS comment in config.h."
#endif
-#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_ADB4F5B113)
+#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_EA72E4BFF5)
# error "symbol_redirect changed. See CHECK_STRUCTS comment in config.h."
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3c8167ec0f9: Fit symbol_redirect snugly in two bits,
Mattias Engdegård <=