emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp a7fac2e 06/10: Lazy load function documentation.


From: Andrea Corallo
Subject: feature/native-comp a7fac2e 06/10: Lazy load function documentation.
Date: Sat, 25 Apr 2020 17:31:25 -0400 (EDT)

branch: feature/native-comp
commit a7fac2e91fb424fcf47ea8a23c218c272dd83434
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>

    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.
---
 src/comp.c    | 17 ++++++++++++++++-
 src/comp.h    |  2 ++
 src/doc.c     |  5 +----
 src/pdumper.c |  4 +++-
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/comp.c b/src/comp.c
index 70b0a25..b33ef92 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,
          comp_u->data_vec = load_static_obj (comp_u, TEXT_DATA_RELOC_SYM);
          comp_u->data_impure_vec =
            load_static_obj (comp_u, TEXT_DATA_RELOC_IMPURE_SYM);
-         comp_u->data_fdoc_h = load_static_obj (comp_u, TEXT_FDOC_SYM);
 
          if (!NILP (Vpurify_flag))
            /* 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,
   return;
 }
 
+Lisp_Object
+native_function_doc (Lisp_Object function)
+{
+  struct Lisp_Native_Comp_Unit *cu =
+    XNATIVE_COMP_UNIT (Fsubr_native_comp_unit (function));
+
+  if (NILP (cu->data_fdoc_h))
+    cu->data_fdoc_h = load_static_obj (cu, TEXT_FDOC_SYM);
+
+  eassert (!NILP (cu->data_fdoc_h));
+
+  return Fgethash (make_fixnum (XSUBR (function)->doc),
+                  cu->data_fdoc_h,
+                  Qnil);
+}
+
 DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
        7, 7, 0,
        doc: /* This gets called by top_level_run during load phase to register
diff --git a/src/comp.h b/src/comp.h
index c059846..5beedcf 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -69,6 +69,8 @@ extern void hash_native_abi (void);
 extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
                            bool loading_dump, bool late_load);
 
+extern Lisp_Object native_function_doc (Lisp_Object function);
+
 extern void syms_of_comp (void);
 
 extern void maybe_defer_native_compilation (Lisp_Object function_name,
diff --git a/src/doc.c b/src/doc.c
index 8191a91..31ccee8 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -337,10 +337,7 @@ string is passed through `substitute-command-keys'.  */)
     fun = XCDR (fun);
 #ifdef HAVE_NATIVE_COMP
   if (!NILP (Fsubr_native_elisp_p (fun)))
-    doc =
-      Fgethash (make_fixnum (XSUBR (fun)->doc),
-               XNATIVE_COMP_UNIT (Fsubr_native_comp_unit (fun))->data_fdoc_h,
-               Qnil);
+    doc = native_function_doc (fun);
   else
 #endif
   if (SUBRP (fun))
diff --git a/src/pdumper.c b/src/pdumper.c
index 702b3ff..39adaf3 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2982,8 +2982,10 @@ dump_subr (struct dump_context *ctx, const struct 
Lisp_Subr *subr)
 #ifdef HAVE_NATIVE_COMP
 static dump_off
 dump_native_comp_unit (struct dump_context *ctx,
-                      const struct Lisp_Native_Comp_Unit *comp_u)
+                      struct Lisp_Native_Comp_Unit *comp_u)
 {
+  /* Have function documentation always lazy loaded to optimize load-time.  */
+  comp_u->data_fdoc_h = Qnil;
   START_DUMP_PVEC (ctx, &comp_u->header, struct Lisp_Native_Comp_Unit, out);
   dump_pseudovector_lisp_fields (ctx, &out->header, &comp_u->header);
   out->handle = NULL;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]