]> git.eshelyaron.com Git - emacs.git/commitdiff
Cleanup last change and make all new stuff conditional.
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 9 Sep 2014 11:43:22 +0000 (15:43 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Tue, 9 Sep 2014 11:43:22 +0000 (15:43 +0400)
* 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.

src/ChangeLog
src/alloc.c
src/lisp.h

index d1e8314b172816cf01ba6c0d402a1ccb5a7f60c0..b94ac53051ab58c22917c0d94a4ec86b60d8d26a 100644 (file)
        * 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,
index 13043d6d9d7881dbde23276c3561cc6ae8d0d332..5c7ce31cad81d48b638d60b10e109b30ede3ef0f 100644 (file)
@@ -7118,6 +7118,10 @@ die (const char *msg, const char *file, int line)
   terminate_due_to_signal (SIGABRT, INT_MAX);
 }
 
+#endif /* ENABLE_CHECKING */
+
+#if defined (ENABLE_CHECKING) && defined (USE_STACK_LISP_OBJECTS)
+
 /* Stress alloca with inconveniently sized requests and check
    whether all allocated areas may be used for Lisp_Object.  */
 
@@ -7134,11 +7138,11 @@ verify_alloca (void)
     }
 }
 
-#else /* not ENABLE_CHECKING */
+#else /* not (ENABLE_CHECKING && USE_STACK_LISP_OBJECTS) */
 
 #define verify_alloca() ((void) 0)
 
-#endif /* ENABLE_CHECKING */
+#endif /* ENABLE_CHECKING && USE_STACK_LISP_OBJECTS */
 
 /* Initialization.  */
 
index a89e80729cd09497ce987f2450f666158e2a5317..cbb4c30bea11f188ce6614f862fcb2d1c4effe68 100644 (file)
@@ -4546,6 +4546,12 @@ extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
       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
@@ -4582,9 +4588,12 @@ scoped_cons_init (void *ptr, Lisp_Object x, Lisp_Object y)
 
 #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.  */
@@ -4622,7 +4631,7 @@ local_vector_init (uintptr_t addr, ptrdiff_t length, Lisp_Object init)
                 ((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)
@@ -4648,13 +4657,32 @@ 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'.  */