diff options
| author | Andrea Corallo | 2020-04-25 16:13:03 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-04-25 19:55:39 +0100 |
| commit | d73e64076e08cf0bcb81ea9d161fb7409e1bf896 (patch) | |
| tree | f07c3127f9cdc6ac97390460e6466ba7b81b4de0 /src | |
| parent | 9c4c0af89d88f5b4a9124741f64915c5378f1283 (diff) | |
| download | emacs-d73e64076e08cf0bcb81ea9d161fb7409e1bf896.tar.gz emacs-d73e64076e08cf0bcb81ea9d161fb7409e1bf896.zip | |
Store function documentations in a hash table.
* src/pdumper.c (dump_subr): Update Lisp_Subr hash.
(dump_subr): Update for new compilation unit layout.
(dump_vectorlike): Update pvec_type hash.
* src/lisp.h (struct Lisp_Subr): Remove 'native_doc' index.
(DEFUN): Update macro for new compilation unit
layout.
* src/doc.c (Fdocumentation): Update for new compilation unit
layout.
* src/comp.h (struct Lisp_Native_Comp_Unit):
Add 'data_fdoc_h' field.
* src/comp.c (TEXT_FDOC_SYM): New macro.
(emit_ctxt_code): Emit function documentations.
(load_comp_unit): Load function documentation.
(Fcomp__register_subr): Rename parameter.
(Fcomp__register_subr): Update for new compilation unit
layout.
* src/alloc.c (mark_object): Update for new compilation unit
layout.
(syms_of_alloc): Likewise.
* lisp/emacs-lisp/comp.el (comp-ctxt): Add doc-index-h slot.
(comp-emit-for-top-level): Emit doc index as 'comp--register-subr'
doc parameter.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 5 | ||||
| -rw-r--r-- | src/comp.c | 12 | ||||
| -rw-r--r-- | src/comp.h | 2 | ||||
| -rw-r--r-- | src/doc.c | 5 | ||||
| -rw-r--r-- | src/lisp.h | 7 | ||||
| -rw-r--r-- | src/pdumper.c | 7 |
6 files changed, 23 insertions, 15 deletions
diff --git a/src/alloc.c b/src/alloc.c index 147e018095b..f2b80fac882 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6638,7 +6638,6 @@ mark_object (Lisp_Object arg) | |||
| 6638 | set_vector_marked (ptr); | 6638 | set_vector_marked (ptr); |
| 6639 | struct Lisp_Subr *subr = XSUBR (obj); | 6639 | struct Lisp_Subr *subr = XSUBR (obj); |
| 6640 | mark_object (subr->native_intspec); | 6640 | mark_object (subr->native_intspec); |
| 6641 | mark_object (subr->native_doc); | ||
| 6642 | mark_object (subr->native_comp_u[0]); | 6641 | mark_object (subr->native_comp_u[0]); |
| 6643 | } | 6642 | } |
| 6644 | break; | 6643 | break; |
| @@ -7529,14 +7528,14 @@ N should be nonnegative. */); | |||
| 7529 | static union Aligned_Lisp_Subr Swatch_gc_cons_threshold = | 7528 | static union Aligned_Lisp_Subr Swatch_gc_cons_threshold = |
| 7530 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, | 7529 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, |
| 7531 | { .a4 = watch_gc_cons_threshold }, | 7530 | { .a4 = watch_gc_cons_threshold }, |
| 7532 | 4, 4, "watch_gc_cons_threshold", {0}, {0}}}; | 7531 | 4, 4, "watch_gc_cons_threshold", {0}, 0}}; |
| 7533 | XSETSUBR (watcher, &Swatch_gc_cons_threshold.s); | 7532 | XSETSUBR (watcher, &Swatch_gc_cons_threshold.s); |
| 7534 | Fadd_variable_watcher (Qgc_cons_threshold, watcher); | 7533 | Fadd_variable_watcher (Qgc_cons_threshold, watcher); |
| 7535 | 7534 | ||
| 7536 | static union Aligned_Lisp_Subr Swatch_gc_cons_percentage = | 7535 | static union Aligned_Lisp_Subr Swatch_gc_cons_percentage = |
| 7537 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, | 7536 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, |
| 7538 | { .a4 = watch_gc_cons_percentage }, | 7537 | { .a4 = watch_gc_cons_percentage }, |
| 7539 | 4, 4, "watch_gc_cons_percentage", {0}, {0}}}; | 7538 | 4, 4, "watch_gc_cons_percentage", {0}, 0}}; |
| 7540 | XSETSUBR (watcher, &Swatch_gc_cons_percentage.s); | 7539 | XSETSUBR (watcher, &Swatch_gc_cons_percentage.s); |
| 7541 | Fadd_variable_watcher (Qgc_cons_percentage, watcher); | 7540 | Fadd_variable_watcher (Qgc_cons_percentage, watcher); |
| 7542 | } | 7541 | } |
diff --git a/src/comp.c b/src/comp.c index 4bd271402c2..2f59164b770 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -41,13 +41,17 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 41 | #define DATA_RELOC_SYM "d_reloc" | 41 | #define DATA_RELOC_SYM "d_reloc" |
| 42 | #define DATA_RELOC_IMPURE_SYM "d_reloc_imp" | 42 | #define DATA_RELOC_IMPURE_SYM "d_reloc_imp" |
| 43 | #define DATA_RELOC_EPHEMERAL_SYM "d_reloc_eph" | 43 | #define DATA_RELOC_EPHEMERAL_SYM "d_reloc_eph" |
| 44 | |||
| 44 | #define FUNC_LINK_TABLE_SYM "freloc_link_table" | 45 | #define FUNC_LINK_TABLE_SYM "freloc_link_table" |
| 45 | #define LINK_TABLE_HASH_SYM "freloc_hash" | 46 | #define LINK_TABLE_HASH_SYM "freloc_hash" |
| 46 | #define COMP_UNIT_SYM "comp_unit" | 47 | #define COMP_UNIT_SYM "comp_unit" |
| 47 | #define TEXT_DATA_RELOC_SYM "text_data_reloc" | 48 | #define TEXT_DATA_RELOC_SYM "text_data_reloc" |
| 48 | #define TEXT_DATA_RELOC_IMPURE_SYM "text_data_reloc_imp" | 49 | #define TEXT_DATA_RELOC_IMPURE_SYM "text_data_reloc_imp" |
| 49 | #define TEXT_DATA_RELOC_EPHEMERAL_SYM "text_data_reloc_eph" | 50 | #define TEXT_DATA_RELOC_EPHEMERAL_SYM "text_data_reloc_eph" |
| 51 | |||
| 50 | #define TEXT_OPTIM_QLY "text_optim_qly" | 52 | #define TEXT_OPTIM_QLY "text_optim_qly" |
| 53 | #define TEXT_FDOC_SYM "text_data_fdoc" | ||
| 54 | |||
| 51 | 55 | ||
| 52 | #define SPEED XFIXNUM (Fsymbol_value (Qcomp_speed)) | 56 | #define SPEED XFIXNUM (Fsymbol_value (Qcomp_speed)) |
| 53 | #define COMP_DEBUG XFIXNUM (Fsymbol_value (Qcomp_debug)) | 57 | #define COMP_DEBUG XFIXNUM (Fsymbol_value (Qcomp_debug)) |
| @@ -2097,6 +2101,9 @@ emit_ctxt_code (void) | |||
| 2097 | Fsymbol_value (Qcomp_debug)) }; | 2101 | Fsymbol_value (Qcomp_debug)) }; |
| 2098 | emit_static_object (TEXT_OPTIM_QLY, Flist (2, opt_qly)); | 2102 | emit_static_object (TEXT_OPTIM_QLY, Flist (2, opt_qly)); |
| 2099 | 2103 | ||
| 2104 | emit_static_object (TEXT_FDOC_SYM, | ||
| 2105 | CALL1I (comp-ctxt-doc-index-h, Vcomp_ctxt)); | ||
| 2106 | |||
| 2100 | comp.current_thread_ref = | 2107 | comp.current_thread_ref = |
| 2101 | gcc_jit_lvalue_as_rvalue ( | 2108 | gcc_jit_lvalue_as_rvalue ( |
| 2102 | gcc_jit_context_new_global ( | 2109 | gcc_jit_context_new_global ( |
| @@ -3619,6 +3626,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, | |||
| 3619 | comp_u->data_vec = load_static_obj (comp_u, TEXT_DATA_RELOC_SYM); | 3626 | comp_u->data_vec = load_static_obj (comp_u, TEXT_DATA_RELOC_SYM); |
| 3620 | comp_u->data_impure_vec = | 3627 | comp_u->data_impure_vec = |
| 3621 | load_static_obj (comp_u, TEXT_DATA_RELOC_IMPURE_SYM); | 3628 | load_static_obj (comp_u, TEXT_DATA_RELOC_IMPURE_SYM); |
| 3629 | comp_u->data_fdoc_h = load_static_obj (comp_u, TEXT_FDOC_SYM); | ||
| 3622 | 3630 | ||
| 3623 | if (!NILP (Vpurify_flag)) | 3631 | if (!NILP (Vpurify_flag)) |
| 3624 | /* Non impure can be copied into pure space. */ | 3632 | /* Non impure can be copied into pure space. */ |
| @@ -3668,7 +3676,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr, | |||
| 3668 | doc: /* This gets called by top_level_run during load phase to register | 3676 | doc: /* This gets called by top_level_run during load phase to register |
| 3669 | each exported subr. */) | 3677 | each exported subr. */) |
| 3670 | (Lisp_Object name, Lisp_Object minarg, Lisp_Object maxarg, | 3678 | (Lisp_Object name, Lisp_Object minarg, Lisp_Object maxarg, |
| 3671 | Lisp_Object c_name, Lisp_Object doc, Lisp_Object intspec, | 3679 | Lisp_Object c_name, Lisp_Object doc_idx, Lisp_Object intspec, |
| 3672 | Lisp_Object comp_u) | 3680 | Lisp_Object comp_u) |
| 3673 | { | 3681 | { |
| 3674 | dynlib_handle_ptr handle = XNATIVE_COMP_UNIT (comp_u)->handle; | 3682 | dynlib_handle_ptr handle = XNATIVE_COMP_UNIT (comp_u)->handle; |
| @@ -3688,7 +3696,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr, | |||
| 3688 | x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; | 3696 | x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; |
| 3689 | x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name))); | 3697 | x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name))); |
| 3690 | x->s.native_intspec = intspec; | 3698 | x->s.native_intspec = intspec; |
| 3691 | x->s.native_doc = doc; | 3699 | x->s.doc = XFIXNUM (doc_idx); |
| 3692 | x->s.native_comp_u[0] = comp_u; | 3700 | x->s.native_comp_u[0] = comp_u; |
| 3693 | Lisp_Object tem; | 3701 | Lisp_Object tem; |
| 3694 | XSETSUBR (tem, &x->s); | 3702 | XSETSUBR (tem, &x->s); |
diff --git a/src/comp.h b/src/comp.h index f5baa88853e..6710227b44d 100644 --- a/src/comp.h +++ b/src/comp.h | |||
| @@ -37,6 +37,8 @@ struct Lisp_Native_Comp_Unit | |||
| 37 | /* Original eln file loaded. */ | 37 | /* Original eln file loaded. */ |
| 38 | Lisp_Object file; | 38 | Lisp_Object file; |
| 39 | Lisp_Object optimize_qualities; | 39 | Lisp_Object optimize_qualities; |
| 40 | /* Hash doc-idx -> function documentaiton. */ | ||
| 41 | Lisp_Object data_fdoc_h; | ||
| 40 | /* Analogous to the constant vector but per compilation unit. */ | 42 | /* Analogous to the constant vector but per compilation unit. */ |
| 41 | Lisp_Object data_vec; | 43 | Lisp_Object data_vec; |
| 42 | /* Same but for data that cannot be moved to pure space. | 44 | /* Same but for data that cannot be moved to pure space. |
| @@ -337,7 +337,10 @@ string is passed through `substitute-command-keys'. */) | |||
| 337 | fun = XCDR (fun); | 337 | fun = XCDR (fun); |
| 338 | #ifdef HAVE_NATIVE_COMP | 338 | #ifdef HAVE_NATIVE_COMP |
| 339 | if (!NILP (Fsubr_native_elisp_p (fun))) | 339 | if (!NILP (Fsubr_native_elisp_p (fun))) |
| 340 | doc = XSUBR (fun)->native_doc; | 340 | doc = |
| 341 | Fgethash (make_fixnum (XSUBR (fun)->doc), | ||
| 342 | XNATIVE_COMP_UNIT (Fsubr_native_comp_unit (fun))->data_fdoc_h, | ||
| 343 | Qnil); | ||
| 341 | else | 344 | else |
| 342 | #endif | 345 | #endif |
| 343 | if (SUBRP (fun)) | 346 | if (SUBRP (fun)) |
diff --git a/src/lisp.h b/src/lisp.h index 1cec62a853c..3d082911f54 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2098,10 +2098,7 @@ struct Lisp_Subr | |||
| 2098 | const char *intspec; | 2098 | const char *intspec; |
| 2099 | Lisp_Object native_intspec; | 2099 | Lisp_Object native_intspec; |
| 2100 | }; | 2100 | }; |
| 2101 | union { | 2101 | EMACS_INT doc; |
| 2102 | EMACS_INT doc; | ||
| 2103 | Lisp_Object native_doc; | ||
| 2104 | }; | ||
| 2105 | Lisp_Object native_comp_u[NATIVE_COMP_FLAG]; | 2102 | Lisp_Object native_comp_u[NATIVE_COMP_FLAG]; |
| 2106 | } GCALIGNED_STRUCT; | 2103 | } GCALIGNED_STRUCT; |
| 2107 | union Aligned_Lisp_Subr | 2104 | union Aligned_Lisp_Subr |
| @@ -3077,7 +3074,7 @@ CHECK_INTEGER (Lisp_Object x) | |||
| 3077 | static union Aligned_Lisp_Subr sname = \ | 3074 | static union Aligned_Lisp_Subr sname = \ |
| 3078 | {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ | 3075 | {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ |
| 3079 | { .a ## maxargs = fnname }, \ | 3076 | { .a ## maxargs = fnname }, \ |
| 3080 | minargs, maxargs, lname, {intspec}, {0}}}; \ | 3077 | minargs, maxargs, lname, {intspec}, 0}}; \ |
| 3081 | Lisp_Object fnname | 3078 | Lisp_Object fnname |
| 3082 | 3079 | ||
| 3083 | /* defsubr (Sname); | 3080 | /* defsubr (Sname); |
diff --git a/src/pdumper.c b/src/pdumper.c index bf6bc3a3bc3..702b3ffced9 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -2938,7 +2938,7 @@ static dump_off | |||
| 2938 | dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) | 2938 | dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) |
| 2939 | { | 2939 | { |
| 2940 | #if CHECK_STRUCTS && ((defined (HAVE_NATIVE_COMP) \ | 2940 | #if CHECK_STRUCTS && ((defined (HAVE_NATIVE_COMP) \ |
| 2941 | && !defined (HASH_Lisp_Subr_D4F15794AF)) \ | 2941 | && !defined (HASH_Lisp_Subr_99B6674034)) \ |
| 2942 | || (!defined (HAVE_NATIVE_COMP) \ | 2942 | || (!defined (HAVE_NATIVE_COMP) \ |
| 2943 | && !defined (HASH_Lisp_Subr_594AB72B54))) | 2943 | && !defined (HASH_Lisp_Subr_594AB72B54))) |
| 2944 | # error "Lisp_Subr changed. See CHECK_STRUCTS comment in config.h." | 2944 | # error "Lisp_Subr changed. See CHECK_STRUCTS comment in config.h." |
| @@ -2959,14 +2959,13 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) | |||
| 2959 | COLD_OP_NATIVE_SUBR, | 2959 | COLD_OP_NATIVE_SUBR, |
| 2960 | make_lisp_ptr ((void *) subr, Lisp_Vectorlike)); | 2960 | make_lisp_ptr ((void *) subr, Lisp_Vectorlike)); |
| 2961 | dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL); | 2961 | dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL); |
| 2962 | dump_field_lv (ctx, &out, subr, &subr->native_doc, WEIGHT_NORMAL); | ||
| 2963 | } | 2962 | } |
| 2964 | else | 2963 | else |
| 2965 | { | 2964 | { |
| 2966 | dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name); | 2965 | dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name); |
| 2967 | dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); | 2966 | dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); |
| 2968 | DUMP_FIELD_COPY (&out, subr, doc); | ||
| 2969 | } | 2967 | } |
| 2968 | DUMP_FIELD_COPY (&out, subr, doc); | ||
| 2970 | if (NATIVE_COMP_FLAG) | 2969 | if (NATIVE_COMP_FLAG) |
| 2971 | dump_field_lv (ctx, &out, subr, &subr->native_comp_u[0], WEIGHT_NORMAL); | 2970 | dump_field_lv (ctx, &out, subr, &subr->native_comp_u[0], WEIGHT_NORMAL); |
| 2972 | 2971 | ||
| @@ -3023,7 +3022,7 @@ dump_vectorlike (struct dump_context *ctx, | |||
| 3023 | Lisp_Object lv, | 3022 | Lisp_Object lv, |
| 3024 | dump_off offset) | 3023 | dump_off offset) |
| 3025 | { | 3024 | { |
| 3026 | #if CHECK_STRUCTS && !defined HASH_pvec_type_A4A6E9984D | 3025 | #if CHECK_STRUCTS && !defined HASH_pvec_type_F5BA506141 |
| 3027 | # error "pvec_type changed. See CHECK_STRUCTS comment in config.h." | 3026 | # error "pvec_type changed. See CHECK_STRUCTS comment in config.h." |
| 3028 | #endif | 3027 | #endif |
| 3029 | const struct Lisp_Vector *v = XVECTOR (lv); | 3028 | const struct Lisp_Vector *v = XVECTOR (lv); |