mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
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.
This commit is contained in:
parent
9c4c0af89d
commit
d73e64076e
7 changed files with 31 additions and 16 deletions
|
|
@ -216,6 +216,8 @@ Can be one of: 'd-default', 'd-impure' or 'd-ephemeral'. See `comp-ctxt'.")
|
|||
(sym-to-c-name-h (make-hash-table :test #'eq) :type hash-table
|
||||
:documentation "symbol-function -> c-name.
|
||||
This is only for optimizing intra CU calls at speed 3.")
|
||||
(doc-index-h (make-hash-table :test #'eql) :type hash-table
|
||||
:documentation "Documentation index -> documentation")
|
||||
(d-default (make-comp-data-container) :type comp-data-container
|
||||
:documentation "Standard data relocated in use by functions.")
|
||||
(d-impure (make-comp-data-container) :type comp-data-container
|
||||
|
|
@ -1214,7 +1216,12 @@ the annotation emission."
|
|||
(comp-args-max args)
|
||||
'many))
|
||||
(make-comp-mvar :constant c-name)
|
||||
(make-comp-mvar :constant (comp-func-doc f))
|
||||
(make-comp-mvar
|
||||
:constant
|
||||
(let* ((h (comp-ctxt-doc-index-h comp-ctxt))
|
||||
(i (hash-table-count h)))
|
||||
(puthash i (comp-func-doc f) h)
|
||||
i))
|
||||
(make-comp-mvar :constant
|
||||
(comp-func-int-spec f))
|
||||
;; This is the compilation unit it-self passed as
|
||||
|
|
|
|||
|
|
@ -6638,7 +6638,6 @@ mark_object (Lisp_Object arg)
|
|||
set_vector_marked (ptr);
|
||||
struct Lisp_Subr *subr = XSUBR (obj);
|
||||
mark_object (subr->native_intspec);
|
||||
mark_object (subr->native_doc);
|
||||
mark_object (subr->native_comp_u[0]);
|
||||
}
|
||||
break;
|
||||
|
|
@ -7529,14 +7528,14 @@ N should be nonnegative. */);
|
|||
static union Aligned_Lisp_Subr Swatch_gc_cons_threshold =
|
||||
{{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) },
|
||||
{ .a4 = watch_gc_cons_threshold },
|
||||
4, 4, "watch_gc_cons_threshold", {0}, {0}}};
|
||||
4, 4, "watch_gc_cons_threshold", {0}, 0}};
|
||||
XSETSUBR (watcher, &Swatch_gc_cons_threshold.s);
|
||||
Fadd_variable_watcher (Qgc_cons_threshold, watcher);
|
||||
|
||||
static union Aligned_Lisp_Subr Swatch_gc_cons_percentage =
|
||||
{{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) },
|
||||
{ .a4 = watch_gc_cons_percentage },
|
||||
4, 4, "watch_gc_cons_percentage", {0}, {0}}};
|
||||
4, 4, "watch_gc_cons_percentage", {0}, 0}};
|
||||
XSETSUBR (watcher, &Swatch_gc_cons_percentage.s);
|
||||
Fadd_variable_watcher (Qgc_cons_percentage, watcher);
|
||||
}
|
||||
|
|
|
|||
12
src/comp.c
12
src/comp.c
|
|
@ -41,13 +41,17 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#define DATA_RELOC_SYM "d_reloc"
|
||||
#define DATA_RELOC_IMPURE_SYM "d_reloc_imp"
|
||||
#define DATA_RELOC_EPHEMERAL_SYM "d_reloc_eph"
|
||||
|
||||
#define FUNC_LINK_TABLE_SYM "freloc_link_table"
|
||||
#define LINK_TABLE_HASH_SYM "freloc_hash"
|
||||
#define COMP_UNIT_SYM "comp_unit"
|
||||
#define TEXT_DATA_RELOC_SYM "text_data_reloc"
|
||||
#define TEXT_DATA_RELOC_IMPURE_SYM "text_data_reloc_imp"
|
||||
#define TEXT_DATA_RELOC_EPHEMERAL_SYM "text_data_reloc_eph"
|
||||
|
||||
#define TEXT_OPTIM_QLY "text_optim_qly"
|
||||
#define TEXT_FDOC_SYM "text_data_fdoc"
|
||||
|
||||
|
||||
#define SPEED XFIXNUM (Fsymbol_value (Qcomp_speed))
|
||||
#define COMP_DEBUG XFIXNUM (Fsymbol_value (Qcomp_debug))
|
||||
|
|
@ -2097,6 +2101,9 @@ emit_ctxt_code (void)
|
|||
Fsymbol_value (Qcomp_debug)) };
|
||||
emit_static_object (TEXT_OPTIM_QLY, Flist (2, opt_qly));
|
||||
|
||||
emit_static_object (TEXT_FDOC_SYM,
|
||||
CALL1I (comp-ctxt-doc-index-h, Vcomp_ctxt));
|
||||
|
||||
comp.current_thread_ref =
|
||||
gcc_jit_lvalue_as_rvalue (
|
||||
gcc_jit_context_new_global (
|
||||
|
|
@ -3619,6 +3626,7 @@ 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. */
|
||||
|
|
@ -3668,7 +3676,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
|
|||
doc: /* This gets called by top_level_run during load phase to register
|
||||
each exported subr. */)
|
||||
(Lisp_Object name, Lisp_Object minarg, Lisp_Object maxarg,
|
||||
Lisp_Object c_name, Lisp_Object doc, Lisp_Object intspec,
|
||||
Lisp_Object c_name, Lisp_Object doc_idx, Lisp_Object intspec,
|
||||
Lisp_Object comp_u)
|
||||
{
|
||||
dynlib_handle_ptr handle = XNATIVE_COMP_UNIT (comp_u)->handle;
|
||||
|
|
@ -3688,7 +3696,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
|
|||
x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY;
|
||||
x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name)));
|
||||
x->s.native_intspec = intspec;
|
||||
x->s.native_doc = doc;
|
||||
x->s.doc = XFIXNUM (doc_idx);
|
||||
x->s.native_comp_u[0] = comp_u;
|
||||
Lisp_Object tem;
|
||||
XSETSUBR (tem, &x->s);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ struct Lisp_Native_Comp_Unit
|
|||
/* Original eln file loaded. */
|
||||
Lisp_Object file;
|
||||
Lisp_Object optimize_qualities;
|
||||
/* Hash doc-idx -> function documentaiton. */
|
||||
Lisp_Object data_fdoc_h;
|
||||
/* Analogous to the constant vector but per compilation unit. */
|
||||
Lisp_Object data_vec;
|
||||
/* Same but for data that cannot be moved to pure space.
|
||||
|
|
|
|||
|
|
@ -337,7 +337,10 @@ string is passed through `substitute-command-keys'. */)
|
|||
fun = XCDR (fun);
|
||||
#ifdef HAVE_NATIVE_COMP
|
||||
if (!NILP (Fsubr_native_elisp_p (fun)))
|
||||
doc = XSUBR (fun)->native_doc;
|
||||
doc =
|
||||
Fgethash (make_fixnum (XSUBR (fun)->doc),
|
||||
XNATIVE_COMP_UNIT (Fsubr_native_comp_unit (fun))->data_fdoc_h,
|
||||
Qnil);
|
||||
else
|
||||
#endif
|
||||
if (SUBRP (fun))
|
||||
|
|
|
|||
|
|
@ -2098,10 +2098,7 @@ struct Lisp_Subr
|
|||
const char *intspec;
|
||||
Lisp_Object native_intspec;
|
||||
};
|
||||
union {
|
||||
EMACS_INT doc;
|
||||
Lisp_Object native_doc;
|
||||
};
|
||||
EMACS_INT doc;
|
||||
Lisp_Object native_comp_u[NATIVE_COMP_FLAG];
|
||||
} GCALIGNED_STRUCT;
|
||||
union Aligned_Lisp_Subr
|
||||
|
|
@ -3077,7 +3074,7 @@ CHECK_INTEGER (Lisp_Object x)
|
|||
static union Aligned_Lisp_Subr sname = \
|
||||
{{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
|
||||
{ .a ## maxargs = fnname }, \
|
||||
minargs, maxargs, lname, {intspec}, {0}}}; \
|
||||
minargs, maxargs, lname, {intspec}, 0}}; \
|
||||
Lisp_Object fnname
|
||||
|
||||
/* defsubr (Sname);
|
||||
|
|
|
|||
|
|
@ -2938,7 +2938,7 @@ static dump_off
|
|||
dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
|
||||
{
|
||||
#if CHECK_STRUCTS && ((defined (HAVE_NATIVE_COMP) \
|
||||
&& !defined (HASH_Lisp_Subr_D4F15794AF)) \
|
||||
&& !defined (HASH_Lisp_Subr_99B6674034)) \
|
||||
|| (!defined (HAVE_NATIVE_COMP) \
|
||||
&& !defined (HASH_Lisp_Subr_594AB72B54)))
|
||||
# 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)
|
|||
COLD_OP_NATIVE_SUBR,
|
||||
make_lisp_ptr ((void *) subr, Lisp_Vectorlike));
|
||||
dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL);
|
||||
dump_field_lv (ctx, &out, subr, &subr->native_doc, WEIGHT_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
|
||||
dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
|
||||
DUMP_FIELD_COPY (&out, subr, doc);
|
||||
}
|
||||
DUMP_FIELD_COPY (&out, subr, doc);
|
||||
if (NATIVE_COMP_FLAG)
|
||||
dump_field_lv (ctx, &out, subr, &subr->native_comp_u[0], WEIGHT_NORMAL);
|
||||
|
||||
|
|
@ -3023,7 +3022,7 @@ dump_vectorlike (struct dump_context *ctx,
|
|||
Lisp_Object lv,
|
||||
dump_off offset)
|
||||
{
|
||||
#if CHECK_STRUCTS && !defined HASH_pvec_type_A4A6E9984D
|
||||
#if CHECK_STRUCTS && !defined HASH_pvec_type_F5BA506141
|
||||
# error "pvec_type changed. See CHECK_STRUCTS comment in config.h."
|
||||
#endif
|
||||
const struct Lisp_Vector *v = XVECTOR (lv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue