diff options
| author | Alan Mackenzie | 2019-04-05 12:18:53 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2019-04-05 12:18:53 +0000 |
| commit | b071398ba3e8031fe8284f2aed95d714cd3c92af (patch) | |
| tree | d27dd7d78dfff9a8b28778bee260dbbdf6c10e1d | |
| parent | 8a23e8717008d31b4648c999c7a417f4729d239f (diff) | |
| download | emacs-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.
| -rw-r--r-- | src/alloc.c | 14 | ||||
| -rw-r--r-- | src/lisp.h | 21 | ||||
| -rw-r--r-- | src/lread.c | 40 | ||||
| -rw-r--r-- | src/pdumper.c | 8 |
4 files changed, 70 insertions, 13 deletions
diff --git a/src/alloc.c b/src/alloc.c index 035b45864d9..e14b0d577a8 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6053,12 +6053,17 @@ garbage_collect_1 (struct gcstat *gcst) | |||
| 6053 | struct timespec start; | 6053 | struct timespec start; |
| 6054 | byte_ct tot_before = 0; | 6054 | byte_ct tot_before = 0; |
| 6055 | 6055 | ||
| 6056 | specbind (Qsymbols_with_pos_enabled, Qnil); | ||
| 6057 | |||
| 6056 | eassert (weak_hash_tables == NULL); | 6058 | eassert (weak_hash_tables == NULL); |
| 6057 | 6059 | ||
| 6058 | /* Can't GC if pure storage overflowed because we can't determine | 6060 | /* Can't GC if pure storage overflowed because we can't determine |
| 6059 | if something is a pure object or not. */ | 6061 | if something is a pure object or not. */ |
| 6060 | if (pure_bytes_used_before_overflow) | 6062 | if (pure_bytes_used_before_overflow) |
| 6061 | return false; | 6063 | { |
| 6064 | unbind_to (count, Qnil); | ||
| 6065 | return false; | ||
| 6066 | } | ||
| 6062 | 6067 | ||
| 6063 | /* Record this function, so it appears on the profiler's backtraces. */ | 6068 | /* Record this function, so it appears on the profiler's backtraces. */ |
| 6064 | record_in_backtrace (QAutomatic_GC, 0, 0); | 6069 | record_in_backtrace (QAutomatic_GC, 0, 0); |
| @@ -6249,6 +6254,7 @@ garbage_collect_1 (struct gcstat *gcst) | |||
| 6249 | malloc_probe (min (swept, SIZE_MAX)); | 6254 | malloc_probe (min (swept, SIZE_MAX)); |
| 6250 | } | 6255 | } |
| 6251 | 6256 | ||
| 6257 | unbind_to (count, Qnil); | ||
| 6252 | return true; | 6258 | return true; |
| 6253 | } | 6259 | } |
| 6254 | 6260 | ||
| @@ -6276,11 +6282,9 @@ returns nil, because real GC can't be done. | |||
| 6276 | See Info node `(elisp)Garbage Collection'. */) | 6282 | See Info node `(elisp)Garbage Collection'. */) |
| 6277 | (void) | 6283 | (void) |
| 6278 | { | 6284 | { |
| 6279 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 6280 | struct gcstat gcst; | 6285 | struct gcstat gcst; |
| 6281 | specbind (Qsymbols_with_pos_enabled, Qnil); | ||
| 6282 | if (!garbage_collect_1 (&gcst)) | 6286 | if (!garbage_collect_1 (&gcst)) |
| 6283 | return unbind_to (count, Qnil); | 6287 | return Qnil; |
| 6284 | 6288 | ||
| 6285 | Lisp_Object total[] = { | 6289 | Lisp_Object total[] = { |
| 6286 | list4 (Qconses, make_fixnum (sizeof (struct Lisp_Cons)), | 6290 | list4 (Qconses, make_fixnum (sizeof (struct Lisp_Cons)), |
| @@ -6315,7 +6319,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 6315 | make_int ((mallinfo ().fordblks + 1023) >> 10)), | 6319 | make_int ((mallinfo ().fordblks + 1023) >> 10)), |
| 6316 | #endif | 6320 | #endif |
| 6317 | }; | 6321 | }; |
| 6318 | return unbind_to (count, CALLMANY (Flist, total)); | 6322 | return CALLMANY (Flist, total); |
| 6319 | } | 6323 | } |
| 6320 | 6324 | ||
| 6321 | /* Mark Lisp objects in glyph matrix MATRIX. Currently the | 6325 | /* Mark Lisp objects in glyph matrix MATRIX. Currently the |
diff --git a/src/lisp.h b/src/lisp.h index 3324dac98f6..a22043026ad 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2127,10 +2127,7 @@ CHAR_TABLE_SET (Lisp_Object ct, int idx, Lisp_Object val) | |||
| 2127 | It is generated by the DEFUN macro only. | 2127 | It is generated by the DEFUN macro only. |
| 2128 | defsubr makes it into a Lisp object. */ | 2128 | defsubr makes it into a Lisp object. */ |
| 2129 | 2129 | ||
| 2130 | struct Lisp_Subr | 2130 | union Lisp_Function { |
| 2131 | { | ||
| 2132 | union vectorlike_header header; | ||
| 2133 | union { | ||
| 2134 | Lisp_Object (*a0) (void); | 2131 | Lisp_Object (*a0) (void); |
| 2135 | Lisp_Object (*a1) (Lisp_Object); | 2132 | Lisp_Object (*a1) (Lisp_Object); |
| 2136 | Lisp_Object (*a2) (Lisp_Object, Lisp_Object); | 2133 | Lisp_Object (*a2) (Lisp_Object, Lisp_Object); |
| @@ -2142,10 +2139,18 @@ struct Lisp_Subr | |||
| 2142 | Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); | 2139 | Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); |
| 2143 | Lisp_Object (*aUNEVALLED) (Lisp_Object args); | 2140 | Lisp_Object (*aUNEVALLED) (Lisp_Object args); |
| 2144 | Lisp_Object (*aMANY) (ptrdiff_t, Lisp_Object *); | 2141 | Lisp_Object (*aMANY) (ptrdiff_t, Lisp_Object *); |
| 2145 | } function; | 2142 | }; |
| 2143 | |||
| 2144 | struct Lisp_Subr | ||
| 2145 | { | ||
| 2146 | union vectorlike_header header; | ||
| 2147 | union Lisp_Function function; | ||
| 2148 | union Lisp_Function normal_function; | ||
| 2149 | union Lisp_Function BC_function; | ||
| 2146 | short min_args, max_args; | 2150 | short min_args, max_args; |
| 2147 | const char *symbol_name; | 2151 | const char *symbol_name; |
| 2148 | const char *intspec; | 2152 | const char *intspec; |
| 2153 | union Aligned_Lisp_Subr *next; | ||
| 2149 | EMACS_INT doc; | 2154 | EMACS_INT doc; |
| 2150 | } GCALIGNED_STRUCT; | 2155 | } GCALIGNED_STRUCT; |
| 2151 | union Aligned_Lisp_Subr | 2156 | union Aligned_Lisp_Subr |
| @@ -3162,7 +3167,11 @@ CHECK_INTEGER (Lisp_Object x) | |||
| 3162 | static union Aligned_Lisp_Subr sname = \ | 3167 | static union Aligned_Lisp_Subr sname = \ |
| 3163 | {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ | 3168 | {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ |
| 3164 | { .a ## maxargs = fnname }, \ | 3169 | { .a ## maxargs = fnname }, \ |
| 3165 | minargs, maxargs, lname, intspec, 0}}; \ | 3170 | { .a ## maxargs = fnname }, \ |
| 3171 | { .a ## maxargs = /* BC_ ## */fnname }, \ | ||
| 3172 | minargs, maxargs, lname, intspec, \ | ||
| 3173 | NULL, \ | ||
| 3174 | 0}}; \ | ||
| 3166 | Lisp_Object fnname | 3175 | Lisp_Object fnname |
| 3167 | 3176 | ||
| 3168 | /* defsubr (Sname); | 3177 | /* defsubr (Sname); |
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 | ||
| 4441 | static union Aligned_Lisp_Subr *subr_ptr = NULL; | ||
| 4442 | static bool using_BC_subrs = false; | ||
| 4443 | |||
| 4444 | DEFUN ("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 | |||
| 4459 | DEFUN ("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 | |||
| 4441 | void | 4475 | void |
| 4442 | defsubr (union Aligned_Lisp_Subr *aname) | 4476 | defsubr (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); |
diff --git a/src/pdumper.c b/src/pdumper.c index a9b3732a2d4..59cd824142d 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -2914,17 +2914,20 @@ dump_bool_vector (struct dump_context *ctx, const struct Lisp_Vector *v) | |||
| 2914 | static dump_off | 2914 | static dump_off |
| 2915 | dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) | 2915 | dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) |
| 2916 | { | 2916 | { |
| 2917 | #if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_594AB72B54) | 2917 | #if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_6AE56C1912) |
| 2918 | # error "Lisp_Subr changed. See CHECK_STRUCTS comment." | 2918 | # error "Lisp_Subr changed. See CHECK_STRUCTS comment." |
| 2919 | #endif | 2919 | #endif |
| 2920 | struct Lisp_Subr out; | 2920 | struct Lisp_Subr out; |
| 2921 | dump_object_start (ctx, &out, sizeof (out)); | 2921 | dump_object_start (ctx, &out, sizeof (out)); |
| 2922 | DUMP_FIELD_COPY (&out, subr, header.size); | 2922 | DUMP_FIELD_COPY (&out, subr, header.size); |
| 2923 | dump_field_emacs_ptr (ctx, &out, subr, &subr->function.a0); | 2923 | dump_field_emacs_ptr (ctx, &out, subr, &subr->function.a0); |
| 2924 | dump_field_emacs_ptr (ctx, &out, subr, &subr->normal_function.a0); | ||
| 2925 | dump_field_emacs_ptr (ctx, &out, subr, &subr->BC_function.a0); | ||
| 2924 | DUMP_FIELD_COPY (&out, subr, min_args); | 2926 | DUMP_FIELD_COPY (&out, subr, min_args); |
| 2925 | DUMP_FIELD_COPY (&out, subr, max_args); | 2927 | DUMP_FIELD_COPY (&out, subr, max_args); |
| 2926 | dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name); | 2928 | dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name); |
| 2927 | dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); | 2929 | dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); |
| 2930 | dump_field_emacs_ptr (ctx, &out, subr, &subr->next); | ||
| 2928 | DUMP_FIELD_COPY (&out, subr, doc); | 2931 | DUMP_FIELD_COPY (&out, subr, doc); |
| 2929 | return dump_object_finish (ctx, &out, sizeof (out)); | 2932 | return dump_object_finish (ctx, &out, sizeof (out)); |
| 2930 | } | 2933 | } |
| @@ -2953,7 +2956,7 @@ dump_vectorlike (struct dump_context *ctx, | |||
| 2953 | Lisp_Object lv, | 2956 | Lisp_Object lv, |
| 2954 | dump_off offset) | 2957 | dump_off offset) |
| 2955 | { | 2958 | { |
| 2956 | #if CHECK_STRUCTS && !defined (HASH_pvec_type_549C833A54) | 2959 | #if CHECK_STRUCTS && !defined (HASH_pvec_type_3C7A719153) |
| 2957 | # error "pvec_type changed. See CHECK_STRUCTS comment." | 2960 | # error "pvec_type changed. See CHECK_STRUCTS comment." |
| 2958 | #endif | 2961 | #endif |
| 2959 | const struct Lisp_Vector *v = XVECTOR (lv); | 2962 | const struct Lisp_Vector *v = XVECTOR (lv); |
| @@ -2974,6 +2977,7 @@ dump_vectorlike (struct dump_context *ctx, | |||
| 2974 | case PVEC_CHAR_TABLE: | 2977 | case PVEC_CHAR_TABLE: |
| 2975 | case PVEC_SUB_CHAR_TABLE: | 2978 | case PVEC_SUB_CHAR_TABLE: |
| 2976 | case PVEC_RECORD: | 2979 | case PVEC_RECORD: |
| 2980 | case PVEC_SYMBOL_WITH_POS: | ||
| 2977 | offset = dump_vectorlike_generic (ctx, &v->header); | 2981 | offset = dump_vectorlike_generic (ctx, &v->header); |
| 2978 | break; | 2982 | break; |
| 2979 | case PVEC_BOOL_VECTOR: | 2983 | case PVEC_BOOL_VECTOR: |