aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2020-04-25 18:16:17 +0100
committerAndrea Corallo2020-04-25 19:55:39 +0100
commita7fac2e91fb424fcf47ea8a23c218c272dd83434 (patch)
tree620e5295a71b246e191a7f61c756d9e0f8ad985d
parentf691af80f1c2073e610a382029790f7c6f97dd5d (diff)
downloademacs-a7fac2e91fb424fcf47ea8a23c218c272dd83434.tar.gz
emacs-a7fac2e91fb424fcf47ea8a23c218c272dd83434.zip
Lazy load function documentation.
* src/comp.c (native_function_doc): New function. (load_comp_unit): Do not load function doc during load. * src/comp.h: Extern 'native_function_doc'. * src/doc.c (Fdocumentation): Call 'native_function_doc' to retrive function doc. * src/pdumper.c (dump_native_comp_unit): Zero 'data_fdoc_h' before dumping.
-rw-r--r--src/comp.c17
-rw-r--r--src/comp.h2
-rw-r--r--src/doc.c5
-rw-r--r--src/pdumper.c4
4 files changed, 22 insertions, 6 deletions
diff --git a/src/comp.c b/src/comp.c
index 70b0a25a9c0..b33ef92f72b 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -3627,7 +3627,6 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
3627 comp_u->data_vec = load_static_obj (comp_u, TEXT_DATA_RELOC_SYM); 3627 comp_u->data_vec = load_static_obj (comp_u, TEXT_DATA_RELOC_SYM);
3628 comp_u->data_impure_vec = 3628 comp_u->data_impure_vec =
3629 load_static_obj (comp_u, TEXT_DATA_RELOC_IMPURE_SYM); 3629 load_static_obj (comp_u, TEXT_DATA_RELOC_IMPURE_SYM);
3630 comp_u->data_fdoc_h = load_static_obj (comp_u, TEXT_FDOC_SYM);
3631 3630
3632 if (!NILP (Vpurify_flag)) 3631 if (!NILP (Vpurify_flag))
3633 /* Non impure can be copied into pure space. */ 3632 /* Non impure can be copied into pure space. */
@@ -3672,6 +3671,22 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
3672 return; 3671 return;
3673} 3672}
3674 3673
3674Lisp_Object
3675native_function_doc (Lisp_Object function)
3676{
3677 struct Lisp_Native_Comp_Unit *cu =
3678 XNATIVE_COMP_UNIT (Fsubr_native_comp_unit (function));
3679
3680 if (NILP (cu->data_fdoc_h))
3681 cu->data_fdoc_h = load_static_obj (cu, TEXT_FDOC_SYM);
3682
3683 eassert (!NILP (cu->data_fdoc_h));
3684
3685 return Fgethash (make_fixnum (XSUBR (function)->doc),
3686 cu->data_fdoc_h,
3687 Qnil);
3688}
3689
3675DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr, 3690DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
3676 7, 7, 0, 3691 7, 7, 0,
3677 doc: /* This gets called by top_level_run during load phase to register 3692 doc: /* This gets called by top_level_run during load phase to register
diff --git a/src/comp.h b/src/comp.h
index c0598468117..5beedcfc280 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -69,6 +69,8 @@ extern void hash_native_abi (void);
69extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, 69extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
70 bool loading_dump, bool late_load); 70 bool loading_dump, bool late_load);
71 71
72extern Lisp_Object native_function_doc (Lisp_Object function);
73
72extern void syms_of_comp (void); 74extern void syms_of_comp (void);
73 75
74extern void maybe_defer_native_compilation (Lisp_Object function_name, 76extern void maybe_defer_native_compilation (Lisp_Object function_name,
diff --git a/src/doc.c b/src/doc.c
index 8191a914c6e..31ccee8079b 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -337,10 +337,7 @@ 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 = 340 doc = native_function_doc (fun);
341 Fgethash (make_fixnum (XSUBR (fun)->doc),
342 XNATIVE_COMP_UNIT (Fsubr_native_comp_unit (fun))->data_fdoc_h,
343 Qnil);
344 else 341 else
345#endif 342#endif
346 if (SUBRP (fun)) 343 if (SUBRP (fun))
diff --git a/src/pdumper.c b/src/pdumper.c
index 702b3ffced9..39adaf3ea21 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2982,8 +2982,10 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
2982#ifdef HAVE_NATIVE_COMP 2982#ifdef HAVE_NATIVE_COMP
2983static dump_off 2983static dump_off
2984dump_native_comp_unit (struct dump_context *ctx, 2984dump_native_comp_unit (struct dump_context *ctx,
2985 const struct Lisp_Native_Comp_Unit *comp_u) 2985 struct Lisp_Native_Comp_Unit *comp_u)
2986{ 2986{
2987 /* Have function documentation always lazy loaded to optimize load-time. */
2988 comp_u->data_fdoc_h = Qnil;
2987 START_DUMP_PVEC (ctx, &comp_u->header, struct Lisp_Native_Comp_Unit, out); 2989 START_DUMP_PVEC (ctx, &comp_u->header, struct Lisp_Native_Comp_Unit, out);
2988 dump_pseudovector_lisp_fields (ctx, &out->header, &comp_u->header); 2990 dump_pseudovector_lisp_fields (ctx, &out->header, &comp_u->header);
2989 out->handle = NULL; 2991 out->handle = NULL;