* alloc.c (verify_alloca) [ENABLE_CHECKING]: New function.
(init_alloc_once): Call it.
+ 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.
+
2014-09-08 Eli Zaretskii <eliz@gnu.org>
* dispnew.c (prepare_desired_row): When MODE_LINE_P is zero,
memory_full (SIZE_MAX); \
} while (false)
+/* This feature is experimental and requires very careful debugging.
+ Brave user should compile with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS'
+ to get into the game. */
+
+#ifdef USE_STACK_LISP_OBJECTS
+
/* Use the following functions to allocate temporary (function-
or block-scoped) conses, vectors, and strings. These objects
are not managed by GC, and passing them out of their scope
#endif /* __GNUC__ etc... */
-/* Convenient utility macro similar to list2. */
+/* Convenient utility macros similar to listX functions. */
+#define scoped_list1(x) scoped_cons (x, Qnil)
#define scoped_list2(x, y) scoped_cons (x, scoped_cons (y, Qnil))
+#define scoped_list3(x, y, z) \
+ scoped_cons (x, scoped_cons (y, scoped_cons (z, Qnil)))
/* True if Lisp_Object may be placed at P. Used only
under ENABLE_CHECKING and optimized away otherwise. */
((size) * word_size + header_size)), \
obj = local_vector_init ((uintptr_t) XLI (obj), (size), (init))))
-/* Helper function for build_local_string, see below. */
+/* Helper function for make_local_string, see below. */
INLINE Lisp_Object
local_string_init (uintptr_t addr, const char *data, ptrdiff_t size)
with contents DATA of length NBYTES. Otherwise create regular
GC-managed string. */
-#define build_local_string(obj, data, nbytes) \
+#define make_local_string(obj, data, nbytes) \
(MAX_ALLOCA < (nbytes) + sizeof (struct Lisp_String) \
? obj = make_string ((data), (nbytes)) \
: (obj = XIL ((uintptr_t) alloca \
((nbytes) + sizeof (struct Lisp_String))), \
obj = local_string_init ((uintptr_t) XLI (obj), data, nbytes)))
+/* We want an interface similar to make_string and build_string, right? */
+
+#define build_local_string(obj, data) \
+ make_local_string (obj, data, strlen (data))
+
+#else /* not USE_STACK_LISP_OBJECTS */
+
+#define scoped_cons(x, y) Fcons ((x), (y))
+#define scoped_list1(x) list1 (x)
+#define scoped_list2(x, y) list2 ((x), (y))
+#define scoped_list3(x, y, z) list3 ((x), (y), (z))
+#define build_local_vector(obj, size, init) \
+ (obj = Fmake_vector (make_number ((size), (init))))
+#define make_local_string(obj, data, nbytes) \
+ (obj = make_string ((data), (nbytes)))
+#define build_local_string(obj, data) (obj = build_string (data))
+
+#endif /* USE_STACK_LISP_OBJECTS */
+
/* Loop over all tails of a list, checking for cycles.
FIXME: Make tortoise and n internal declarations.
FIXME: Unroll the loop body so we don't need `n'. */