diff options
| author | Andrea Corallo | 2019-12-07 11:28:21 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:38:11 +0100 |
| commit | f4de790beec514808eafd1cb22fa5eacdecd4552 (patch) | |
| tree | 0c14d43cd7313875a9730a3834de30d59ef40aaf | |
| parent | e05253cb9bc4a35c7dedc3cbb2830e37d385a339 (diff) | |
| download | emacs-f4de790beec514808eafd1cb22fa5eacdecd4552.tar.gz emacs-f4de790beec514808eafd1cb22fa5eacdecd4552.zip | |
add native compiled function docstring support
| -rw-r--r-- | lisp/help-fns.el | 8 | ||||
| -rw-r--r-- | src/alloc.c | 4 | ||||
| -rw-r--r-- | src/comp.c | 8 | ||||
| -rw-r--r-- | src/doc.c | 12 | ||||
| -rw-r--r-- | src/lisp.h | 9 |
5 files changed, 30 insertions, 11 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 0e2ae6b3c3c..afa5c9be940 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -377,7 +377,7 @@ suitable file is found, return nil." | |||
| 377 | ;; This applies to config files like ~/.emacs, | 377 | ;; This applies to config files like ~/.emacs, |
| 378 | ;; which people sometimes compile. | 378 | ;; which people sometimes compile. |
| 379 | ((let (fn) | 379 | ((let (fn) |
| 380 | (and (string-match "\\`\\..*\\.elc\\'" | 380 | (and (string-match "\\`\\..*\\.el[cn]\\'" |
| 381 | (file-name-nondirectory file-name)) | 381 | (file-name-nondirectory file-name)) |
| 382 | (string-equal (file-name-directory file-name) | 382 | (string-equal (file-name-directory file-name) |
| 383 | (file-name-as-directory (expand-file-name "~"))) | 383 | (file-name-as-directory (expand-file-name "~"))) |
| @@ -386,7 +386,7 @@ suitable file is found, return nil." | |||
| 386 | ;; When the Elisp source file can be found in the install | 386 | ;; When the Elisp source file can be found in the install |
| 387 | ;; directory, return the name of that file. | 387 | ;; directory, return the name of that file. |
| 388 | ((let ((lib-name | 388 | ((let ((lib-name |
| 389 | (if (string-match "[.]elc\\'" file-name) | 389 | (if (string-match "[.]el[cn]\\'" file-name) |
| 390 | (substring-no-properties file-name 0 -1) | 390 | (substring-no-properties file-name 0 -1) |
| 391 | file-name))) | 391 | file-name))) |
| 392 | (or (and (file-readable-p lib-name) lib-name) | 392 | (or (and (file-readable-p lib-name) lib-name) |
| @@ -399,7 +399,7 @@ suitable file is found, return nil." | |||
| 399 | ;; name, convert that back to a file name and see if we | 399 | ;; name, convert that back to a file name and see if we |
| 400 | ;; get the original one. If so, they are equivalent. | 400 | ;; get the original one. If so, they are equivalent. |
| 401 | (if (equal file-name (locate-file lib-name load-path '(""))) | 401 | (if (equal file-name (locate-file lib-name load-path '(""))) |
| 402 | (if (string-match "[.]elc\\'" lib-name) | 402 | (if (string-match "[.]el[cn]\\'" lib-name) |
| 403 | (substring-no-properties lib-name 0 -1) | 403 | (substring-no-properties lib-name 0 -1) |
| 404 | lib-name) | 404 | lib-name) |
| 405 | file-name)) | 405 | file-name)) |
| @@ -738,6 +738,8 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)." | |||
| 738 | ;; aliases before functions. | 738 | ;; aliases before functions. |
| 739 | (aliased | 739 | (aliased |
| 740 | (format-message "an alias for `%s'" real-def)) | 740 | (format-message "an alias for `%s'" real-def)) |
| 741 | ((subr-native-elisp-p def) | ||
| 742 | "native compiled Lisp function") | ||
| 741 | ((subrp def) | 743 | ((subrp def) |
| 742 | (concat beg (if (eq 'unevalled (cdr (subr-arity def))) | 744 | (concat beg (if (eq 'unevalled (cdr (subr-arity def))) |
| 743 | "special form" | 745 | "special form" |
diff --git a/src/alloc.c b/src/alloc.c index 1c6b664b220..00da90464be 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -7450,14 +7450,14 @@ N should be nonnegative. */); | |||
| 7450 | static union Aligned_Lisp_Subr Swatch_gc_cons_threshold = | 7450 | static union Aligned_Lisp_Subr Swatch_gc_cons_threshold = |
| 7451 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, | 7451 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, |
| 7452 | { .a4 = watch_gc_cons_threshold }, | 7452 | { .a4 = watch_gc_cons_threshold }, |
| 7453 | 4, 4, "watch_gc_cons_threshold", 0, 0}}; | 7453 | 4, 4, "watch_gc_cons_threshold", 0, {0}}}; |
| 7454 | XSETSUBR (watcher, &Swatch_gc_cons_threshold.s); | 7454 | XSETSUBR (watcher, &Swatch_gc_cons_threshold.s); |
| 7455 | Fadd_variable_watcher (Qgc_cons_threshold, watcher); | 7455 | Fadd_variable_watcher (Qgc_cons_threshold, watcher); |
| 7456 | 7456 | ||
| 7457 | static union Aligned_Lisp_Subr Swatch_gc_cons_percentage = | 7457 | static union Aligned_Lisp_Subr Swatch_gc_cons_percentage = |
| 7458 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, | 7458 | {{{ PSEUDOVECTOR_FLAG | (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) }, |
| 7459 | { .a4 = watch_gc_cons_percentage }, | 7459 | { .a4 = watch_gc_cons_percentage }, |
| 7460 | 4, 4, "watch_gc_cons_percentage", 0, 0}}; | 7460 | 4, 4, "watch_gc_cons_percentage", 0, {0}}}; |
| 7461 | XSETSUBR (watcher, &Swatch_gc_cons_percentage.s); | 7461 | XSETSUBR (watcher, &Swatch_gc_cons_percentage.s); |
| 7462 | Fadd_variable_watcher (Qgc_cons_percentage, watcher); | 7462 | Fadd_variable_watcher (Qgc_cons_percentage, watcher); |
| 7463 | } | 7463 | } |
diff --git a/src/comp.c b/src/comp.c index e2629de0426..5a00200ee87 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -3317,17 +3317,21 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, | |||
| 3317 | void *func = dynlib_sym (handle, SSDATA (c_name)); | 3317 | void *func = dynlib_sym (handle, SSDATA (c_name)); |
| 3318 | eassert (func); | 3318 | eassert (func); |
| 3319 | 3319 | ||
| 3320 | /* FIXME add gc support, now just leaking. */ | ||
| 3320 | union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); | 3321 | union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); |
| 3322 | |||
| 3321 | x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; | 3323 | x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; |
| 3322 | x->s.function.a0 = func; | 3324 | x->s.function.a0 = func; |
| 3323 | x->s.min_args = XFIXNUM (minarg); | 3325 | x->s.min_args = XFIXNUM (minarg); |
| 3324 | x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; | 3326 | x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; |
| 3325 | x->s.symbol_name = SSDATA (Fsymbol_name (name)); | 3327 | x->s.symbol_name = xstrdup (SSDATA (Fsymbol_name (name))); |
| 3326 | x->s.intspec = NULL; | 3328 | x->s.intspec = NULL; |
| 3327 | x->s.doc = 0; /* FIXME */ | 3329 | x->s.native_doc = doc; |
| 3328 | x->s.native_elisp = true; | 3330 | x->s.native_elisp = true; |
| 3329 | defsubr (x); | 3331 | defsubr (x); |
| 3330 | 3332 | ||
| 3333 | LOADHIST_ATTACH (Fcons (Qdefun, name)); | ||
| 3334 | |||
| 3331 | return Qnil; | 3335 | return Qnil; |
| 3332 | } | 3336 | } |
| 3333 | 3337 | ||
| @@ -335,6 +335,11 @@ string is passed through `substitute-command-keys'. */) | |||
| 335 | xsignal1 (Qvoid_function, function); | 335 | xsignal1 (Qvoid_function, function); |
| 336 | if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) | 336 | if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) |
| 337 | fun = XCDR (fun); | 337 | fun = XCDR (fun); |
| 338 | #ifdef HAVE_NATIVE_COMP | ||
| 339 | if (!NILP (Fsubr_native_elisp_p (fun))) | ||
| 340 | doc = XSUBR (fun)->native_doc; | ||
| 341 | else | ||
| 342 | #endif | ||
| 338 | if (SUBRP (fun)) | 343 | if (SUBRP (fun)) |
| 339 | doc = make_fixnum (XSUBR (fun)->doc); | 344 | doc = make_fixnum (XSUBR (fun)->doc); |
| 340 | #ifdef HAVE_MODULES | 345 | #ifdef HAVE_MODULES |
| @@ -508,7 +513,12 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset) | |||
| 508 | 513 | ||
| 509 | /* Lisp_Subrs have a slot for it. */ | 514 | /* Lisp_Subrs have a slot for it. */ |
| 510 | else if (SUBRP (fun)) | 515 | else if (SUBRP (fun)) |
| 511 | XSUBR (fun)->doc = offset; | 516 | { |
| 517 | #ifdef HAVE_NATIVE_COMP | ||
| 518 | eassert (NILP (Fsubr_native_elisp_p (fun))); | ||
| 519 | #endif | ||
| 520 | XSUBR (fun)->doc = offset; | ||
| 521 | } | ||
| 512 | 522 | ||
| 513 | /* Bytecode objects sometimes have slots for it. */ | 523 | /* Bytecode objects sometimes have slots for it. */ |
| 514 | else if (COMPILEDP (fun)) | 524 | else if (COMPILEDP (fun)) |
diff --git a/src/lisp.h b/src/lisp.h index a84c08e5669..1c692933cdb 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2087,10 +2087,13 @@ struct Lisp_Subr | |||
| 2087 | short min_args, max_args; | 2087 | short min_args, max_args; |
| 2088 | const char *symbol_name; | 2088 | const char *symbol_name; |
| 2089 | const char *intspec; | 2089 | const char *intspec; |
| 2090 | EMACS_INT doc; | 2090 | union { |
| 2091 | EMACS_INT doc; | ||
| 2091 | #ifdef HAVE_NATIVE_COMP | 2092 | #ifdef HAVE_NATIVE_COMP |
| 2092 | bool native_elisp; | 2093 | Lisp_Object native_doc; |
| 2093 | #endif | 2094 | #endif |
| 2095 | }; | ||
| 2096 | bool native_elisp; | ||
| 2094 | } GCALIGNED_STRUCT; | 2097 | } GCALIGNED_STRUCT; |
| 2095 | union Aligned_Lisp_Subr | 2098 | union Aligned_Lisp_Subr |
| 2096 | { | 2099 | { |
| @@ -3103,7 +3106,7 @@ CHECK_INTEGER (Lisp_Object x) | |||
| 3103 | static union Aligned_Lisp_Subr sname = \ | 3106 | static union Aligned_Lisp_Subr sname = \ |
| 3104 | {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ | 3107 | {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ |
| 3105 | { .a ## maxargs = fnname }, \ | 3108 | { .a ## maxargs = fnname }, \ |
| 3106 | minargs, maxargs, lname, intspec, 0}}; \ | 3109 | minargs, maxargs, lname, intspec, {0}}}; \ |
| 3107 | Lisp_Object fnname | 3110 | Lisp_Object fnname |
| 3108 | 3111 | ||
| 3109 | /* defsubr (Sname); | 3112 | /* defsubr (Sname); |