]> git.eshelyaron.com Git - emacs.git/commitdiff
initial compilation unit as object add
authorAndrea Corallo <akrl@sdf.org>
Fri, 20 Dec 2019 04:22:09 +0000 (05:22 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:13 +0000 (11:38 +0100)
src/alloc.c
src/comp.h [new file with mode: 0644]
src/lisp.h
src/print.c

index 5ff0d907915feb1a9c9dd082bf368ca544d2fd94..d990f53f7a02908b4f3d80808ea142ffec64cd3f 100644 (file)
@@ -3023,6 +3023,15 @@ cleanup_vector (struct Lisp_Vector *vector)
       if (uptr->finalizer)
        uptr->finalizer (uptr->p);
     }
+#ifdef HAVE_NATIVE_COMP
+  else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT))
+    {
+      struct Lisp_Native_Compilation_Unit *cu =
+       PSEUDOVEC_STRUCT (vector, Lisp_Native_Compilation_Unit);
+      eassert (cu->handle);
+      dynlib_close (cu->handle);
+    }
+#endif
 }
 
 /* Reclaim space used by unmarked vectors.  */
@@ -6556,6 +6565,10 @@ mark_object (Lisp_Object arg)
            break;
 
          case PVEC_SUBR:
+#ifdef HAVE_NATIVE_COMP
+           if (XSUBR (obj)->native_comp_u)
+             set_vector_marked (ptr);
+#endif
            break;
 
          case PVEC_FREE:
@@ -6700,7 +6713,13 @@ survives_gc_p (Lisp_Object obj)
       break;
 
     case Lisp_Vectorlike:
+#ifdef HAVE_NATIVE_COMP
+      survives_p =
+       (SUBRP (obj) && !XSUBR (obj)->native_comp_u) ||
+       vector_marked_p (XVECTOR (obj));
+#else
       survives_p = SUBRP (obj) || vector_marked_p (XVECTOR (obj));
+#endif
       break;
 
     case Lisp_Cons:
diff --git a/src/comp.h b/src/comp.h
new file mode 100644 (file)
index 0000000..457b678
--- /dev/null
@@ -0,0 +1,52 @@
+/* Elisp native compiler definitions
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#ifndef COMP_H
+#define COMP_H
+
+#ifdef HAVE_NATIVE_COMP
+
+#include <dynlib.h>
+
+struct Lisp_Native_Compilation_Unit
+{
+  union vectorlike_header header;
+  /* Compilation unit file descriptor and handle.  */
+  int fd;
+  dynlib_handle_ptr handle;
+};
+
+INLINE bool
+COMPILATIONP_UNITP (Lisp_Object a)
+{
+  return PSEUDOVECTORP (a, PVEC_NATIVE_COMP_UNIT);
+}
+
+INLINE struct Lisp_Native_Compilation_Unit *
+XCOMPILATION_UNIT (Lisp_Object a)
+{
+  eassert (COMPILATIONP_UNITP (a));
+  return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Native_Compilation_Unit);
+}
+
+/* Defined in comp.c.  */
+extern void syms_of_comp (void);
+extern void fill_freloc (void);
+
+#endif
+#endif
index 04f729f182a8eb78928eccc4957298fe1831bf00..bb441b181a1a1db7e1e7ea99896c36f4e0a4aa3b 100644 (file)
@@ -34,10 +34,6 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <intprops.h>
 #include <verify.h>
 
-#ifdef HAVE_NATIVE_COMP
-#include <dynlib.h>
-#endif
-
 INLINE_HEADER_BEGIN
 
 /* Define a TYPE constant ID as an externally visible name.  Use like this:
@@ -1097,6 +1093,7 @@ enum pvec_type
   PVEC_MUTEX,
   PVEC_CONDVAR,
   PVEC_MODULE_FUNCTION,
+  PVEC_NATIVE_COMP_UNIT,
 
   /* These should be last, check internal_equal to see why.  */
   PVEC_COMPILED,
@@ -2068,10 +2065,7 @@ CHAR_TABLE_SET (Lisp_Object ct, int idx, Lisp_Object val)
     char_table_set (ct, idx, val);
 }
 
-struct Native_Compilation_Unit
-{
-  dynlib_handle_ptr handle;
-};
+#include "comp.h"
 
 /* This structure describes a built-in function.
    It is generated by the DEFUN macro only.
@@ -2104,7 +2098,7 @@ struct Lisp_Subr
       Lisp_Object native_doc;
     };
 #ifdef HAVE_NATIVE_COMP
-    struct Native_Compilation_Unit *native_comp_u;;
+    Lisp_Object native_comp_u;;
 #endif
   } GCALIGNED_STRUCT;
 union Aligned_Lisp_Subr
@@ -4759,12 +4753,6 @@ extern bool profiler_memory_running;
 extern void malloc_probe (size_t);
 extern void syms_of_profiler (void);
 
-#ifdef HAVE_NATIVE_COMP
-/* Defined in comp.c.  */
-extern void syms_of_comp (void);
-extern void fill_freloc (void);
-#endif /* HAVE_NATIVE_COMP */
-
 #ifdef DOS_NT
 /* Defined in msdos.c, w32.c.  */
 extern char *emacs_root_dir (void);
index 425b0dc4ee33a92d882e81b7cc2ef3552e6052bf..2e2c863ece806989f801d9170d0d251786a2fb61 100644 (file)
@@ -1825,7 +1825,16 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
       }
       break;
 #endif
-
+#ifdef HAVE_NATIVE_COMP
+    case PVEC_NATIVE_COMP_UNIT:
+      {
+       print_c_string ("#<native compilation unit>", printcharfun);
+       int len = sprintf (buf, "%d", XCOMPILATION_UNIT (obj)->fd);
+       strout (buf, len, len, printcharfun);
+       printchar ('>', printcharfun);
+      }
+      break;
+#endif
     default:
       emacs_abort ();
     }