aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-29 10:44:31 +0400
committerDmitry Antipov2014-09-29 10:44:31 +0400
commit71a72686e3e81253f2bc0ad74568aafdbd86879c (patch)
treee2f2d44e9a01c782e71e8de88e3b345733c86fc7 /src/alloc.c
parentc3301e3c7f146a3aa017fa24f6ed240d6ecbafb4 (diff)
downloademacs-71a72686e3e81253f2bc0ad74568aafdbd86879c.tar.gz
emacs-71a72686e3e81253f2bc0ad74568aafdbd86879c.zip
Keep stack-allocated Lisp objects fast rather than versatile.
* configure.ac (HAVE_STATEMENT_EXPRESSIONS): Remove. For USE_STACK_LISP_OBJECTS, we always assume __GNUC__. * lisp.h (union Aligned_Cons) [!GCALIGNED]: Define as such. (SCOPED_CONS_INITIALIZER): New macro. (scoped_cons) [USE_STACK_LISP_OBJECTS]: Use it. (USE_LOCAL_ALLOCA): Remove. (local_cons, local_list1, local_list2, local_list3, local_list4): Remove. Stack overflow checking makes them too slow. (make_local_vector): Likewise. Also we just don't have enough users for it. (enum LISP_STRING_OVERHEAD): Remove. (local_string_init, local_vector_init): Remove prototypes. (make_local_string, build_local_string): Redesign to target short compile-time string constants, fall back to regular string allocation where appropriate. (lisp_string_size): New function. (verify_ascii) [ENABLE_CHECKING]: Add prototype. * alloc.c (local_string_init, local_vector_init): Remove. (verify_ascii) [ENABLE_CHECKING]: New function. * buffer.c, charset.c, chartab.c, data.c, editfns.c, emacs.c, fileio.c: * fns.c, font.c, fontset.c, frame.c, keyboard.c, keymap.c, lread.c: * menu.c, minibuf.c, process.c, textprop.c, xdisp.c, xfns.c, xfont.c: * xselect.c, xterm.c: All related users changed.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c65
1 files changed, 18 insertions, 47 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 2dd5fae7d8e..93bdd9a2810 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -69,7 +69,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
69static bool valgrind_p; 69static bool valgrind_p;
70#endif 70#endif
71 71
72#ifdef USE_LOCAL_ALLOCATORS 72#if USE_STACK_LISP_OBJECTS
73# if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS 73# if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS
74# error "Stack-allocated Lisp objects are not compatible with GCPROs" 74# error "Stack-allocated Lisp objects are not compatible with GCPROs"
75# endif 75# endif
@@ -2232,33 +2232,6 @@ make_string (const char *contents, ptrdiff_t nbytes)
2232 return val; 2232 return val;
2233} 2233}
2234 2234
2235#ifdef USE_LOCAL_ALLOCATORS
2236
2237/* Initialize the string S from DATA and SIZE. S must be followed by
2238 SIZE + 1 bytes of memory that can be used. Return S tagged as a
2239 Lisp object. */
2240
2241Lisp_Object
2242local_string_init (struct Lisp_String *s, char const *data, ptrdiff_t size)
2243{
2244 unsigned char *data_copy = (unsigned char *) (s + 1);
2245 parse_str_as_multibyte ((unsigned char const *) data,
2246 size, &s->size, &s->size_byte);
2247 if (size == s->size || size != s->size_byte)
2248 {
2249 s->size = size;
2250 s->size_byte = -1;
2251 }
2252 s->intervals = NULL;
2253 s->data = data_copy;
2254 memcpy (data_copy, data, size);
2255 data_copy[size] = '\0';
2256 return make_lisp_ptr (s, Lisp_String);
2257}
2258
2259#endif
2260
2261
2262/* Make an unibyte string from LENGTH bytes at CONTENTS. */ 2235/* Make an unibyte string from LENGTH bytes at CONTENTS. */
2263 2236
2264Lisp_Object 2237Lisp_Object
@@ -3320,23 +3293,6 @@ See also the function `vector'. */)
3320 return vector; 3293 return vector;
3321} 3294}
3322 3295
3323#ifdef USE_LOCAL_ALLOCATORS
3324
3325/* Initialize V with LENGTH objects each with value INIT,
3326 and return it tagged as a Lisp Object. */
3327
3328Lisp_Object
3329local_vector_init (struct Lisp_Vector *v, ptrdiff_t length, Lisp_Object init)
3330{
3331 v->header.size = length;
3332 for (ptrdiff_t i = 0; i < length; i++)
3333 v->contents[i] = init;
3334 return make_lisp_ptr (v, Lisp_Vectorlike);
3335}
3336
3337#endif
3338
3339
3340DEFUN ("vector", Fvector, Svector, 0, MANY, 0, 3296DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
3341 doc: /* Return a newly created vector with specified arguments as elements. 3297 doc: /* Return a newly created vector with specified arguments as elements.
3342Any number of arguments, even zero arguments, are allowed. 3298Any number of arguments, even zero arguments, are allowed.
@@ -7157,7 +7113,22 @@ die (const char *msg, const char *file, int line)
7157 7113
7158#endif /* ENABLE_CHECKING */ 7114#endif /* ENABLE_CHECKING */
7159 7115
7160#if defined (ENABLE_CHECKING) && defined (USE_STACK_LISP_OBJECTS) 7116#if defined (ENABLE_CHECKING) && USE_STACK_LISP_OBJECTS
7117
7118/* Debugging check whether STR is ASCII-only. */
7119
7120const char *
7121verify_ascii (const char *str)
7122{
7123 const unsigned char *ptr = (unsigned char *) str, *end = ptr + strlen (str);
7124 while (ptr < end)
7125 {
7126 int c = STRING_CHAR_ADVANCE (ptr);
7127 if (!ASCII_CHAR_P (c))
7128 emacs_abort ();
7129 }
7130 return str;
7131}
7161 7132
7162/* Stress alloca with inconveniently sized requests and check 7133/* Stress alloca with inconveniently sized requests and check
7163 whether all allocated areas may be used for Lisp_Object. */ 7134 whether all allocated areas may be used for Lisp_Object. */
@@ -7175,7 +7146,7 @@ verify_alloca (void)
7175 } 7146 }
7176} 7147}
7177 7148
7178#else /* not (ENABLE_CHECKING && USE_STACK_LISP_OBJECTS) */ 7149#else /* not ENABLE_CHECKING && USE_STACK_LISP_OBJECTS */
7179 7150
7180#define verify_alloca() ((void) 0) 7151#define verify_alloca() ((void) 0)
7181 7152