mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Remove weak-ref
This commit is contained in:
parent
6b3f53bde6
commit
399b76455f
7 changed files with 1 additions and 154 deletions
|
|
@ -292,8 +292,6 @@ a fixed set of types. */)
|
|||
return Qsqlite;
|
||||
case PVEC_SUB_CHAR_TABLE:
|
||||
return Qsub_char_table;
|
||||
case PVEC_WEAK_REF:
|
||||
return Qweak_ref;
|
||||
|
||||
/* "Impossible" cases. */
|
||||
case PVEC_MISC_PTR:
|
||||
|
|
@ -4198,7 +4196,6 @@ syms_of_data (void)
|
|||
DEFSYM (Qtreesit_node, "treesit-node");
|
||||
DEFSYM (Qtreesit_compiled_query, "treesit-compiled-query");
|
||||
DEFSYM (Qobarray, "obarray");
|
||||
DEFSYM (Qweak_ref, "weak-ref");
|
||||
|
||||
DEFSYM (Qdefun, "defun");
|
||||
|
||||
|
|
|
|||
100
src/igc.c
100
src/igc.c
|
|
@ -205,7 +205,6 @@ static const char *obj_type_names[] = {
|
|||
"IGC_OBJ_FACE_CACHE",
|
||||
"IGC_OBJ_FLOAT",
|
||||
"IGC_OBJ_BLV",
|
||||
"IGC_OBJ_WEAK",
|
||||
"IGC_OBJ_PTR_VEC",
|
||||
"IGC_OBJ_OBJ_VEC",
|
||||
"IGC_OBJ_HANDLER",
|
||||
|
|
@ -262,7 +261,6 @@ static const char *pvec_type_names[] = {
|
|||
"PVEC_TS_NODE",
|
||||
"PVEC_TS_COMPILED_QUERY",
|
||||
"PVEC_SQLITE",
|
||||
"PVEC_WEAK_REF",
|
||||
"PVEC_CLOSURE",
|
||||
"PVEC_CHAR_TABLE",
|
||||
"PVEC_SUB_CHAR_TABLE",
|
||||
|
|
@ -1225,40 +1223,6 @@ fix_obj_vec (mps_ss_t ss, Lisp_Object *v)
|
|||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
static mps_res_t
|
||||
fix_weak_ref (mps_ss_t ss, struct Lisp_Weak_Ref *wref)
|
||||
{
|
||||
MPS_SCAN_BEGIN (ss)
|
||||
{
|
||||
IGC_FIX12_OBJ (ss, &wref->ref);
|
||||
}
|
||||
MPS_SCAN_END (ss);
|
||||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
/* MPS docs 7.4 says that weak objects must must follow certain rules to
|
||||
enable instruction emulation on 32-bit Windows and Linux x86 systems.
|
||||
This doesn't follow the rules. */
|
||||
|
||||
static mps_res_t
|
||||
fix_weak (mps_ss_t ss, struct Lisp_Vector* v)
|
||||
{
|
||||
MPS_SCAN_BEGIN (ss)
|
||||
{
|
||||
switch (pseudo_vector_type (v))
|
||||
{
|
||||
case PVEC_WEAK_REF:
|
||||
IGC_FIX_CALL_FN (ss, struct Lisp_Weak_Ref, v, fix_weak_ref);
|
||||
break;
|
||||
|
||||
default:
|
||||
igc_assert (!"fix_weak");
|
||||
}
|
||||
}
|
||||
MPS_SCAN_END (ss);
|
||||
return MPS_RES_OK;
|
||||
}
|
||||
|
||||
static mps_res_t
|
||||
fix_cons (mps_ss_t ss, struct Lisp_Cons *cons)
|
||||
{
|
||||
|
|
@ -1409,10 +1373,6 @@ dflt_scan_obj (mps_ss_t ss, mps_addr_t base_start, mps_addr_t base_limit,
|
|||
IGC_FIX_CALL_FN (ss, struct Lisp_Buffer_Local_Value, client,
|
||||
fix_blv);
|
||||
break;
|
||||
|
||||
case IGC_OBJ_WEAK:
|
||||
IGC_FIX_CALL_FN (ss, struct Lisp_Vector, client, fix_weak);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MPS_SCAN_END (ss);
|
||||
|
|
@ -1983,9 +1943,6 @@ fix_vector (mps_ss_t ss, struct Lisp_Vector *v)
|
|||
#endif
|
||||
IGC_FIX_CALL_FN (ss, struct Lisp_Vector, v, fix_vectorlike);
|
||||
break;
|
||||
|
||||
case PVEC_WEAK_REF:
|
||||
emacs_abort ();
|
||||
}
|
||||
}
|
||||
MPS_SCAN_END (ss);
|
||||
|
|
@ -2656,7 +2613,6 @@ finalize_vector (mps_addr_t v)
|
|||
case PVEC_XWIDGET_VIEW:
|
||||
case PVEC_TERMINAL:
|
||||
case PVEC_MARKER:
|
||||
case PVEC_WEAK_REF:
|
||||
case PVEC_MODULE_GLOBAL_REFERENCE:
|
||||
igc_assert (!"finalization not implemented");
|
||||
break;
|
||||
|
|
@ -2692,7 +2648,6 @@ finalize (struct igc *gc, mps_addr_t base)
|
|||
case IGC_OBJ_FACE:
|
||||
case IGC_OBJ_FACE_CACHE:
|
||||
case IGC_OBJ_FLOAT:
|
||||
case IGC_OBJ_WEAK:
|
||||
case IGC_OBJ_BLV:
|
||||
case IGC_OBJ_PTR_VEC:
|
||||
case IGC_OBJ_OBJ_VEC:
|
||||
|
|
@ -2756,7 +2711,6 @@ maybe_finalize (mps_addr_t client, enum pvec_type tag)
|
|||
#ifdef IN_MY_FORK
|
||||
case PVEC_PACKAGE:
|
||||
#endif
|
||||
case PVEC_WEAK_REF:
|
||||
case PVEC_MODULE_GLOBAL_REFERENCE:
|
||||
break;
|
||||
}
|
||||
|
|
@ -2841,9 +2795,6 @@ thread_ap (enum igc_obj_type type)
|
|||
case IGC_OBJ_NUM_TYPES:
|
||||
emacs_abort ();
|
||||
|
||||
case IGC_OBJ_WEAK:
|
||||
return t->d.weak_weak_ap;
|
||||
|
||||
case IGC_OBJ_VECTOR:
|
||||
case IGC_OBJ_CONS:
|
||||
case IGC_OBJ_SYMBOL:
|
||||
|
|
@ -3227,41 +3178,6 @@ igc_make_image_cache (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
DEFUN ("igc-make-weak-ref", Figc_make_weak_ref, Sigc_make_weak_ref, 1, 1, 0,
|
||||
doc
|
||||
: /* todo */)
|
||||
(Lisp_Object target)
|
||||
{
|
||||
const enum pvec_type type = PVEC_WEAK_REF;
|
||||
struct Lisp_Weak_Ref *wref = alloc (sizeof *wref, IGC_OBJ_WEAK);
|
||||
int nwords_lisp = VECSIZE (struct Lisp_Weak_Ref);
|
||||
XSETPVECTYPESIZE (wref, type, nwords_lisp, 0);
|
||||
wref->ref = target;
|
||||
Lisp_Object obj = make_lisp_ptr (wref, Lisp_Vectorlike);
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
CHECK_WEAK_REF_P (Lisp_Object x)
|
||||
{
|
||||
CHECK_TYPE (WEAK_REF_P (x), Qweak_ref_p, x);
|
||||
}
|
||||
|
||||
Lisp_Object
|
||||
igc_weak_ref_deref (struct Lisp_Weak_Ref *wref)
|
||||
{
|
||||
return wref->ref;
|
||||
}
|
||||
|
||||
DEFUN ("igc-weak-ref-deref", Figc_weak_reaf_deref, Sigc_weak_ref_deref, 1, 1,
|
||||
0, doc
|
||||
: /* todo */)
|
||||
(Lisp_Object obj)
|
||||
{
|
||||
CHECK_WEAK_REF_P (obj);
|
||||
return igc_weak_ref_deref (XWEAK_REF (obj));
|
||||
}
|
||||
|
||||
struct Lisp_Buffer_Local_Value *
|
||||
igc_alloc_blv (void)
|
||||
{
|
||||
|
|
@ -3566,7 +3482,6 @@ is_builtin_obj_type (enum igc_obj_type type)
|
|||
case IGC_OBJ_FACE_CACHE:
|
||||
case IGC_OBJ_FLOAT:
|
||||
case IGC_OBJ_BLV:
|
||||
case IGC_OBJ_WEAK:
|
||||
case IGC_OBJ_PTR_VEC:
|
||||
case IGC_OBJ_OBJ_VEC:
|
||||
case IGC_OBJ_HANDLER:
|
||||
|
|
@ -3620,8 +3535,6 @@ syms_of_igc (void)
|
|||
{
|
||||
defsubr (&Sigc_info);
|
||||
defsubr (&Sigc_roots);
|
||||
defsubr (&Sigc_make_weak_ref);
|
||||
defsubr (&Sigc_weak_ref_deref);
|
||||
defsubr (&Sigc__collect);
|
||||
DEFSYM (Qambig, "ambig");
|
||||
DEFSYM (Qexact, "exact");
|
||||
|
|
@ -4022,12 +3935,6 @@ mirror_weak_ref (struct igc_mirror *m, struct Lisp_Weak_Ref *r)
|
|||
NOT_IMPLEMENTED ();
|
||||
}
|
||||
|
||||
static void
|
||||
mirror_weak (struct igc_mirror *m, struct Lisp_Vector *v)
|
||||
{
|
||||
NOT_IMPLEMENTED ();
|
||||
}
|
||||
|
||||
static void
|
||||
mirror_cons (struct igc_mirror *m, struct Lisp_Cons *c)
|
||||
{
|
||||
|
|
@ -4372,9 +4279,6 @@ mirror_vector (struct igc_mirror *m, void *client)
|
|||
#endif
|
||||
IGC_MIRROR_VECTORLIKE (m, client);
|
||||
break;
|
||||
|
||||
case PVEC_WEAK_REF:
|
||||
emacs_abort ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4460,10 +4364,6 @@ mirror (struct igc_mirror *m, void *org_base, void *copy_base)
|
|||
case IGC_OBJ_BLV:
|
||||
mirror_blv (m, client);
|
||||
break;
|
||||
|
||||
case IGC_OBJ_WEAK:
|
||||
mirror_weak (m, client);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
18
src/igc.h
18
src/igc.h
|
|
@ -42,7 +42,6 @@ enum igc_obj_type
|
|||
IGC_OBJ_FACE_CACHE,
|
||||
IGC_OBJ_FLOAT,
|
||||
IGC_OBJ_BLV,
|
||||
IGC_OBJ_WEAK,
|
||||
IGC_OBJ_PTR_VEC,
|
||||
IGC_OBJ_OBJ_VEC,
|
||||
IGC_OBJ_HANDLER,
|
||||
|
|
@ -140,23 +139,6 @@ void igc_root_create_exact (Lisp_Object *start, Lisp_Object *end);
|
|||
void igc_root_create_exact_ptr (void *var_addr);
|
||||
void igc_root_destroy_comp_unit (struct Lisp_Native_Comp_Unit *u);
|
||||
void *igc_root_create_n (Lisp_Object start[], size_t n);
|
||||
|
||||
struct Lisp_Weak_Ref;
|
||||
Lisp_Object igc_weak_ref_deref (struct Lisp_Weak_Ref *);
|
||||
|
||||
INLINE bool
|
||||
WEAK_REF_P (Lisp_Object x)
|
||||
{
|
||||
return PSEUDOVECTORP (x, PVEC_WEAK_REF);
|
||||
}
|
||||
|
||||
INLINE struct Lisp_Weak_Ref *
|
||||
XWEAK_REF (Lisp_Object a)
|
||||
{
|
||||
eassert (WEAK_REF_P (a));
|
||||
return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Weak_Ref);
|
||||
}
|
||||
|
||||
size_t igc_header_size (void);
|
||||
char *igc_dump_finish_obj (void *client, enum igc_obj_type type,
|
||||
char *base, char *end);
|
||||
|
|
|
|||
|
|
@ -1053,7 +1053,6 @@ enum pvec_type
|
|||
PVEC_TS_NODE,
|
||||
PVEC_TS_COMPILED_QUERY,
|
||||
PVEC_SQLITE,
|
||||
PVEC_WEAK_REF,
|
||||
|
||||
/* These should be last, for internal_equal and sxhash_obj. */
|
||||
PVEC_CLOSURE,
|
||||
|
|
|
|||
|
|
@ -3159,7 +3159,7 @@ dump_vectorlike (struct dump_context *ctx,
|
|||
Lisp_Object lv,
|
||||
dump_off offset)
|
||||
{
|
||||
#if CHECK_STRUCTS && !defined HASH_pvec_type_86BEDC7D5F
|
||||
#if CHECK_STRUCTS && !defined HASH_pvec_type_6604A61AFB
|
||||
# error "pvec_type changed. See CHECK_STRUCTS comment in config.h."
|
||||
#endif
|
||||
const struct Lisp_Vector *v = XVECTOR (lv);
|
||||
|
|
@ -3234,8 +3234,6 @@ dump_vectorlike (struct dump_context *ctx,
|
|||
case PVEC_TS_NODE:
|
||||
case PVEC_TS_COMPILED_QUERY:
|
||||
break;
|
||||
case PVEC_WEAK_REF:
|
||||
emacs_abort();
|
||||
}
|
||||
char msg[60];
|
||||
snprintf (msg, sizeof msg, "pseudovector type %d", (int) ptype);
|
||||
|
|
|
|||
13
src/print.c
13
src/print.c
|
|
@ -2172,19 +2172,6 @@ print_vectorlike_unreadable (Lisp_Object obj, Lisp_Object printcharfun,
|
|||
return;
|
||||
}
|
||||
|
||||
case PVEC_WEAK_REF:
|
||||
{
|
||||
print_c_string ("#<weak-ref ", printcharfun);
|
||||
#ifdef HAVE_MPS
|
||||
Lisp_Object target = igc_weak_ref_deref (XWEAK_REF(obj));
|
||||
print_object (target, printcharfun, escapeflag);
|
||||
#else
|
||||
# warning "PVEC_WEAK_REF not implemented"
|
||||
#endif
|
||||
print_c_string (">", printcharfun);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Types handled earlier. */
|
||||
case PVEC_NORMAL_VECTOR:
|
||||
case PVEC_RECORD:
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
;;; igc-tests.el --- Tests for igc.c -*- lexical-binding: t -*-
|
||||
|
||||
(require 'ert)
|
||||
|
||||
(defvar igc-test-v0 (igc-make-weak-ref (list 1 2)))
|
||||
(defvar igc-test-v1 (igc-make-weak-ref (make-symbol "foo")))
|
||||
|
||||
(ert-deftest igc-test-weak-refs ()
|
||||
(igc--collect)
|
||||
(garbage-collect)
|
||||
(should (equal (igc-weak-ref-deref igc-test-v0) nil))
|
||||
(should (equal (igc-weak-ref-deref igc-test-v1) nil))
|
||||
(let ((wref (igc-make-weak-ref (list 3 4))))
|
||||
(should (equal (igc-weak-ref-deref wref) '(3 4)))))
|
||||
|
||||
(provide 'igc-tests)
|
||||
Loading…
Add table
Add a link
Reference in a new issue