comparison src/alloc.c @ 851:e7ee5f8bde58

[xemacs-hg @ 2002-05-23 11:46:08 by ben] fix for raymond toy's crash, alloca crashes, some recover-session improvements files.el: Recover-session improvements: Only show session files where some files can actually be recovered, and show in chronological order. subr.el, menubar-items.el: As promised to rms, the functionality in truncate-string-with-continuation-dots has been merged into truncate-string-to-width. Change callers in menubar-items.el. select.el: Document some of these funs better. Fix problem where we were doing own-clipboard twice. Makefile.in.in: Add alloca.o. Ensure that alloca.s doesn't compile into alloca.o, but allocax.o (not that it's currently used or anything.) EmacsFrame.c, abbrev.c, alloc.c, alloca.c, callint.c, callproc.c, config.h.in, device-msw.c, device-x.c, dired.c, doc.c, editfns.c, emacs.c, emodules.c, eval.c, event-Xt.c, event-msw.c, event-stream.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-x.c, input-method-xlib.c, intl-win32.c, lisp.h, lread.c, menubar-gtk.c, menubar-msw.c, menubar.c, mule-wnnfns.c, nt.c, objects-msw.c, process-nt.c, realpath.c, redisplay-gtk.c, redisplay-output.c, redisplay-x.c, redisplay.c, search.c, select-msw.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: Fix Raymond Toy's crash. Repeat to self: 2^21 - 1 is NOT the same as (2 << 21) - 1. Fix crashes due to excessive alloca(). replace alloca() with ALLOCA(), which calls the C alloca() [which uses xmalloc()] when the size is too big. Insert in various places calls to try to flush the C alloca() stored info if there is any. Add MALLOC_OR_ALLOCA(), for places that expect to be alloca()ing large blocks. This xmalloc()s when too large and records an unwind-protect to free -- relying on the caller to unbind_to() elsewhere in the function. Use it in concat(). Use MALLOC instead of ALLOCA in select-msw.c. xemacs.mak: Add alloca.o.
author ben
date Thu, 23 May 2002 11:46:46 +0000
parents 6728e641994e
children 2b6fa2618f76
comparison
equal deleted inserted replaced
850:f915ad7befaf 851:e7ee5f8bde58
92 #endif 92 #endif
93 93
94 /* Number of bytes of consing done since the last gc */ 94 /* Number of bytes of consing done since the last gc */
95 static EMACS_INT consing_since_gc; 95 static EMACS_INT consing_since_gc;
96 int need_to_garbage_collect; 96 int need_to_garbage_collect;
97 int need_to_check_c_alloca;
98 int funcall_allocation_flag;
99 Bytecount __temp_alloca_size__;
100 Bytecount funcall_alloca_count;
97 101
98 /* Determine now whether we need to garbage collect or not, to make 102 /* Determine now whether we need to garbage collect or not, to make
99 Ffuncall() faster */ 103 Ffuncall() faster */
100 #define INCREMENT_CONS_COUNTER_1(size) \ 104 #define INCREMENT_CONS_COUNTER_1(size) \
101 do \ 105 do \
399 good thing, as it will guarantee we won't get any intermittent bugs 403 good thing, as it will guarantee we won't get any intermittent bugs
400 coming from an uninitiated field. The speed loss if unnoticeable, 404 coming from an uninitiated field. The speed loss if unnoticeable,
401 esp. as the object are not large -- large stuff like buffer text and 405 esp. as the object are not large -- large stuff like buffer text and
402 redisplay structures and allocated separately. */ 406 redisplay structures and allocated separately. */
403 memset (val, 0, size); 407 memset (val, 0, size);
408
409 if (need_to_check_c_alloca)
410 xemacs_c_alloca (0);
411
404 return val; 412 return val;
405 } 413 }
406 414
407 415
408 /* lcrecords are chained together through their "next" field. 416 /* lcrecords are chained together through their "next" field.
1907 (Bytecount) MAX_STRING_ASCII_BEGIN)); 1915 (Bytecount) MAX_STRING_ASCII_BEGIN));
1908 } 1916 }
1909 #endif 1917 #endif
1910 1918
1911 /* You do NOT want to be calling this! (And if you do, you must call 1919 /* You do NOT want to be calling this! (And if you do, you must call
1912 XSET_STRING_ASCII_BEGIN() after modifying the string.) Use alloca() 1920 XSET_STRING_ASCII_BEGIN() after modifying the string.) Use ALLOCA ()
1913 instead and then call make_string() like the rest of the world. */ 1921 instead and then call make_string() like the rest of the world. */
1914 1922
1915 Lisp_Object 1923 Lisp_Object
1916 make_uninit_string (Bytecount length) 1924 make_uninit_string (Bytecount length)
1917 { 1925 {
3997 ()) 4005 ())
3998 { 4006 {
3999 return make_int (total_data_usage ()); 4007 return make_int (total_data_usage ());
4000 } 4008 }
4001 4009
4010 void
4011 recompute_funcall_allocation_flag (void)
4012 {
4013 funcall_allocation_flag = need_to_garbage_collect || need_to_check_c_alloca;
4014 }
4015
4002 /* True if it's time to garbage collect now. */ 4016 /* True if it's time to garbage collect now. */
4003 static void 4017 static void
4004 recompute_need_to_garbage_collect (void) 4018 recompute_need_to_garbage_collect (void)
4005 { 4019 {
4006 if (always_gc) 4020 if (always_gc)
4012 && 4026 &&
4013 (100 * consing_since_gc) / total_data_usage () >= 4027 (100 * consing_since_gc) / total_data_usage () >=
4014 gc_cons_percentage 4028 gc_cons_percentage
4015 #endif /* 0 */ 4029 #endif /* 0 */
4016 ); 4030 );
4031 recompute_funcall_allocation_flag ();
4017 } 4032 }
4018 4033
4019 4034
4020 int 4035 int
4021 object_dead_p (Lisp_Object obj) 4036 object_dead_p (Lisp_Object obj)
4217 Dynarr_resize (staticpro_nodump_names, 100); /* ditto */ 4232 Dynarr_resize (staticpro_nodump_names, 100); /* ditto */
4218 #endif 4233 #endif
4219 4234
4220 consing_since_gc = 0; 4235 consing_since_gc = 0;
4221 need_to_garbage_collect = always_gc; 4236 need_to_garbage_collect = always_gc;
4237 need_to_check_c_alloca = 0;
4238 funcall_allocation_flag = 0;
4239 funcall_alloca_count = 0;
4222 4240
4223 #if 1 4241 #if 1
4224 gc_cons_threshold = 500000; /* XEmacs change */ 4242 gc_cons_threshold = 500000; /* XEmacs change */
4225 #else 4243 #else
4226 gc_cons_threshold = 15000; /* debugging */ 4244 gc_cons_threshold = 15000; /* debugging */