diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/lisp.h | 36 |
2 files changed, 17 insertions, 25 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b91221ef8f3..010f5fd95dd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | 2014-09-18 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2014-09-18 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Port USE_LOCAL_ALLOCATORS code to clang 3.4 x86-64. | 3 | Port USE_LOCAL_ALLOCATORS code to clang 3.4 x86-64. |
| 4 | * lisp.h (ALLOCA_FIXUP): New constant. | 4 | * lisp.h (USE_LOCAL_ALLOCATORS): Define only if __GNUC__ && |
| 5 | (LOCAL_ALLOCA): New macro. | 5 | !__clang__. This works with GCC and with clang and is safer for |
| 6 | (local_cons, make_local_vector, make_local_string): Use them. | 6 | compilers we don't know about. |
| 7 | (local_cons): Rename parameter to make capture less likely. | 7 | (local_cons): Rename parameter to make capture less likely. |
| 8 | 8 | ||
| 9 | 2014-09-17 Samuel Bronson <naesten@gmail.com> | 9 | 2014-09-17 Samuel Bronson <naesten@gmail.com> |
diff --git a/src/lisp.h b/src/lisp.h index 7a3e0d6a8a3..c5e698cc7c7 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4599,30 +4599,22 @@ verify (sizeof (struct Lisp_Cons) == sizeof (union Aligned_Cons)); | |||
| 4599 | # define scoped_list3(x, y, z) list3 (x, y, z) | 4599 | # define scoped_list3(x, y, z) list3 (x, y, z) |
| 4600 | #endif | 4600 | #endif |
| 4601 | 4601 | ||
| 4602 | #if USE_STACK_LISP_OBJECTS && HAVE_STATEMENT_EXPRESSIONS | 4602 | /* Local allocators require both statement expressions and a |
| 4603 | 4603 | GCALIGNMENT-aligned alloca. clang's alloca isn't properly aligned | |
| 4604 | in some cases. In the absence of solid information, play it safe | ||
| 4605 | for other non-GCC compilers. */ | ||
| 4606 | #if (USE_STACK_LISP_OBJECTS && HAVE_STATEMENT_EXPRESSIONS \ | ||
| 4607 | && __GNUC__ && !__clang__) | ||
| 4604 | # define USE_LOCAL_ALLOCATORS | 4608 | # define USE_LOCAL_ALLOCATORS |
| 4609 | #endif | ||
| 4605 | 4610 | ||
| 4606 | /* Alignment fixup needed for alloca. GCC aligns alloca properly already, | 4611 | #ifdef USE_LOCAL_ALLOCATORS |
| 4607 | Clang sometimes doesn't, and play it safe for other random compilers. */ | ||
| 4608 | # if __GNUC__ && !__clang__ | ||
| 4609 | enum { ALLOCA_FIXUP = 0 }; | ||
| 4610 | # else | ||
| 4611 | enum { ALLOCA_FIXUP = GCALIGNMENT - 1 }; | ||
| 4612 | # endif | ||
| 4613 | |||
| 4614 | /* Declare a void * variable PTR and set it to a properly-aligned array of | ||
| 4615 | N newly allocated bytes with function lifetime. */ | ||
| 4616 | # define LOCAL_ALLOCA(ptr, n) \ | ||
| 4617 | void *ptr = alloca ((n) + ALLOCA_FIXUP); \ | ||
| 4618 | ptr = (void *) ((intptr_t) ptr_ & ~(ALLOCA_FIXUP)) | ||
| 4619 | 4612 | ||
| 4620 | /* Return a function-scoped cons whose car is X and cdr is Y. */ | 4613 | /* Return a function-scoped cons whose car is X and cdr is Y. */ |
| 4621 | 4614 | ||
| 4622 | # define local_cons(x, y) \ | 4615 | # define local_cons(x, y) \ |
| 4623 | ({ \ | 4616 | ({ \ |
| 4624 | LOCAL_ALLOCA (ptr_, sizeof (struct Lisp_Cons)); \ | 4617 | struct Lisp_Cons *c_ = alloca (sizeof (struct Lisp_Cons)); \ |
| 4625 | struct Lisp_Cons *c_ = ptr_; \ | ||
| 4626 | c_->car = (x); \ | 4618 | c_->car = (x); \ |
| 4627 | c_->u.cdr = (y); \ | 4619 | c_->u.cdr = (y); \ |
| 4628 | make_lisp_ptr (c_, Lisp_Cons); \ | 4620 | make_lisp_ptr (c_, Lisp_Cons); \ |
| @@ -4640,9 +4632,9 @@ enum { ALLOCA_FIXUP = GCALIGNMENT - 1 }; | |||
| 4640 | ptrdiff_t size_ = size; \ | 4632 | ptrdiff_t size_ = size; \ |
| 4641 | Lisp_Object init_ = init; \ | 4633 | Lisp_Object init_ = init; \ |
| 4642 | Lisp_Object vec_; \ | 4634 | Lisp_Object vec_; \ |
| 4643 | if (size_ <= (MAX_ALLOCA - ALLOCA_FIXUP - header_size) / word_size) \ | 4635 | if (size_ <= (MAX_ALLOCA - header_size) / word_size) \ |
| 4644 | { \ | 4636 | { \ |
| 4645 | LOCAL_ALLOCA (ptr_, size_ * word_size + header_size); \ | 4637 | void *ptr_ = alloca (size_ * word_size + header_size); \ |
| 4646 | vec_ = local_vector_init (ptr_, size_, init_); \ | 4638 | vec_ = local_vector_init (ptr_, size_, init_); \ |
| 4647 | } \ | 4639 | } \ |
| 4648 | else \ | 4640 | else \ |
| @@ -4657,10 +4649,10 @@ enum { ALLOCA_FIXUP = GCALIGNMENT - 1 }; | |||
| 4657 | char const *data_ = data; \ | 4649 | char const *data_ = data; \ |
| 4658 | ptrdiff_t nbytes_ = nbytes; \ | 4650 | ptrdiff_t nbytes_ = nbytes; \ |
| 4659 | Lisp_Object string_; \ | 4651 | Lisp_Object string_; \ |
| 4660 | if (nbytes_ \ | 4652 | if (nbytes_ <= MAX_ALLOCA - sizeof (struct Lisp_String) - 1) \ |
| 4661 | <= MAX_ALLOCA - ALLOCA_FIXUP - sizeof (struct Lisp_String) - 1) \ | ||
| 4662 | { \ | 4653 | { \ |
| 4663 | LOCAL_ALLOCA (ptr_, sizeof (struct Lisp_String) + 1 + bytes_); \ | 4654 | struct Lisp_String *ptr_ \ |
| 4655 | = alloca (sizeof (struct Lisp_String) + 1 + nbytes_); \ | ||
| 4664 | string_ = local_string_init (ptr_, data_, nbytes_); \ | 4656 | string_ = local_string_init (ptr_, data_, nbytes_); \ |
| 4665 | } \ | 4657 | } \ |
| 4666 | else \ | 4658 | else \ |