diff src/alloc.c @ 887:ccc3177ef10b

[xemacs-hg @ 2002-06-28 14:21:41 by michaels] 2002-06-27 Mike Sperber <mike@xemacs.org> * eval.c (Ffuncall): Run `post-gc-hook' if GC just happened. * alloc.c (garbage_collect_1): Delay running `post-gc-hook' until later.
author michaels
date Fri, 28 Jun 2002 14:21:41 +0000
parents 79c6ff3eef26
children c925bacdda60
line wrap: on
line diff
--- a/src/alloc.c	Fri Jun 28 14:20:42 2002 +0000
+++ b/src/alloc.c	Fri Jun 28 14:21:41 2002 +0000
@@ -96,6 +96,7 @@
 static EMACS_INT consing_since_gc;
 int need_to_garbage_collect;
 int need_to_check_c_alloca;
+int need_to_signal_post_gc;
 int funcall_allocation_flag;
 Bytecount __temp_alloca_size__;
 Bytecount funcall_alloca_count;
@@ -3626,6 +3627,9 @@
      have infinite GC recursion. */
   speccount = begin_gc_forbidden ();
 
+  need_to_signal_post_gc = 0;
+  recompute_funcall_allocation_flag();
+
   if (!gc_hooks_inhibited)
     run_hook_trapping_problems
       ("Error in pre-gc-hook", Qpre_gc_hook,
@@ -3770,7 +3774,8 @@
      iterate until nothing more gets marked. */
 
   while (finish_marking_weak_hash_tables () > 0 ||
-	 finish_marking_weak_lists       () > 0)
+	 finish_marking_weak_lists       () > 0 ||
+	 finish_marking_ephemerons       () > 0)
     ;
 
   /* And prune (this needs to be called after everything else has been
@@ -3782,6 +3787,7 @@
   prune_specifiers ();
   prune_syntax_tables ();
 
+  prune_ephemerons ();
   prune_weak_boxes ();
 
   gc_sweep ();
@@ -3801,10 +3807,6 @@
 
   /******* End of garbage collection ********/
 
-  run_hook_trapping_problems
-    ("Error in post-gc-hook", Qpost_gc_hook,
-     INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION);
-
   /* Now remove the GC cursor/message */
   if (!noninteractive)
     {
@@ -3837,6 +3839,10 @@
     }
 
   UNGCPRO;
+
+  need_to_signal_post_gc = 1;
+  funcall_allocation_flag = 1;
+
   return;
 }
 
@@ -4012,7 +4018,10 @@
 void
 recompute_funcall_allocation_flag (void)
 {
-  funcall_allocation_flag = need_to_garbage_collect || need_to_check_c_alloca;
+  funcall_allocation_flag =
+    need_to_garbage_collect ||
+    need_to_check_c_alloca ||
+    need_to_signal_post_gc;
 }
 
 /* True if it's time to garbage collect now. */
@@ -4427,8 +4436,8 @@
   DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook /*
 Function or functions to be run just after each garbage collection.
 Interrupts, garbage collection, and errors are inhibited while this hook
-runs, so be extremely careful in what you add here.  In particular, avoid
-consing, and do not interact with the user.
+runs.  Each hook is called with one argument which is an alist with
+finalization data.
 */ );
   Vpost_gc_hook = Qnil;