summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKaroly Lorentey <lorentey@elte.hu>2004-12-23 16:43:51 +0000
committerKaroly Lorentey <lorentey@elte.hu>2004-12-23 16:43:51 +0000
commit17d51b68fb4e7da4f18eff72c589b7ffc4f9c22c (patch)
treef490c1ccdbd43077ea77f953bc59ca94c2fe810c /src/alloc.c
parent4b89585ee70a1f64543a5851f07cf7e2d89c5c62 (diff)
parent55f4edbcd246d8ea1715687a7aeeb3afe35c0345 (diff)
downloademacs-17d51b68fb4e7da4f18eff72c589b7ffc4f9c22c.tar.gz
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-726 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-727 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-728 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-729 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-730 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-731 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-732 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-733 Update from CVS: man/calc.texi: Fix some TeX definitions. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-734 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-735 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-736 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-737 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-738 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-739 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-740 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-741 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-742 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-743 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-744 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-745 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-746 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-75 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-76 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-77 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-277
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c109
1 files changed, 38 insertions, 71 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 4cf5de46d21..7a6a1344d6c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -99,7 +99,7 @@ extern __malloc_size_t __malloc_extra_blocks;
If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
functions below are called from malloc, there is a chance that one
of these threads preempts the Emacs main thread and the hook variables
- end up in a inconsistent state. So we have a mutex to prevent that (note
+ end up in an inconsistent state. So we have a mutex to prevent that (note
that the backend handles concurrent access to malloc within its own threads
but Emacs code running in the main thread is not included in that control).
@@ -109,7 +109,6 @@ extern __malloc_size_t __malloc_extra_blocks;
To prevent that, we only call BLOCK/UNBLOCK from the main thread. */
static pthread_mutex_t alloc_mutex;
-pthread_t main_thread;
#define BLOCK_INPUT_ALLOC \
do \
@@ -201,12 +200,6 @@ extern
#endif /* VIRT_ADDR_VARIES */
int malloc_sbrk_unused;
-/* Two limits controlling how much undo information to keep. */
-
-EMACS_INT undo_limit;
-EMACS_INT undo_strong_limit;
-EMACS_INT undo_outer_limit;
-
/* Number of live and free conses etc. */
static int total_conses, total_markers, total_symbols, total_vector_size;
@@ -1311,8 +1304,6 @@ uninterrupt_malloc ()
pthread_mutexattr_init (&attr);
pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init (&alloc_mutex, &attr);
-
- main_thread = pthread_self ();
#endif /* HAVE_GTK_AND_PTHREAD */
if (__free_hook != emacs_blocked_free)
@@ -4648,13 +4639,48 @@ returns nil, because real GC can't be done. */)
if (abort_on_gc)
abort ();
- EMACS_GET_TIME (t1);
-
/* Can't GC if pure storage overflowed because we can't determine
if something is a pure object or not. */
if (pure_bytes_used_before_overflow)
return Qnil;
+ /* Don't keep undo information around forever.
+ Do this early on, so it is no problem if the user quits. */
+ {
+ register struct buffer *nextb = all_buffers;
+
+ while (nextb)
+ {
+ /* If a buffer's undo list is Qt, that means that undo is
+ turned off in that buffer. Calling truncate_undo_list on
+ Qt tends to return NULL, which effectively turns undo back on.
+ So don't call truncate_undo_list if undo_list is Qt. */
+ if (! EQ (nextb->undo_list, Qt))
+ truncate_undo_list (nextb);
+
+ /* Shrink buffer gaps, but skip indirect and dead buffers. */
+ if (nextb->base_buffer == 0 && !NILP (nextb->name))
+ {
+ /* If a buffer's gap size is more than 10% of the buffer
+ size, or larger than 2000 bytes, then shrink it
+ accordingly. Keep a minimum size of 20 bytes. */
+ int size = min (2000, max (20, (nextb->text->z_byte / 10)));
+
+ if (nextb->text->gap_size > size)
+ {
+ struct buffer *save_current = current_buffer;
+ current_buffer = nextb;
+ make_gap (-(nextb->text->gap_size - size));
+ current_buffer = save_current;
+ }
+ }
+
+ nextb = nextb->next;
+ }
+ }
+
+ EMACS_GET_TIME (t1);
+
/* In case user calls debug_print during GC,
don't let that cause a recursive GC. */
consing_since_gc = 0;
@@ -4693,42 +4719,6 @@ returns nil, because real GC can't be done. */)
shrink_regexp_cache ();
- /* Don't keep undo information around forever. */
- {
- register struct buffer *nextb = all_buffers;
-
- while (nextb)
- {
- /* If a buffer's undo list is Qt, that means that undo is
- turned off in that buffer. Calling truncate_undo_list on
- Qt tends to return NULL, which effectively turns undo back on.
- So don't call truncate_undo_list if undo_list is Qt. */
- if (! EQ (nextb->undo_list, Qt))
- nextb->undo_list
- = truncate_undo_list (nextb->undo_list, undo_limit,
- undo_strong_limit, undo_outer_limit);
-
- /* Shrink buffer gaps, but skip indirect and dead buffers. */
- if (nextb->base_buffer == 0 && !NILP (nextb->name))
- {
- /* If a buffer's gap size is more than 10% of the buffer
- size, or larger than 2000 bytes, then shrink it
- accordingly. Keep a minimum size of 20 bytes. */
- int size = min (2000, max (20, (nextb->text->z_byte / 10)));
-
- if (nextb->text->gap_size > size)
- {
- struct buffer *save_current = current_buffer;
- current_buffer = nextb;
- make_gap (-(nextb->text->gap_size - size));
- current_buffer = save_current;
- }
- }
-
- nextb = nextb->next;
- }
- }
-
gc_in_progress = 1;
/* clear_marks (); */
@@ -6004,29 +5994,6 @@ prevent garbage collection during a part of the program. */);
doc: /* Non-nil means loading Lisp code in order to dump an executable.
This means that certain objects should be allocated in shared (pure) space. */);
- DEFVAR_INT ("undo-limit", &undo_limit,
- doc: /* Keep no more undo information once it exceeds this size.
-This limit is applied when garbage collection happens.
-The size is counted as the number of bytes occupied,
-which includes both saved text and other data. */);
- undo_limit = 20000;
-
- DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
- doc: /* Don't keep more than this much size of undo information.
-A previous command which pushes the undo list past this size
-is entirely forgotten when GC happens.
-The size is counted as the number of bytes occupied,
-which includes both saved text and other data. */);
- undo_strong_limit = 30000;
-
- DEFVAR_INT ("undo-outer-limit", &undo_outer_limit,
- doc: /* Don't keep more than this much size of undo information.
-If the current command has produced more than this much undo information,
-GC discards it. This is a last-ditch limit to prevent memory overflow.
-The size is counted as the number of bytes occupied,
-which includes both saved text and other data. */);
- undo_outer_limit = 300000;
-
DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
doc: /* Non-nil means display messages at start and end of garbage collection. */);
garbage_collection_messages = 0;