aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-09 07:44:06 +0400
committerDmitry Antipov2014-09-09 07:44:06 +0400
commitc7dfea947eba1980fe3a23ad13f04dd40c6c0d68 (patch)
tree3927b309d9773c54a06d7590e0dd6017a8c3bfc8 /src/alloc.c
parent80465f41d7fc67d40f0a233504e295b127ad2c6b (diff)
downloademacs-c7dfea947eba1980fe3a23ad13f04dd40c6c0d68.tar.gz
emacs-c7dfea947eba1980fe3a23ad13f04dd40c6c0d68.zip
Add macros to allocate temporary Lisp objects with alloca.
Respect MAX_ALLOCA and fall back to regular GC for large objects. * character.h (parse_str_as_multibyte): Move prototype to ... * lisp.h (parse_str_as_multibyte): ... here. (struct Lisp_Cons): Add GCALIGNED attribute if supported. (scoped_cons, scoped_list2, build_local_vector, build_local_string): New macros. (scoped_cons_init, pointer_valid_for_lisp_object, local_vector_init) (local_string_init): New functions. * alloc.c (verify_alloca) [ENABLE_CHECKING]: New function. (init_alloc_once): Call it.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 31b0644c285..13043d6d9d7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7117,8 +7117,29 @@ die (const char *msg, const char *file, int line)
7117 file, line, msg); 7117 file, line, msg);
7118 terminate_due_to_signal (SIGABRT, INT_MAX); 7118 terminate_due_to_signal (SIGABRT, INT_MAX);
7119} 7119}
7120#endif 7120
7121 7121/* Stress alloca with inconveniently sized requests and check
7122 whether all allocated areas may be used for Lisp_Object. */
7123
7124NO_INLINE static void
7125verify_alloca (void)
7126{
7127 int i;
7128 enum { ALLOCA_CHECK_MAX = 256 };
7129 /* Start from size of the smallest Lisp object. */
7130 for (i = sizeof (struct Lisp_Cons); i <= ALLOCA_CHECK_MAX; i++)
7131 {
7132 char *ptr = alloca (i);
7133 eassert (pointer_valid_for_lisp_object (ptr));
7134 }
7135}
7136
7137#else /* not ENABLE_CHECKING */
7138
7139#define verify_alloca() ((void) 0)
7140
7141#endif /* ENABLE_CHECKING */
7142
7122/* Initialization. */ 7143/* Initialization. */
7123 7144
7124void 7145void
@@ -7128,6 +7149,8 @@ init_alloc_once (void)
7128 purebeg = PUREBEG; 7149 purebeg = PUREBEG;
7129 pure_size = PURESIZE; 7150 pure_size = PURESIZE;
7130 7151
7152 verify_alloca ();
7153
7131#if GC_MARK_STACK || defined GC_MALLOC_CHECK 7154#if GC_MARK_STACK || defined GC_MALLOC_CHECK
7132 mem_init (); 7155 mem_init ();
7133 Vdead = make_pure_string ("DEAD", 4, 4, 0); 7156 Vdead = make_pure_string ("DEAD", 4, 4, 0);