aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorAlan Mackenzie2019-04-05 12:18:53 +0000
committerAlan Mackenzie2019-04-05 12:18:53 +0000
commitb071398ba3e8031fe8284f2aed95d714cd3c92af (patch)
treed27dd7d78dfff9a8b28778bee260dbbdf6c10e1d /src/lread.c
parent8a23e8717008d31b4648c999c7a417f4729d239f (diff)
downloademacs-scratch/accurate-warning-pos.tar.gz
emacs-scratch/accurate-warning-pos.zip
Enhance struct Lisp_Subr to hold the alternative "BC_" function.scratch/accurate-warning-pos
Also fix a GC bug, where symbols with position were not being disabled. * src/lisp.h (union Lisp_Function): New type. (struct Lisp_Subr): Add fields normal_function, BC_function, and next. (DEFUN): Setup all three function fields to the subr (BC_function is still a dummy), set field next to NULL. * src/alloc.c (Fgarbage_collect): Move the binding of Qsymbols_with_pos_enabled to garbage_collect_1 so that it gets bound when GC is invoked via garbage_collect. * src/lread.c (subr_ptr, using_BC_subrs): New static variables. (Fswitch_to_BC_subrs, Fswitch_to_normal_subrs): New defuns. (defsubr): Chain new subr to previous using field next and variable subr_ptr. (init_lread): Initialise subr_ptr to NULL. (syms_of_lread): Create subrs Sswitch_to_BC_subrs and Sswitch_to_normal_subrs. * src/pdumper.c (dump_subr): Enhance to dump struct Lisp_Subr's new fields. Update the expected value of HASH_Lisp_Subr_xxxxxxxxxx. (dump_vectorlike): Also dump PVEC_SYMBOL_WITH_POSes.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lread.c b/src/lread.c
index fcee7d4df7e..cc9ee110aec 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -4438,6 +4438,40 @@ init_obarray_once (void)
4438} 4438}
4439 4439
4440 4440
4441static union Aligned_Lisp_Subr *subr_ptr = NULL;
4442static bool using_BC_subrs = false;
4443
4444DEFUN ("switch-to-BC-subrs", Fswitch_to_BC_subrs, Sswitch_to_BC_subrs, 0, 0, 0,
4445 doc: /* Switch all subrs to using the byte compiler versions. */)
4446 (void)
4447{
4448 union Aligned_Lisp_Subr *ptr = subr_ptr;
4449 if (!using_BC_subrs)
4450 while (ptr)
4451 {
4452 ptr->s.function = ptr->s.BC_function;
4453 ptr = ptr->s.next;
4454 }
4455 using_BC_subrs = true;
4456 return Qnil;
4457}
4458
4459DEFUN ("switch-to-normal-subrs", Fswitch_to_normal_subrs,
4460 Sswitch_to_normal_subrs, 0, 0, 0,
4461 doc: /* Switch all subrs to using the normal versions. */)
4462 (void)
4463{
4464 union Aligned_Lisp_Subr *ptr = subr_ptr;
4465 if (using_BC_subrs)
4466 while (ptr)
4467 {
4468 ptr->s.function = ptr->s.normal_function;
4469 ptr = ptr->s.next;
4470 }
4471 using_BC_subrs = false;
4472 return Qnil;
4473}
4474
4441void 4475void
4442defsubr (union Aligned_Lisp_Subr *aname) 4476defsubr (union Aligned_Lisp_Subr *aname)
4443{ 4477{
@@ -4447,6 +4481,8 @@ defsubr (union Aligned_Lisp_Subr *aname)
4447 XSETPVECTYPE (sname, PVEC_SUBR); 4481 XSETPVECTYPE (sname, PVEC_SUBR);
4448 XSETSUBR (tem, sname); 4482 XSETSUBR (tem, sname);
4449 set_symbol_function (sym, tem); 4483 set_symbol_function (sym, tem);
4484 sname->next = subr_ptr;
4485 subr_ptr = aname;
4450} 4486}
4451 4487
4452#ifdef NOTDEF /* Use fset in subr.el now! */ 4488#ifdef NOTDEF /* Use fset in subr.el now! */
@@ -4702,6 +4738,8 @@ init_lread (void)
4702 if (NILP (Vpurify_flag) && !NILP (Ffboundp (Qfile_truename))) 4738 if (NILP (Vpurify_flag) && !NILP (Ffboundp (Qfile_truename)))
4703 Vsource_directory = call1 (Qfile_truename, Vsource_directory); 4739 Vsource_directory = call1 (Qfile_truename, Vsource_directory);
4704 4740
4741 subr_ptr = NULL;
4742
4705 /* First, set Vload_path. */ 4743 /* First, set Vload_path. */
4706 4744
4707 /* Ignore EMACSLOADPATH when dumping. */ 4745 /* Ignore EMACSLOADPATH when dumping. */
@@ -4816,6 +4854,8 @@ syms_of_lread (void)
4816 defsubr (&Sintern); 4854 defsubr (&Sintern);
4817 defsubr (&Sintern_soft); 4855 defsubr (&Sintern_soft);
4818 defsubr (&Sunintern); 4856 defsubr (&Sunintern);
4857 defsubr (&Sswitch_to_BC_subrs);
4858 defsubr (&Sswitch_to_normal_subrs);
4819 defsubr (&Sget_load_suffixes); 4859 defsubr (&Sget_load_suffixes);
4820 defsubr (&Sload); 4860 defsubr (&Sload);
4821 defsubr (&Seval_buffer); 4861 defsubr (&Seval_buffer);