[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/lexspaces 02d8ef2 05/17: Move symbol value into separate binding
From: |
Andrea Corallo |
Subject: |
scratch/lexspaces 02d8ef2 05/17: Move symbol value into separate binding |
Date: |
Fri, 8 May 2020 16:43:07 -0400 (EDT) |
branch: scratch/lexspaces
commit 02d8ef242da4547fc6ebce8fc4df47581206a745
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>
Move symbol value into separate binding
---
src/alloc.c | 22 ++++++++++++----------
src/lisp.h | 18 +++++++++++-------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index 4bbc6e3..5199238 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3524,7 +3524,7 @@ init_symbol (Lisp_Object val, Lisp_Object name)
set_symbol_plist (val, Qnil);
p->u.s.redirect = SYMBOL_PLAINVAL;
p->u.s.val.value = Qunbound;
- set_symbol_function (val, Qnil);
+ p->u.s._function = Qnil;
set_symbol_next (val, NULL);
p->u.s.gcmarkbit = false;
p->u.s.interned = SYMBOL_UNINTERNED;
@@ -4510,7 +4510,7 @@ live_symbol_holding (struct mem_node *m, void *p)
{
cp = ptr_bounds_copy (cp, b);
struct Lisp_Symbol *s = p = cp -= offset % sizeof b->symbols[0];
- if (!deadp (SYMBOL_FUNCTION (s)))
+ if (!deadp (s->u.s._function))
return make_lisp_symbol (s);
}
}
@@ -6647,8 +6647,8 @@ mark_object (Lisp_Object arg)
CHECK_ALLOCATED_AND_LIVE_SYMBOL ();
set_symbol_marked(ptr);
/* Attempt to catch bogus objects. */
- eassert (valid_lisp_object_p (SYMBOL_FUNCTION (ptr)));
- mark_object (SYMBOL_FUNCTION (ptr));
+ eassert (valid_lisp_object_p (ptr->u.s._function));
+ mark_object (ptr->u.s._function);
mark_object (ptr->u.s.plist);
switch (ptr->u.s.redirect)
{
@@ -7005,7 +7005,9 @@ sweep_symbols (void)
sym->u.s.next = symbol_free_list;
symbol_free_list = sym;
/* FIXME */
- symbol_free_list->u.s._function = dead_object ();
+ if (!NILP (sym->u.s._function))
+ XBINDING (symbol_free_list->u.s._function)->b[curr_lexspace] =
+ dead_object ();
++this_free;
}
else
@@ -7013,7 +7015,7 @@ sweep_symbols (void)
++num_used;
sym->u.s.gcmarkbit = 0;
/* Attempt to catch bogus objects. */
- eassert (valid_lisp_object_p (SYMBOL_FUNCTION (sym)));
+ eassert (valid_lisp_object_p (sym->u.s._function));
}
}
@@ -7167,10 +7169,10 @@ symbol_uses_obj (Lisp_Object symbol, Lisp_Object obj)
struct Lisp_Symbol *sym = XSYMBOL (symbol);
Lisp_Object val = find_symbol_value (symbol);
return (EQ (val, obj)
- || EQ (SYMBOL_FUNCTION (sym), obj)
- || (!NILP (SYMBOL_FUNCTION (sym))
- && COMPILEDP (SYMBOL_FUNCTION (sym))
- && EQ (AREF (SYMBOL_FUNCTION (sym), COMPILED_BYTECODE), obj))
+ || EQ (sym->u.s._function, obj)
+ || (!NILP (sym->u.s._function)
+ && COMPILEDP (sym->u.s._function)
+ && EQ (AREF (sym->u.s._function, COMPILED_BYTECODE), obj))
|| (!NILP (val)
&& COMPILEDP (val)
&& EQ (AREF (val, COMPILED_BYTECODE), obj)));
diff --git a/src/lisp.h b/src/lisp.h
index 7bf8222..29df243 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2171,7 +2171,7 @@ typedef jmp_buf sys_jmp_buf;
extern EMACS_INT curr_lexspace;
-INLINE Lisp_Object make_binding (void);
+INLINE Lisp_Object make_binding (Lisp_Object);
struct Lisp_Binding
{
@@ -2219,7 +2219,9 @@ SYMBOL_VAL (struct Lisp_Symbol *sym)
INLINE Lisp_Object
SYMBOL_FUNCTION (struct Lisp_Symbol *sym)
{
- return sym->u.s._function;
+ if (!NILP (sym->u.s._function))
+ return XBINDING (sym->u.s._function)->b[curr_lexspace];
+ return Qnil;
}
INLINE struct Lisp_Symbol *
@@ -2247,7 +2249,7 @@ SET_SYMBOL_VAL (struct Lisp_Symbol *sym, Lisp_Object v)
{
eassert (sym->u.s.redirect == SYMBOL_PLAINVAL);
if (EQ (sym->u.s.val.value, Qunbound))
- sym->u.s.val.value = make_binding ();
+ sym->u.s.val.value = make_binding (Qunbound);
struct Lisp_Binding *binding = XBINDING (sym->u.s.val.value);
binding->b[curr_lexspace] = v;
}
@@ -3429,8 +3431,10 @@ set_hash_value_slot (struct Lisp_Hash_Table *h,
ptrdiff_t idx, Lisp_Object val)
INLINE void
set_symbol_function (Lisp_Object sym, Lisp_Object function)
{
- /* FIXME */
- XSYMBOL (sym)->u.s._function = function;
+ struct Lisp_Symbol *s = XSYMBOL (sym);
+ if (NILP (s->u.s._function))
+ s->u.s._function = make_binding (Qnil);
+ XBINDING (s->u.s._function)->b[curr_lexspace] = function;
}
INLINE void
@@ -5086,13 +5090,13 @@ maybe_gc (void)
}
INLINE Lisp_Object
-make_binding (void)
+make_binding (Lisp_Object init_val)
{
struct Lisp_Binding *binding =
ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Binding,
b[MAX_LEXSPACES - 1], PVEC_BINDING);
for (EMACS_INT i = 0; i < MAX_LEXSPACES; i++)
- binding->b[i] = Qunbound;
+ binding->b[i] = init_val;
return make_lisp_ptr (binding, Lisp_Vectorlike);
}
- branch scratch/lexspaces created (now e2f183c), Andrea Corallo, 2020/05/08
- scratch/lexspaces 67e28d9 02/17: Adding binding pseudovector, Andrea Corallo, 2020/05/08
- scratch/lexspaces 2d1e916 01/17: Add lexspaces.c, Andrea Corallo, 2020/05/08
- scratch/lexspaces 64e442b 04/17: Add SYMBOL_FUNCTION accessor function, Andrea Corallo, 2020/05/08
- scratch/lexspaces 02d8ef2 05/17: Move symbol value into separate binding,
Andrea Corallo <=
- scratch/lexspaces 3a57250 06/17: Add lexspace-make-from, Andrea Corallo, 2020/05/08
- scratch/lexspaces 7fecbf5 08/17: Add lexspace redirection, Andrea Corallo, 2020/05/08
- scratch/lexspaces 09821e3 03/17: Store symbol value into the binding, Andrea Corallo, 2020/05/08
- scratch/lexspaces 04ac507 14/17: Remove unnecessary assertion, Andrea Corallo, 2020/05/08
- scratch/lexspaces 00108a5 15/17: Fix sweep_symbols, Andrea Corallo, 2020/05/08
- scratch/lexspaces 295ac3d 07/17: Make in-lexspace do something, Andrea Corallo, 2020/05/08
- scratch/lexspaces 610552d 10/17: Add SYMBOL_FUNC_LEXSPACE, Andrea Corallo, 2020/05/08
- scratch/lexspaces 9091913 13/17: Rename lexspace-make-from -> lexspace-make, Andrea Corallo, 2020/05/08
- scratch/lexspaces e2f183c 17/17: Shallow setters by default are not a good idea, Andrea Corallo, 2020/05/08
- scratch/lexspaces 73363e9 09/17: Store lexspace in closures, Andrea Corallo, 2020/05/08