aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2019-12-20 05:22:09 +0100
committerAndrea Corallo2020-01-01 11:38:13 +0100
commit4496a3f5ba899c89e45cd478a22b25ddf77869ec (patch)
treefdc43a9698554a5a218104e762e80e43428c07dc /src
parentb3cbdfc86474932e4ef8d1237ed100a6f4f4c854 (diff)
downloademacs-4496a3f5ba899c89e45cd478a22b25ddf77869ec.tar.gz
emacs-4496a3f5ba899c89e45cd478a22b25ddf77869ec.zip
initial compilation unit as object add
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c19
-rw-r--r--src/comp.h52
-rw-r--r--src/lisp.h18
-rw-r--r--src/print.c11
4 files changed, 84 insertions, 16 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 5ff0d907915..d990f53f7a0 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3023,6 +3023,15 @@ cleanup_vector (struct Lisp_Vector *vector)
3023 if (uptr->finalizer) 3023 if (uptr->finalizer)
3024 uptr->finalizer (uptr->p); 3024 uptr->finalizer (uptr->p);
3025 } 3025 }
3026#ifdef HAVE_NATIVE_COMP
3027 else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT))
3028 {
3029 struct Lisp_Native_Compilation_Unit *cu =
3030 PSEUDOVEC_STRUCT (vector, Lisp_Native_Compilation_Unit);
3031 eassert (cu->handle);
3032 dynlib_close (cu->handle);
3033 }
3034#endif
3026} 3035}
3027 3036
3028/* Reclaim space used by unmarked vectors. */ 3037/* Reclaim space used by unmarked vectors. */
@@ -6556,6 +6565,10 @@ mark_object (Lisp_Object arg)
6556 break; 6565 break;
6557 6566
6558 case PVEC_SUBR: 6567 case PVEC_SUBR:
6568#ifdef HAVE_NATIVE_COMP
6569 if (XSUBR (obj)->native_comp_u)
6570 set_vector_marked (ptr);
6571#endif
6559 break; 6572 break;
6560 6573
6561 case PVEC_FREE: 6574 case PVEC_FREE:
@@ -6700,7 +6713,13 @@ survives_gc_p (Lisp_Object obj)
6700 break; 6713 break;
6701 6714
6702 case Lisp_Vectorlike: 6715 case Lisp_Vectorlike:
6716#ifdef HAVE_NATIVE_COMP
6717 survives_p =
6718 (SUBRP (obj) && !XSUBR (obj)->native_comp_u) ||
6719 vector_marked_p (XVECTOR (obj));
6720#else
6703 survives_p = SUBRP (obj) || vector_marked_p (XVECTOR (obj)); 6721 survives_p = SUBRP (obj) || vector_marked_p (XVECTOR (obj));
6722#endif
6704 break; 6723 break;
6705 6724
6706 case Lisp_Cons: 6725 case Lisp_Cons:
diff --git a/src/comp.h b/src/comp.h
new file mode 100644
index 00000000000..457b678699c
--- /dev/null
+++ b/src/comp.h
@@ -0,0 +1,52 @@
1/* Elisp native compiler definitions
2Copyright (C) 2012-2019 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef COMP_H
20#define COMP_H
21
22#ifdef HAVE_NATIVE_COMP
23
24#include <dynlib.h>
25
26struct Lisp_Native_Compilation_Unit
27{
28 union vectorlike_header header;
29 /* Compilation unit file descriptor and handle. */
30 int fd;
31 dynlib_handle_ptr handle;
32};
33
34INLINE bool
35COMPILATIONP_UNITP (Lisp_Object a)
36{
37 return PSEUDOVECTORP (a, PVEC_NATIVE_COMP_UNIT);
38}
39
40INLINE struct Lisp_Native_Compilation_Unit *
41XCOMPILATION_UNIT (Lisp_Object a)
42{
43 eassert (COMPILATIONP_UNITP (a));
44 return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Native_Compilation_Unit);
45}
46
47/* Defined in comp.c. */
48extern void syms_of_comp (void);
49extern void fill_freloc (void);
50
51#endif
52#endif
diff --git a/src/lisp.h b/src/lisp.h
index 04f729f182a..bb441b181a1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -34,10 +34,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
34#include <intprops.h> 34#include <intprops.h>
35#include <verify.h> 35#include <verify.h>
36 36
37#ifdef HAVE_NATIVE_COMP
38#include <dynlib.h>
39#endif
40
41INLINE_HEADER_BEGIN 37INLINE_HEADER_BEGIN
42 38
43/* Define a TYPE constant ID as an externally visible name. Use like this: 39/* Define a TYPE constant ID as an externally visible name. Use like this:
@@ -1097,6 +1093,7 @@ enum pvec_type
1097 PVEC_MUTEX, 1093 PVEC_MUTEX,
1098 PVEC_CONDVAR, 1094 PVEC_CONDVAR,
1099 PVEC_MODULE_FUNCTION, 1095 PVEC_MODULE_FUNCTION,
1096 PVEC_NATIVE_COMP_UNIT,
1100 1097
1101 /* These should be last, check internal_equal to see why. */ 1098 /* These should be last, check internal_equal to see why. */
1102 PVEC_COMPILED, 1099 PVEC_COMPILED,
@@ -2068,10 +2065,7 @@ CHAR_TABLE_SET (Lisp_Object ct, int idx, Lisp_Object val)
2068 char_table_set (ct, idx, val); 2065 char_table_set (ct, idx, val);
2069} 2066}
2070 2067
2071struct Native_Compilation_Unit 2068#include "comp.h"
2072{
2073 dynlib_handle_ptr handle;
2074};
2075 2069
2076/* This structure describes a built-in function. 2070/* This structure describes a built-in function.
2077 It is generated by the DEFUN macro only. 2071 It is generated by the DEFUN macro only.
@@ -2104,7 +2098,7 @@ struct Lisp_Subr
2104 Lisp_Object native_doc; 2098 Lisp_Object native_doc;
2105 }; 2099 };
2106#ifdef HAVE_NATIVE_COMP 2100#ifdef HAVE_NATIVE_COMP
2107 struct Native_Compilation_Unit *native_comp_u;; 2101 Lisp_Object native_comp_u;;
2108#endif 2102#endif
2109 } GCALIGNED_STRUCT; 2103 } GCALIGNED_STRUCT;
2110union Aligned_Lisp_Subr 2104union Aligned_Lisp_Subr
@@ -4759,12 +4753,6 @@ extern bool profiler_memory_running;
4759extern void malloc_probe (size_t); 4753extern void malloc_probe (size_t);
4760extern void syms_of_profiler (void); 4754extern void syms_of_profiler (void);
4761 4755
4762#ifdef HAVE_NATIVE_COMP
4763/* Defined in comp.c. */
4764extern void syms_of_comp (void);
4765extern void fill_freloc (void);
4766#endif /* HAVE_NATIVE_COMP */
4767
4768#ifdef DOS_NT 4756#ifdef DOS_NT
4769/* Defined in msdos.c, w32.c. */ 4757/* Defined in msdos.c, w32.c. */
4770extern char *emacs_root_dir (void); 4758extern char *emacs_root_dir (void);
diff --git a/src/print.c b/src/print.c
index 425b0dc4ee3..2e2c863ece8 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1825,7 +1825,16 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
1825 } 1825 }
1826 break; 1826 break;
1827#endif 1827#endif
1828 1828#ifdef HAVE_NATIVE_COMP
1829 case PVEC_NATIVE_COMP_UNIT:
1830 {
1831 print_c_string ("#<native compilation unit>", printcharfun);
1832 int len = sprintf (buf, "%d", XCOMPILATION_UNIT (obj)->fd);
1833 strout (buf, len, len, printcharfun);
1834 printchar ('>', printcharfun);
1835 }
1836 break;
1837#endif
1829 default: 1838 default:
1830 emacs_abort (); 1839 emacs_abort ();
1831 } 1840 }