aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2017-06-09 01:25:47 +0200
committerPhilipp Stephani2017-06-09 01:25:47 +0200
commit6e00ffe317797ead28ac45f9b609e35553bcdbd1 (patch)
treebb7476cce152dc4232f7463df2792c029083873c
parenta62d15763df16e64b452b24191e12c0e32a2de6b (diff)
downloademacs-6e00ffe317797ead28ac45f9b609e35553bcdbd1.tar.gz
emacs-6e00ffe317797ead28ac45f9b609e35553bcdbd1.zip
Add garbage collection support for module environments
* src/emacs-module.c (mark_modules): New function. (initialize_environment): Properly initialize Lisp objects. * src/alloc.c (garbage_collect_1): Call it.
-rw-r--r--src/alloc.c4
-rw-r--r--src/emacs-module.c14
-rw-r--r--src/lisp.h1
3 files changed, 19 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c
index a1a85946ce0..ac3de83b2b6 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5942,6 +5942,10 @@ garbage_collect_1 (void *end)
5942 mark_fringe_data (); 5942 mark_fringe_data ();
5943#endif 5943#endif
5944 5944
5945#ifdef HAVE_MODULES
5946 mark_modules ();
5947#endif
5948
5945 /* Everything is now marked, except for the data in font caches, 5949 /* Everything is now marked, except for the data in font caches,
5946 undo lists, and finalizers. The first two are compacted by 5950 undo lists, and finalizers. The first two are compacted by
5947 removing an items which aren't reachable otherwise. */ 5951 removing an items which aren't reachable otherwise. */
diff --git a/src/emacs-module.c b/src/emacs-module.c
index bebfe594426..1a8c1768230 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -871,6 +871,7 @@ static void
871initialize_environment (emacs_env *env, struct emacs_env_private *priv) 871initialize_environment (emacs_env *env, struct emacs_env_private *priv)
872{ 872{
873 priv->pending_non_local_exit = emacs_funcall_exit_return; 873 priv->pending_non_local_exit = emacs_funcall_exit_return;
874 priv->non_local_exit_symbol = priv->non_local_exit_data = Qnil;
874 env->size = sizeof *env; 875 env->size = sizeof *env;
875 env->private_members = priv; 876 env->private_members = priv;
876 env->make_global_ref = module_make_global_ref; 877 env->make_global_ref = module_make_global_ref;
@@ -926,6 +927,19 @@ finalize_runtime_unwind (void* raw_ert)
926 finalize_environment (&ert->private_members->pub); 927 finalize_environment (&ert->private_members->pub);
927} 928}
928 929
930void
931mark_modules (void)
932{
933 Lisp_Object tail = Vmodule_environments;
934 FOR_EACH_TAIL_SAFE (tail)
935 {
936 emacs_env *env = XSAVE_POINTER (XCAR (tail), 0);
937 struct emacs_env_private *priv = env->private_members;
938 mark_object (priv->non_local_exit_symbol);
939 mark_object (priv->non_local_exit_data);
940 }
941}
942
929 943
930/* Non-local exit handling. */ 944/* Non-local exit handling. */
931 945
diff --git a/src/lisp.h b/src/lisp.h
index c35bd1f6df1..ee703893e22 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3958,6 +3958,7 @@ extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
3958/* Defined in emacs-module.c. */ 3958/* Defined in emacs-module.c. */
3959extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *); 3959extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
3960extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *); 3960extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
3961extern void mark_modules (void);
3961extern void syms_of_module (void); 3962extern void syms_of_module (void);
3962#endif 3963#endif
3963 3964