aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2019-12-24 17:41:44 +0100
committerAndrea Corallo2020-01-01 11:38:16 +0100
commitef59b67e4657fa80d1528b9d476c67f01abecc35 (patch)
tree8827eea8a193014bbc7df20b9e7974ae99509bbc /src
parent2ccce1bc3954ce5f2faa0dcf7fa68ec5cae710ca (diff)
downloademacs-ef59b67e4657fa80d1528b9d476c67f01abecc35.tar.gz
emacs-ef59b67e4657fa80d1528b9d476c67f01abecc35.zip
mitigate ifdef proliferation
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c17
-rw-r--r--src/comp.c2
-rw-r--r--src/comp.h10
-rw-r--r--src/data.c5
-rw-r--r--src/doc.c2
-rw-r--r--src/eval.c19
-rw-r--r--src/lisp.h15
-rw-r--r--src/lread.c32
-rw-r--r--src/pdumper.c21
9 files changed, 60 insertions, 63 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 5e0b04b1cc7..6d6f6934bab 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3023,15 +3023,14 @@ cleanup_vector (struct Lisp_Vector *vector)
3023 if (uptr->finalizer) 3023 if (uptr->finalizer)
3024 uptr->finalizer (uptr->p); 3024 uptr->finalizer (uptr->p);
3025 } 3025 }
3026#ifdef HAVE_NATIVE_COMP 3026 else if (NATIVE_COMP_FLAG
3027 else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT)) 3027 && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT))
3028 { 3028 {
3029 struct Lisp_Native_Comp_Unit *cu = 3029 struct Lisp_Native_Comp_Unit *cu =
3030 PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); 3030 PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit);
3031 eassert (cu->handle); 3031 eassert (cu->handle);
3032 dynlib_close (cu->handle); 3032 dynlib_close (cu->handle);
3033 } 3033 }
3034#endif
3035} 3034}
3036 3035
3037/* Reclaim space used by unmarked vectors. */ 3036/* Reclaim space used by unmarked vectors. */
@@ -6565,14 +6564,12 @@ mark_object (Lisp_Object arg)
6565 break; 6564 break;
6566 6565
6567 case PVEC_SUBR: 6566 case PVEC_SUBR:
6568#ifdef HAVE_NATIVE_COMP
6569 if (SUBRP_NATIVE_COMPILEDP (obj)) 6567 if (SUBRP_NATIVE_COMPILEDP (obj))
6570 { 6568 {
6571 set_vector_marked (ptr); 6569 set_vector_marked (ptr);
6572 struct Lisp_Subr *subr = XSUBR (obj); 6570 struct Lisp_Subr *subr = XSUBR (obj);
6573 mark_object (subr->native_comp_u); 6571 mark_object (subr->native_comp_u[0]);
6574 } 6572 }
6575#endif
6576 break; 6573 break;
6577 6574
6578 case PVEC_FREE: 6575 case PVEC_FREE:
@@ -6717,13 +6714,9 @@ survives_gc_p (Lisp_Object obj)
6717 break; 6714 break;
6718 6715
6719 case Lisp_Vectorlike: 6716 case Lisp_Vectorlike:
6720#ifdef HAVE_NATIVE_COMP
6721 survives_p = 6717 survives_p =
6722 (SUBRP (obj) && !SUBRP_NATIVE_COMPILEDP (obj)) || 6718 (SUBRP (obj) && !SUBRP_NATIVE_COMPILEDP (obj)) ||
6723 vector_marked_p (XVECTOR (obj)); 6719 vector_marked_p (XVECTOR (obj));
6724#else
6725 survives_p = SUBRP (obj) || vector_marked_p (XVECTOR (obj));
6726#endif
6727 break; 6720 break;
6728 6721
6729 case Lisp_Cons: 6722 case Lisp_Cons:
@@ -7473,14 +7466,14 @@ N should be nonnegative. */);
7473 static union Aligned_Lisp_Subr Swatch_gc_cons_threshold = 7466 static union Aligned_Lisp_Subr Swatch_gc_cons_threshold =
7474 {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, 7467 {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) },
7475 { .a4 = watch_gc_cons_threshold }, 7468 { .a4 = watch_gc_cons_threshold },
7476 4, 4, "watch_gc_cons_threshold", {0}, {0}, 0}}; 7469 4, 4, "watch_gc_cons_threshold", {0}, {0}}};
7477 XSETSUBR (watcher, &Swatch_gc_cons_threshold.s); 7470 XSETSUBR (watcher, &Swatch_gc_cons_threshold.s);
7478 Fadd_variable_watcher (Qgc_cons_threshold, watcher); 7471 Fadd_variable_watcher (Qgc_cons_threshold, watcher);
7479 7472
7480 static union Aligned_Lisp_Subr Swatch_gc_cons_percentage = 7473 static union Aligned_Lisp_Subr Swatch_gc_cons_percentage =
7481 {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, 7474 {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) },
7482 { .a4 = watch_gc_cons_percentage }, 7475 { .a4 = watch_gc_cons_percentage },
7483 4, 4, "watch_gc_cons_percentage", {0}, {0}, 0}}; 7476 4, 4, "watch_gc_cons_percentage", {0}, {0}}};
7484 XSETSUBR (watcher, &Swatch_gc_cons_percentage.s); 7477 XSETSUBR (watcher, &Swatch_gc_cons_percentage.s);
7485 Fadd_variable_watcher (Qgc_cons_percentage, watcher); 7478 Fadd_variable_watcher (Qgc_cons_percentage, watcher);
7486} 7479}
diff --git a/src/comp.c b/src/comp.c
index 87986abee68..6f5658191c0 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -3285,7 +3285,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
3285 x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name))); 3285 x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name)));
3286 x->s.native_intspec = intspec; 3286 x->s.native_intspec = intspec;
3287 x->s.native_doc = doc; 3287 x->s.native_doc = doc;
3288 x->s.native_comp_u = comp_u; 3288 x->s.native_comp_u[0] = comp_u;
3289 Lisp_Object tem; 3289 Lisp_Object tem;
3290 XSETSUBR (tem, &x->s); 3290 XSETSUBR (tem, &x->s);
3291 set_symbol_function (name, tem); 3291 set_symbol_function (name, tem);
diff --git a/src/comp.h b/src/comp.h
index 90b4f40426b..f756e38d292 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -19,6 +19,16 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19#ifndef COMP_H 19#ifndef COMP_H
20#define COMP_H 20#define COMP_H
21 21
22/* To keep ifdefs under control. */
23enum {
24 NATIVE_COMP_FLAG =
25#ifdef HAVE_NATIVE_COMP
26 1
27#else
28 0
29#endif
30};
31
22#ifdef HAVE_NATIVE_COMP 32#ifdef HAVE_NATIVE_COMP
23 33
24#include <dynlib.h> 34#include <dynlib.h>
diff --git a/src/data.c b/src/data.c
index 3fb0fc0a190..d20db4dc3a3 100644
--- a/src/data.c
+++ b/src/data.c
@@ -881,7 +881,7 @@ DEFUN ("subr-native-comp-unit", Fsubr_native_comp_unit,
881 (Lisp_Object subr) 881 (Lisp_Object subr)
882{ 882{
883 CHECK_SUBR (subr); 883 CHECK_SUBR (subr);
884 return XSUBR (subr)->native_comp_u; 884 return XSUBR (subr)->native_comp_u[0];
885} 885}
886 886
887DEFUN ("native-comp-unit-file", Fnative_comp_unit_file, 887DEFUN ("native-comp-unit-file", Fnative_comp_unit_file,
@@ -919,10 +919,9 @@ Value, if non-nil, is a list (interactive SPEC). */)
919 919
920 if (SUBRP (fun)) 920 if (SUBRP (fun))
921 { 921 {
922#ifdef HAVE_NATIVE_COMP
923 if (SUBRP_NATIVE_COMPILEDP (fun) && XSUBR (fun)->native_intspec) 922 if (SUBRP_NATIVE_COMPILEDP (fun) && XSUBR (fun)->native_intspec)
924 return XSUBR (fun)->native_intspec; 923 return XSUBR (fun)->native_intspec;
925#endif 924
926 const char *spec = XSUBR (fun)->intspec; 925 const char *spec = XSUBR (fun)->intspec;
927 if (spec) 926 if (spec)
928 return list2 (Qinteractive, 927 return list2 (Qinteractive,
diff --git a/src/doc.c b/src/doc.c
index 9e1d8392787..2c96fc15a7c 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -510,12 +510,10 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
510 XSETCAR (tem, make_fixnum (offset)); 510 XSETCAR (tem, make_fixnum (offset));
511 } 511 }
512 } 512 }
513#ifdef HAVE_NATIVE_COMP
514 else if (SUBRP_NATIVE_COMPILEDP (fun)) 513 else if (SUBRP_NATIVE_COMPILEDP (fun))
515 { 514 {
516 XSUBR (fun)->native_doc = Qnil; 515 XSUBR (fun)->native_doc = Qnil;
517 } 516 }
518#endif
519 /* Lisp_Subrs have a slot for it. */ 517 /* Lisp_Subrs have a slot for it. */
520 else if (SUBRP (fun)) 518 else if (SUBRP (fun))
521 { 519 {
diff --git a/src/eval.c b/src/eval.c
index bf37ed9cefa..253de05a658 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -219,14 +219,17 @@ void
219init_eval_once (void) 219init_eval_once (void)
220{ 220{
221 /* Don't forget to update docs (lispref node "Local Variables"). */ 221 /* Don't forget to update docs (lispref node "Local Variables"). */
222#ifndef HAVE_NATIVE_COMP 222 if (!NATIVE_COMP_FLAG)
223 max_specpdl_size = 1600; /* 1500 is not enough for cl-generic.el. */ 223 {
224 max_lisp_eval_depth = 800; 224 max_specpdl_size = 1600; /* 1500 is not enough for cl-generic.el. */
225#else 225 max_lisp_eval_depth = 800;
226 /* Original values increased for comp.el. */ 226 }
227 max_specpdl_size = 2100; 227 else
228 max_lisp_eval_depth = 1400; 228 {
229#endif 229 /* Original values increased for comp.el. */
230 max_specpdl_size = 2100;
231 max_lisp_eval_depth = 1400;
232 }
230 Vrun_hooks = Qnil; 233 Vrun_hooks = Qnil;
231 pdumper_do_now_and_after_load (init_eval_once_for_pdumper); 234 pdumper_do_now_and_after_load (init_eval_once_for_pdumper);
232} 235}
diff --git a/src/lisp.h b/src/lisp.h
index c7e55057ad3..a4cabc34855 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2098,9 +2098,7 @@ struct Lisp_Subr
2098 EMACS_INT doc; 2098 EMACS_INT doc;
2099 Lisp_Object native_doc; 2099 Lisp_Object native_doc;
2100 }; 2100 };
2101#ifdef HAVE_NATIVE_COMP 2101 Lisp_Object native_comp_u[NATIVE_COMP_FLAG];
2102 Lisp_Object native_comp_u;
2103#endif
2104 } GCALIGNED_STRUCT; 2102 } GCALIGNED_STRUCT;
2105union Aligned_Lisp_Subr 2103union Aligned_Lisp_Subr
2106 { 2104 {
@@ -3113,7 +3111,7 @@ CHECK_INTEGER (Lisp_Object x)
3113 static union Aligned_Lisp_Subr sname = \ 3111 static union Aligned_Lisp_Subr sname = \
3114 {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ 3112 {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
3115 { .a ## maxargs = fnname }, \ 3113 { .a ## maxargs = fnname }, \
3116 minargs, maxargs, lname, {intspec}, {0}, 0}}; \ 3114 minargs, maxargs, lname, {intspec}, {0}}}; \
3117 Lisp_Object fnname 3115 Lisp_Object fnname
3118 3116
3119/* defsubr (Sname); 3117/* defsubr (Sname);
@@ -4763,7 +4761,7 @@ extern char *emacs_root_dir (void);
4763INLINE bool 4761INLINE bool
4764SUBRP_NATIVE_COMPILEDP (Lisp_Object a) 4762SUBRP_NATIVE_COMPILEDP (Lisp_Object a)
4765{ 4763{
4766 return SUBRP (a) && XSUBR (a)->native_comp_u; 4764 return SUBRP (a) && XSUBR (a)->native_comp_u[0];
4767} 4765}
4768 4766
4769INLINE struct Lisp_Native_Comp_Unit * 4767INLINE struct Lisp_Native_Comp_Unit *
@@ -4772,6 +4770,13 @@ allocate_native_comp_unit (void)
4772 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Native_Comp_Unit, data_vec, 4770 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Native_Comp_Unit, data_vec,
4773 PVEC_NATIVE_COMP_UNIT); 4771 PVEC_NATIVE_COMP_UNIT);
4774} 4772}
4773#else
4774INLINE bool
4775SUBRP_NATIVE_COMPILEDP (Lisp_Object a)
4776{
4777 return false;
4778}
4779
4775#endif 4780#endif
4776 4781
4777/* Defined in lastfile.c. */ 4782/* Defined in lastfile.c. */
diff --git a/src/lread.c b/src/lread.c
index 4e8a3adeb94..1c5268d0dad 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1281,11 +1281,9 @@ Return t if the file exists and loads successfully. */)
1281 bool is_module = false; 1281 bool is_module = false;
1282#endif 1282#endif
1283 1283
1284#ifdef HAVE_NATIVE_COMP 1284 bool is_native_elisp =
1285 bool is_native_elisp = suffix_p (found, NATIVE_ELISP_SUFFIX); 1285 NATIVE_COMP_FLAG && suffix_p (found, NATIVE_ELISP_SUFFIX) ? true : false;
1286#else 1286
1287 bool is_native_elisp = false;
1288#endif
1289 /* Check if we're stuck in a recursive load cycle. 1287 /* Check if we're stuck in a recursive load cycle.
1290 1288
1291 2000-09-21: It's not possible to just check for the file loaded 1289 2000-09-21: It's not possible to just check for the file loaded
@@ -1486,15 +1484,16 @@ Return t if the file exists and loads successfully. */)
1486 } 1484 }
1487 else if (is_native_elisp) 1485 else if (is_native_elisp)
1488 { 1486 {
1489#ifdef HAVE_NATIVE_COMP 1487 if (NATIVE_COMP_FLAG)
1490 specbind (Qcurrent_load_list, Qnil); 1488 {
1491 LOADHIST_ATTACH (found); 1489 specbind (Qcurrent_load_list, Qnil);
1492 Fnative_elisp_load (found); 1490 LOADHIST_ATTACH (found);
1493 build_load_history (found, true); 1491 Fnative_elisp_load (found);
1494#else 1492 build_load_history (found, true);
1495 /* This cannot happen. */ 1493 }
1496 emacs_abort (); 1494 else
1497#endif 1495 /* This cannot happen. */
1496 emacs_abort ();
1498 } 1497 }
1499 else 1498 else
1500 { 1499 {
@@ -4465,9 +4464,8 @@ defsubr (union Aligned_Lisp_Subr *aname)
4465 XSETPVECTYPE (sname, PVEC_SUBR); 4464 XSETPVECTYPE (sname, PVEC_SUBR);
4466 XSETSUBR (tem, sname); 4465 XSETSUBR (tem, sname);
4467 set_symbol_function (sym, tem); 4466 set_symbol_function (sym, tem);
4468#ifdef HAVE_NATIVE_COMP 4467 if (NATIVE_COMP_FLAG)
4469 Vcomp_subr_list = Fcons (tem, Vcomp_subr_list); 4468 Vcomp_subr_list = Fcons (tem, Vcomp_subr_list);
4470#endif /* HAVE_NATIVE_COMP */
4471} 4469}
4472 4470
4473#ifdef NOTDEF /* Use fset in subr.el now! */ 4471#ifdef NOTDEF /* Use fset in subr.el now! */
diff --git a/src/pdumper.c b/src/pdumper.c
index 610b94b0a32..d66c4e99642 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2948,18 +2948,13 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
2948 struct Lisp_Subr out; 2948 struct Lisp_Subr out;
2949 dump_object_start (ctx, &out, sizeof (out)); 2949 dump_object_start (ctx, &out, sizeof (out));
2950 DUMP_FIELD_COPY (&out, subr, header.size); 2950 DUMP_FIELD_COPY (&out, subr, header.size);
2951#ifdef HAVE_NATIVE_COMP 2951 if (NATIVE_COMP_FLAG && subr->native_comp_u[0])
2952 if (subr->native_comp_u)
2953 out.function.a0 = NULL; 2952 out.function.a0 = NULL;
2954 else 2953 else
2955 dump_field_emacs_ptr (ctx, &out, subr, &subr->function.a0); 2954 dump_field_emacs_ptr (ctx, &out, subr, &subr->function.a0);
2956#else
2957 dump_field_emacs_ptr (ctx, &out, subr, &subr->function.a0);
2958#endif
2959 DUMP_FIELD_COPY (&out, subr, min_args); 2955 DUMP_FIELD_COPY (&out, subr, min_args);
2960 DUMP_FIELD_COPY (&out, subr, max_args); 2956 DUMP_FIELD_COPY (&out, subr, max_args);
2961#ifdef HAVE_NATIVE_COMP 2957 if (NATIVE_COMP_FLAG && subr->native_comp_u[0])
2962 if (subr->native_comp_u)
2963 { 2958 {
2964 dump_field_fixup_later (ctx, &out, subr, &subr->symbol_name); 2959 dump_field_fixup_later (ctx, &out, subr, &subr->symbol_name);
2965 dump_remember_cold_op (ctx, 2960 dump_remember_cold_op (ctx,
@@ -2974,15 +2969,11 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
2974 dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); 2969 dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
2975 DUMP_FIELD_COPY (&out, subr, doc); 2970 DUMP_FIELD_COPY (&out, subr, doc);
2976 } 2971 }
2977 dump_field_lv (ctx, &out, subr, &subr->native_comp_u, WEIGHT_NORMAL); 2972 if (NATIVE_COMP_FLAG)
2978#else 2973 dump_field_lv (ctx, &out, subr, &subr->native_comp_u[0], WEIGHT_NORMAL);
2979 dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
2980 dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
2981 DUMP_FIELD_COPY (&out, subr, doc);
2982#endif
2983 2974
2984 dump_off subr_off = dump_object_finish (ctx, &out, sizeof (out)); 2975 dump_off subr_off = dump_object_finish (ctx, &out, sizeof (out));
2985 if (ctx->flags.dump_object_contents && subr->native_comp_u) 2976 if (ctx->flags.dump_object_contents && subr->native_comp_u[0])
2986 /* We'll do the final addr relocation during VERY_LATE_RELOCS time 2977 /* We'll do the final addr relocation during VERY_LATE_RELOCS time
2987 after the compilation units has been loaded. */ 2978 after the compilation units has been loaded. */
2988 dump_push (&ctx->dump_relocs[VERY_LATE_RELOCS], 2979 dump_push (&ctx->dump_relocs[VERY_LATE_RELOCS],
@@ -5320,7 +5311,7 @@ dump_do_dump_relocation (const uintptr_t dump_base,
5320 struct Lisp_Subr *subr = dump_ptr (dump_base, reloc_offset); 5311 struct Lisp_Subr *subr = dump_ptr (dump_base, reloc_offset);
5321 Lisp_Object name = intern (subr->symbol_name); 5312 Lisp_Object name = intern (subr->symbol_name);
5322 struct Lisp_Native_Comp_Unit *comp_u = 5313 struct Lisp_Native_Comp_Unit *comp_u =
5323 XNATIVE_COMP_UNIT (subr->native_comp_u); 5314 XNATIVE_COMP_UNIT (subr->native_comp_u[0]);
5324 if (!comp_u->handle) 5315 if (!comp_u->handle)
5325 error ("can't relocate native subr with not loaded compilation unit"); 5316 error ("can't relocate native subr with not loaded compilation unit");
5326 Lisp_Object c_name = Fgethash (name, Vcomp_sym_subr_c_name_h, Qnil); 5317 Lisp_Object c_name = Fgethash (name, Vcomp_sym_subr_c_name_h, Qnil);