]> git.eshelyaron.com Git - emacs.git/commitdiff
Add garbage collection support for module environments
authorPhilipp Stephani <phst@google.com>
Thu, 8 Jun 2017 23:25:47 +0000 (01:25 +0200)
committerPhilipp Stephani <phst@google.com>
Thu, 8 Jun 2017 23:25:47 +0000 (01:25 +0200)
* src/emacs-module.c (mark_modules): New function.
(initialize_environment): Properly initialize Lisp objects.
* src/alloc.c (garbage_collect_1): Call it.

src/alloc.c
src/emacs-module.c
src/lisp.h

index a1a85946ce0499c091457cf85d4f989de434df9e..ac3de83b2b6ab48f21c49e0f7410c94190e52109 100644 (file)
@@ -5942,6 +5942,10 @@ garbage_collect_1 (void *end)
   mark_fringe_data ();
 #endif
 
+#ifdef HAVE_MODULES
+  mark_modules ();
+#endif
+
   /* Everything is now marked, except for the data in font caches,
      undo lists, and finalizers.  The first two are compacted by
      removing an items which aren't reachable otherwise.  */
index bebfe594426b0490d199c37b0c21f2ba11ae3e14..1a8c1768230a74e84cfce6ed8d99e44ab03b5b33 100644 (file)
@@ -871,6 +871,7 @@ static void
 initialize_environment (emacs_env *env, struct emacs_env_private *priv)
 {
   priv->pending_non_local_exit = emacs_funcall_exit_return;
+  priv->non_local_exit_symbol = priv->non_local_exit_data = Qnil;
   env->size = sizeof *env;
   env->private_members = priv;
   env->make_global_ref = module_make_global_ref;
@@ -926,6 +927,19 @@ finalize_runtime_unwind (void* raw_ert)
   finalize_environment (&ert->private_members->pub);
 }
 
+void
+mark_modules (void)
+{
+  Lisp_Object tail = Vmodule_environments;
+  FOR_EACH_TAIL_SAFE (tail)
+  {
+    emacs_env *env = XSAVE_POINTER (XCAR (tail), 0);
+    struct emacs_env_private *priv = env->private_members;
+    mark_object (priv->non_local_exit_symbol);
+    mark_object (priv->non_local_exit_data);
+  }
+}
+
 \f
 /* Non-local exit handling.  */
 
index c35bd1f6df16ce18dec657cdb03536317adfa5e0..ee703893e2269ec5d32b786d414da3f4afd7736c 100644 (file)
@@ -3958,6 +3958,7 @@ extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
 /* Defined in emacs-module.c.  */
 extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
 extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
+extern void mark_modules (void);
 extern void syms_of_module (void);
 #endif