diff options
| author | Andrea Corallo | 2021-04-25 20:06:22 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2021-04-25 20:06:22 +0200 |
| commit | 289000eee729689b0cf362a21baa40ac7f9506f6 (patch) | |
| tree | 04e59d0f2bd7111749d8d97f829a410d4602a247 /src/data.c | |
| parent | 8f63f0078a23421eada97b4da51b9308b82532ce (diff) | |
| parent | fa65c044f2ebe666467166075c1507a8d0e1347f (diff) | |
| download | emacs-289000eee729689b0cf362a21baa40ac7f9506f6.tar.gz emacs-289000eee729689b0cf362a21baa40ac7f9506f6.zip | |
Merge branch 'feature/native-comp' into into trunk
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 95 |
1 files changed, 89 insertions, 6 deletions
diff --git a/src/data.c b/src/data.c index 3667b03c0e4..d547f5da5e0 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -88,12 +88,6 @@ XOBJFWD (lispfwd a) | |||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | static void | 90 | static void |
| 91 | CHECK_SUBR (Lisp_Object x) | ||
| 92 | { | ||
| 93 | CHECK_TYPE (SUBRP (x), Qsubrp, x); | ||
| 94 | } | ||
| 95 | |||
| 96 | static void | ||
| 97 | set_blv_found (struct Lisp_Buffer_Local_Value *blv, int found) | 91 | set_blv_found (struct Lisp_Buffer_Local_Value *blv, int found) |
| 98 | { | 92 | { |
| 99 | eassert (found == !EQ (blv->defcell, blv->valcell)); | 93 | eassert (found == !EQ (blv->defcell, blv->valcell)); |
| @@ -259,6 +253,8 @@ for example, (type-of 1) returns `integer'. */) | |||
| 259 | } | 253 | } |
| 260 | case PVEC_MODULE_FUNCTION: | 254 | case PVEC_MODULE_FUNCTION: |
| 261 | return Qmodule_function; | 255 | return Qmodule_function; |
| 256 | case PVEC_NATIVE_COMP_UNIT: | ||
| 257 | return Qnative_comp_unit; | ||
| 262 | case PVEC_XWIDGET: | 258 | case PVEC_XWIDGET: |
| 263 | return Qxwidget; | 259 | return Qxwidget; |
| 264 | case PVEC_XWIDGET_VIEW: | 260 | case PVEC_XWIDGET_VIEW: |
| @@ -779,6 +775,13 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, | |||
| 779 | 775 | ||
| 780 | eassert (valid_lisp_object_p (definition)); | 776 | eassert (valid_lisp_object_p (definition)); |
| 781 | 777 | ||
| 778 | #ifdef HAVE_NATIVE_COMP | ||
| 779 | if (comp_enable_subr_trampolines | ||
| 780 | && SUBRP (function) | ||
| 781 | && !SUBR_NATIVE_COMPILEDP (function)) | ||
| 782 | CALLN (Ffuncall, Qcomp_subr_trampoline_install, symbol); | ||
| 783 | #endif | ||
| 784 | |||
| 782 | set_symbol_function (symbol, definition); | 785 | set_symbol_function (symbol, definition); |
| 783 | 786 | ||
| 784 | return definition; | 787 | return definition; |
| @@ -824,6 +827,8 @@ The return value is undefined. */) | |||
| 824 | Ffset (symbol, definition); | 827 | Ffset (symbol, definition); |
| 825 | } | 828 | } |
| 826 | 829 | ||
| 830 | maybe_defer_native_compilation (symbol, definition); | ||
| 831 | |||
| 827 | if (!NILP (docstring)) | 832 | if (!NILP (docstring)) |
| 828 | Fput (symbol, Qfunction_documentation, docstring); | 833 | Fput (symbol, Qfunction_documentation, docstring); |
| 829 | /* We used to return `definition', but now that `defun' and `defmacro' expand | 834 | /* We used to return `definition', but now that `defun' and `defmacro' expand |
| @@ -870,6 +875,72 @@ SUBR must be a built-in function. */) | |||
| 870 | return build_string (name); | 875 | return build_string (name); |
| 871 | } | 876 | } |
| 872 | 877 | ||
| 878 | DEFUN ("subr-native-elisp-p", Fsubr_native_elisp_p, Ssubr_native_elisp_p, 1, 1, | ||
| 879 | 0, doc: /* Return t if the object is native compiled lisp | ||
| 880 | function, nil otherwise. */) | ||
| 881 | (Lisp_Object object) | ||
| 882 | { | ||
| 883 | return SUBR_NATIVE_COMPILEDP (object) ? Qt : Qnil; | ||
| 884 | } | ||
| 885 | |||
| 886 | DEFUN ("subr-native-lambda-list", Fsubr_native_lambda_list, | ||
| 887 | Ssubr_native_lambda_list, 1, 1, 0, | ||
| 888 | doc: /* Return the lambda list for a native compiled lisp/d | ||
| 889 | function or t otherwise. */) | ||
| 890 | (Lisp_Object subr) | ||
| 891 | { | ||
| 892 | CHECK_SUBR (subr); | ||
| 893 | |||
| 894 | return SUBR_NATIVE_COMPILED_DYNP (subr) | ||
| 895 | ? XSUBR (subr)->lambda_list[0] | ||
| 896 | : Qt; | ||
| 897 | } | ||
| 898 | |||
| 899 | DEFUN ("subr-type", Fsubr_type, | ||
| 900 | Ssubr_type, 1, 1, 0, | ||
| 901 | doc: /* Return the type of SUBR. */) | ||
| 902 | (Lisp_Object subr) | ||
| 903 | { | ||
| 904 | CHECK_SUBR (subr); | ||
| 905 | #ifdef HAVE_NATIVE_COMP | ||
| 906 | return SUBR_TYPE (subr); | ||
| 907 | #else | ||
| 908 | return Qnil; | ||
| 909 | #endif | ||
| 910 | } | ||
| 911 | |||
| 912 | #ifdef HAVE_NATIVE_COMP | ||
| 913 | |||
| 914 | DEFUN ("subr-native-comp-unit", Fsubr_native_comp_unit, | ||
| 915 | Ssubr_native_comp_unit, 1, 1, 0, | ||
| 916 | doc: /* Return the native compilation unit. */) | ||
| 917 | (Lisp_Object subr) | ||
| 918 | { | ||
| 919 | CHECK_SUBR (subr); | ||
| 920 | return XSUBR (subr)->native_comp_u[0]; | ||
| 921 | } | ||
| 922 | |||
| 923 | DEFUN ("native-comp-unit-file", Fnative_comp_unit_file, | ||
| 924 | Snative_comp_unit_file, 1, 1, 0, | ||
| 925 | doc: /* Return the file of the native compilation unit. */) | ||
| 926 | (Lisp_Object comp_unit) | ||
| 927 | { | ||
| 928 | CHECK_TYPE (NATIVE_COMP_UNITP (comp_unit), Qnative_comp_unit, comp_unit); | ||
| 929 | return XNATIVE_COMP_UNIT (comp_unit)->file; | ||
| 930 | } | ||
| 931 | |||
| 932 | DEFUN ("native-comp-unit-set-file", Fnative_comp_unit_set_file, | ||
| 933 | Snative_comp_unit_set_file, 2, 2, 0, | ||
| 934 | doc: /* Return the file of the native compilation unit. */) | ||
| 935 | (Lisp_Object comp_unit, Lisp_Object new_file) | ||
| 936 | { | ||
| 937 | CHECK_TYPE (NATIVE_COMP_UNITP (comp_unit), Qnative_comp_unit, comp_unit); | ||
| 938 | XNATIVE_COMP_UNIT (comp_unit)->file = new_file; | ||
| 939 | return comp_unit; | ||
| 940 | } | ||
| 941 | |||
| 942 | #endif | ||
| 943 | |||
| 873 | DEFUN ("interactive-form", Finteractive_form, Sinteractive_form, 1, 1, 0, | 944 | DEFUN ("interactive-form", Finteractive_form, Sinteractive_form, 1, 1, 0, |
| 874 | doc: /* Return the interactive form of CMD or nil if none. | 945 | doc: /* Return the interactive form of CMD or nil if none. |
| 875 | If CMD is not a command, the return value is nil. | 946 | If CMD is not a command, the return value is nil. |
| @@ -895,6 +966,9 @@ Value, if non-nil, is a list (interactive SPEC). */) | |||
| 895 | 966 | ||
| 896 | if (SUBRP (fun)) | 967 | if (SUBRP (fun)) |
| 897 | { | 968 | { |
| 969 | if (SUBR_NATIVE_COMPILEDP (fun) && !NILP (XSUBR (fun)->native_intspec)) | ||
| 970 | return XSUBR (fun)->native_intspec; | ||
| 971 | |||
| 898 | const char *spec = XSUBR (fun)->intspec; | 972 | const char *spec = XSUBR (fun)->intspec; |
| 899 | if (spec) | 973 | if (spec) |
| 900 | return list2 (Qinteractive, | 974 | return list2 (Qinteractive, |
| @@ -3961,6 +4035,7 @@ syms_of_data (void) | |||
| 3961 | DEFSYM (Qoverlay, "overlay"); | 4035 | DEFSYM (Qoverlay, "overlay"); |
| 3962 | DEFSYM (Qfinalizer, "finalizer"); | 4036 | DEFSYM (Qfinalizer, "finalizer"); |
| 3963 | DEFSYM (Qmodule_function, "module-function"); | 4037 | DEFSYM (Qmodule_function, "module-function"); |
| 4038 | DEFSYM (Qnative_comp_unit, "native-comp-unit"); | ||
| 3964 | DEFSYM (Quser_ptr, "user-ptr"); | 4039 | DEFSYM (Quser_ptr, "user-ptr"); |
| 3965 | DEFSYM (Qfloat, "float"); | 4040 | DEFSYM (Qfloat, "float"); |
| 3966 | DEFSYM (Qwindow_configuration, "window-configuration"); | 4041 | DEFSYM (Qwindow_configuration, "window-configuration"); |
| @@ -4085,6 +4160,14 @@ syms_of_data (void) | |||
| 4085 | defsubr (&Sbyteorder); | 4160 | defsubr (&Sbyteorder); |
| 4086 | defsubr (&Ssubr_arity); | 4161 | defsubr (&Ssubr_arity); |
| 4087 | defsubr (&Ssubr_name); | 4162 | defsubr (&Ssubr_name); |
| 4163 | defsubr (&Ssubr_native_elisp_p); | ||
| 4164 | defsubr (&Ssubr_native_lambda_list); | ||
| 4165 | defsubr (&Ssubr_type); | ||
| 4166 | #ifdef HAVE_NATIVE_COMP | ||
| 4167 | defsubr (&Ssubr_native_comp_unit); | ||
| 4168 | defsubr (&Snative_comp_unit_file); | ||
| 4169 | defsubr (&Snative_comp_unit_set_file); | ||
| 4170 | #endif | ||
| 4088 | #ifdef HAVE_MODULES | 4171 | #ifdef HAVE_MODULES |
| 4089 | defsubr (&Suser_ptrp); | 4172 | defsubr (&Suser_ptrp); |
| 4090 | #endif | 4173 | #endif |