aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-09 15:43:22 +0400
committerDmitry Antipov2014-09-09 15:43:22 +0400
commite2588fa52fd7761e252361c341d8565790b3d1f2 (patch)
treed42c861fba7d5770d8371a8109768ea541595ae3 /src
parentc7dfea947eba1980fe3a23ad13f04dd40c6c0d68 (diff)
downloademacs-e2588fa52fd7761e252361c341d8565790b3d1f2.tar.gz
emacs-e2588fa52fd7761e252361c341d8565790b3d1f2.zip
Cleanup last change and make all new stuff conditional.
* lisp.h (build_local_string): Rename to ... (make_local_string): ... this macro. (build_local_string, scoped_list1, scoped_list3): New macros. (toplevel) [USE_STACK_LISP_OBJECTS]: Define all new macros and functions as such, use regular fallbacks otherwise. * alloc.c (verify_alloca) [USE_STACK_LISP_OBJECTS]: Define conditionally.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/alloc.c8
-rw-r--r--src/lisp.h34
3 files changed, 46 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d1e8314b172..b94ac53051a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -17,6 +17,15 @@
17 * alloc.c (verify_alloca) [ENABLE_CHECKING]: New function. 17 * alloc.c (verify_alloca) [ENABLE_CHECKING]: New function.
18 (init_alloc_once): Call it. 18 (init_alloc_once): Call it.
19 19
20 Cleanup last change and make all new stuff conditional.
21 * lisp.h (build_local_string): Rename to ...
22 (make_local_string): ... this macro.
23 (build_local_string, scoped_list1, scoped_list3): New macros.
24 (toplevel) [USE_STACK_LISP_OBJECTS]: Define all new macros
25 and functions as such, use regular fallbacks otherwise.
26 * alloc.c (verify_alloca) [USE_STACK_LISP_OBJECTS]: Define
27 conditionally.
28
202014-09-08 Eli Zaretskii <eliz@gnu.org> 292014-09-08 Eli Zaretskii <eliz@gnu.org>
21 30
22 * dispnew.c (prepare_desired_row): When MODE_LINE_P is zero, 31 * dispnew.c (prepare_desired_row): When MODE_LINE_P is zero,
diff --git a/src/alloc.c b/src/alloc.c
index 13043d6d9d7..5c7ce31cad8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7118,6 +7118,10 @@ die (const char *msg, const char *file, int line)
7118 terminate_due_to_signal (SIGABRT, INT_MAX); 7118 terminate_due_to_signal (SIGABRT, INT_MAX);
7119} 7119}
7120 7120
7121#endif /* ENABLE_CHECKING */
7122
7123#if defined (ENABLE_CHECKING) && defined (USE_STACK_LISP_OBJECTS)
7124
7121/* Stress alloca with inconveniently sized requests and check 7125/* Stress alloca with inconveniently sized requests and check
7122 whether all allocated areas may be used for Lisp_Object. */ 7126 whether all allocated areas may be used for Lisp_Object. */
7123 7127
@@ -7134,11 +7138,11 @@ verify_alloca (void)
7134 } 7138 }
7135} 7139}
7136 7140
7137#else /* not ENABLE_CHECKING */ 7141#else /* not (ENABLE_CHECKING && USE_STACK_LISP_OBJECTS) */
7138 7142
7139#define verify_alloca() ((void) 0) 7143#define verify_alloca() ((void) 0)
7140 7144
7141#endif /* ENABLE_CHECKING */ 7145#endif /* ENABLE_CHECKING && USE_STACK_LISP_OBJECTS */
7142 7146
7143/* Initialization. */ 7147/* Initialization. */
7144 7148
diff --git a/src/lisp.h b/src/lisp.h
index a89e80729cd..cbb4c30bea1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4546,6 +4546,12 @@ extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
4546 memory_full (SIZE_MAX); \ 4546 memory_full (SIZE_MAX); \
4547 } while (false) 4547 } while (false)
4548 4548
4549/* This feature is experimental and requires very careful debugging.
4550 Brave user should compile with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS'
4551 to get into the game. */
4552
4553#ifdef USE_STACK_LISP_OBJECTS
4554
4549/* Use the following functions to allocate temporary (function- 4555/* Use the following functions to allocate temporary (function-
4550 or block-scoped) conses, vectors, and strings. These objects 4556 or block-scoped) conses, vectors, and strings. These objects
4551 are not managed by GC, and passing them out of their scope 4557 are not managed by GC, and passing them out of their scope
@@ -4582,9 +4588,12 @@ scoped_cons_init (void *ptr, Lisp_Object x, Lisp_Object y)
4582 4588
4583#endif /* __GNUC__ etc... */ 4589#endif /* __GNUC__ etc... */
4584 4590
4585/* Convenient utility macro similar to list2. */ 4591/* Convenient utility macros similar to listX functions. */
4586 4592
4593#define scoped_list1(x) scoped_cons (x, Qnil)
4587#define scoped_list2(x, y) scoped_cons (x, scoped_cons (y, Qnil)) 4594#define scoped_list2(x, y) scoped_cons (x, scoped_cons (y, Qnil))
4595#define scoped_list3(x, y, z) \
4596 scoped_cons (x, scoped_cons (y, scoped_cons (z, Qnil)))
4588 4597
4589/* True if Lisp_Object may be placed at P. Used only 4598/* True if Lisp_Object may be placed at P. Used only
4590 under ENABLE_CHECKING and optimized away otherwise. */ 4599 under ENABLE_CHECKING and optimized away otherwise. */
@@ -4622,7 +4631,7 @@ local_vector_init (uintptr_t addr, ptrdiff_t length, Lisp_Object init)
4622 ((size) * word_size + header_size)), \ 4631 ((size) * word_size + header_size)), \
4623 obj = local_vector_init ((uintptr_t) XLI (obj), (size), (init)))) 4632 obj = local_vector_init ((uintptr_t) XLI (obj), (size), (init))))
4624 4633
4625/* Helper function for build_local_string, see below. */ 4634/* Helper function for make_local_string, see below. */
4626 4635
4627INLINE Lisp_Object 4636INLINE Lisp_Object
4628local_string_init (uintptr_t addr, const char *data, ptrdiff_t size) 4637local_string_init (uintptr_t addr, const char *data, ptrdiff_t size)
@@ -4648,13 +4657,32 @@ local_string_init (uintptr_t addr, const char *data, ptrdiff_t size)
4648 with contents DATA of length NBYTES. Otherwise create regular 4657 with contents DATA of length NBYTES. Otherwise create regular
4649 GC-managed string. */ 4658 GC-managed string. */
4650 4659
4651#define build_local_string(obj, data, nbytes) \ 4660#define make_local_string(obj, data, nbytes) \
4652 (MAX_ALLOCA < (nbytes) + sizeof (struct Lisp_String) \ 4661 (MAX_ALLOCA < (nbytes) + sizeof (struct Lisp_String) \
4653 ? obj = make_string ((data), (nbytes)) \ 4662 ? obj = make_string ((data), (nbytes)) \
4654 : (obj = XIL ((uintptr_t) alloca \ 4663 : (obj = XIL ((uintptr_t) alloca \
4655 ((nbytes) + sizeof (struct Lisp_String))), \ 4664 ((nbytes) + sizeof (struct Lisp_String))), \
4656 obj = local_string_init ((uintptr_t) XLI (obj), data, nbytes))) 4665 obj = local_string_init ((uintptr_t) XLI (obj), data, nbytes)))
4657 4666
4667/* We want an interface similar to make_string and build_string, right? */
4668
4669#define build_local_string(obj, data) \
4670 make_local_string (obj, data, strlen (data))
4671
4672#else /* not USE_STACK_LISP_OBJECTS */
4673
4674#define scoped_cons(x, y) Fcons ((x), (y))
4675#define scoped_list1(x) list1 (x)
4676#define scoped_list2(x, y) list2 ((x), (y))
4677#define scoped_list3(x, y, z) list3 ((x), (y), (z))
4678#define build_local_vector(obj, size, init) \
4679 (obj = Fmake_vector (make_number ((size), (init))))
4680#define make_local_string(obj, data, nbytes) \
4681 (obj = make_string ((data), (nbytes)))
4682#define build_local_string(obj, data) (obj = build_string (data))
4683
4684#endif /* USE_STACK_LISP_OBJECTS */
4685
4658/* Loop over all tails of a list, checking for cycles. 4686/* Loop over all tails of a list, checking for cycles.
4659 FIXME: Make tortoise and n internal declarations. 4687 FIXME: Make tortoise and n internal declarations.
4660 FIXME: Unroll the loop body so we don't need `n'. */ 4688 FIXME: Unroll the loop body so we don't need `n'. */