From: Andrea Corallo Date: Sat, 7 Dec 2019 17:19:00 +0000 (+0100) Subject: native compile interactive functions support X-Git-Tag: emacs-28.0.90~2727^2~925 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a248dfe2c3341ed73de38c2feea64ec12f053aaa;p=emacs.git native compile interactive functions support --- diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index e46453e8516..ffd4985301e 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1076,9 +1076,7 @@ the annotation emission." (cl-defmethod comp-emit-for-top-level ((form byte-to-native-function)) (let* ((name (byte-to-native-function-name form)) (f (gethash name (comp-ctxt-funcs-h comp-ctxt))) - (args (comp-func-args f)) - (c-name (comp-func-c-name f)) - (doc (comp-func-doc f))) + (args (comp-func-args f))) (cl-assert (and name f)) (comp-emit (comp-call 'comp--register-subr (make-comp-mvar :constant name) @@ -1086,8 +1084,10 @@ the annotation emission." (make-comp-mvar :constant (if (comp-args-p args) (comp-args-max args) 'many)) - (make-comp-mvar :constant c-name) - (make-comp-mvar :constant doc))))) + (make-comp-mvar :constant (comp-func-c-name f)) + (make-comp-mvar :constant (comp-func-doc f)) + (make-comp-mvar :constant + (comp-func-int-spec f)))))) (cl-defmethod comp-emit-for-top-level ((form byte-to-native-top-level)) (let ((form (byte-to-native-top-level-form form))) diff --git a/src/alloc.c b/src/alloc.c index 00da90464be..5ff0d907915 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -7450,14 +7450,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}, 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}, 0}}; XSETSUBR (watcher, &Swatch_gc_cons_percentage.s); Fadd_variable_watcher (Qgc_cons_percentage, watcher); } diff --git a/src/comp.c b/src/comp.c index 5a00200ee87..a15bedf41aa 100644 --- a/src/comp.c +++ b/src/comp.c @@ -3304,11 +3304,11 @@ load_comp_unit (dynlib_handle_ptr handle, Lisp_Object file) DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr, - 5, 5, 0, + 6, 6, 0, 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 c_name, Lisp_Object doc, Lisp_Object intspec) { dynlib_handle_ptr handle = xmint_pointer (XCAR (load_handle_stack)); if (!handle) @@ -3325,7 +3325,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, x->s.min_args = XFIXNUM (minarg); x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name))); - x->s.intspec = NULL; + x->s.native_intspec = intspec; x->s.native_doc = doc; x->s.native_elisp = true; defsubr (x); diff --git a/src/data.c b/src/data.c index 50dce9e4644..67613881d67 100644 --- a/src/data.c +++ b/src/data.c @@ -899,6 +899,10 @@ Value, if non-nil, is a list (interactive SPEC). */) if (SUBRP (fun)) { +#ifdef HAVE_NATIVE_COMP + if (XSUBR (fun)->native_elisp && XSUBR (fun)->native_intspec) + return XSUBR (fun)->native_intspec; +#endif const char *spec = XSUBR (fun)->intspec; if (spec) return list2 (Qinteractive, diff --git a/src/lisp.h b/src/lisp.h index 1c692933cdb..56aa7b151e6 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2086,7 +2086,12 @@ struct Lisp_Subr } function; short min_args, max_args; const char *symbol_name; - const char *intspec; + union { + const char *intspec; +#ifdef HAVE_NATIVE_COMP + Lisp_Object native_intspec; +#endif + }; union { EMACS_INT doc; #ifdef HAVE_NATIVE_COMP @@ -3106,7 +3111,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}, 0}}; \ Lisp_Object fnname /* defsubr (Sname);