diff options
| author | Tom Tromey | 2013-03-08 11:57:29 -0700 |
|---|---|---|
| committer | Tom Tromey | 2013-03-08 11:57:29 -0700 |
| commit | 71f91792e3013b397996905224f387da5cc539a9 (patch) | |
| tree | 4c3d3ba909e76deea1cdf73b73fca67a57149465 /src/alloc.c | |
| parent | 6f4de085f065e11f4df3195d47479f28f5ef08ba (diff) | |
| parent | b5426561089d39f18b42bed9dbfcb531f43ed562 (diff) | |
| download | emacs-71f91792e3013b397996905224f387da5cc539a9.tar.gz emacs-71f91792e3013b397996905224f387da5cc539a9.zip | |
merge from trunk
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/src/alloc.c b/src/alloc.c index b7c17fbd6fb..63fd973ffce 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 26 | #include <limits.h> /* For CHAR_BIT. */ | 26 | #include <limits.h> /* For CHAR_BIT. */ |
| 27 | 27 | ||
| 28 | #ifdef ENABLE_CHECKING | 28 | #ifdef ENABLE_CHECKING |
| 29 | #include <signal.h> /* For SIGABRT. */ | 29 | #include <signal.h> /* For SIGABRT. */ |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #ifdef HAVE_PTHREAD | 32 | #ifdef HAVE_PTHREAD |
| @@ -836,7 +836,7 @@ void * | |||
| 836 | record_xmalloc (size_t size) | 836 | record_xmalloc (size_t size) |
| 837 | { | 837 | { |
| 838 | void *p = xmalloc (size); | 838 | void *p = xmalloc (size); |
| 839 | record_unwind_protect (safe_alloca_unwind, make_save_value (p, 0)); | 839 | record_unwind_protect (safe_alloca_unwind, make_save_pointer (p)); |
| 840 | return p; | 840 | return p; |
| 841 | } | 841 | } |
| 842 | 842 | ||
| @@ -1675,7 +1675,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 1675 | b = lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP); | 1675 | b = lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP); |
| 1676 | 1676 | ||
| 1677 | #ifdef DOUG_LEA_MALLOC | 1677 | #ifdef DOUG_LEA_MALLOC |
| 1678 | /* Back to a reasonable maximum of mmap'ed areas. */ | 1678 | /* Back to a reasonable maximum of mmap'ed areas. */ |
| 1679 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 1679 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
| 1680 | #endif | 1680 | #endif |
| 1681 | 1681 | ||
| @@ -1892,7 +1892,7 @@ compact_small_strings (void) | |||
| 1892 | 1892 | ||
| 1893 | #ifdef GC_CHECK_STRING_BYTES | 1893 | #ifdef GC_CHECK_STRING_BYTES |
| 1894 | /* Check that the string size recorded in the string is the | 1894 | /* Check that the string size recorded in the string is the |
| 1895 | same as the one recorded in the sdata structure. */ | 1895 | same as the one recorded in the sdata structure. */ |
| 1896 | if (s && string_bytes (s) != SDATA_NBYTES (from)) | 1896 | if (s && string_bytes (s) != SDATA_NBYTES (from)) |
| 1897 | emacs_abort (); | 1897 | emacs_abort (); |
| 1898 | #endif /* GC_CHECK_STRING_BYTES */ | 1898 | #endif /* GC_CHECK_STRING_BYTES */ |
| @@ -3103,13 +3103,10 @@ Any number of arguments, even zero arguments, are allowed. | |||
| 3103 | usage: (vector &rest OBJECTS) */) | 3103 | usage: (vector &rest OBJECTS) */) |
| 3104 | (ptrdiff_t nargs, Lisp_Object *args) | 3104 | (ptrdiff_t nargs, Lisp_Object *args) |
| 3105 | { | 3105 | { |
| 3106 | register Lisp_Object len, val; | ||
| 3107 | ptrdiff_t i; | 3106 | ptrdiff_t i; |
| 3108 | register struct Lisp_Vector *p; | 3107 | register Lisp_Object val = make_uninit_vector (nargs); |
| 3108 | register struct Lisp_Vector *p = XVECTOR (val); | ||
| 3109 | 3109 | ||
| 3110 | XSETFASTINT (len, nargs); | ||
| 3111 | val = Fmake_vector (len, Qnil); | ||
| 3112 | p = XVECTOR (val); | ||
| 3113 | for (i = 0; i < nargs; i++) | 3110 | for (i = 0; i < nargs; i++) |
| 3114 | p->contents[i] = args[i]; | 3111 | p->contents[i] = args[i]; |
| 3115 | return val; | 3112 | return val; |
| @@ -3147,9 +3144,9 @@ stack before executing the byte-code. | |||
| 3147 | usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) | 3144 | usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) |
| 3148 | (ptrdiff_t nargs, Lisp_Object *args) | 3145 | (ptrdiff_t nargs, Lisp_Object *args) |
| 3149 | { | 3146 | { |
| 3150 | register Lisp_Object len, val; | ||
| 3151 | ptrdiff_t i; | 3147 | ptrdiff_t i; |
| 3152 | register struct Lisp_Vector *p; | 3148 | register Lisp_Object val = make_uninit_vector (nargs); |
| 3149 | register struct Lisp_Vector *p = XVECTOR (val); | ||
| 3153 | 3150 | ||
| 3154 | /* We used to purecopy everything here, if purify-flag was set. This worked | 3151 | /* We used to purecopy everything here, if purify-flag was set. This worked |
| 3155 | OK for Emacs-23, but with Emacs-24's lexical binding code, it can be | 3152 | OK for Emacs-23, but with Emacs-24's lexical binding code, it can be |
| @@ -3159,10 +3156,6 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT | |||
| 3159 | just wasteful and other times plainly wrong (e.g. those free vars may want | 3156 | just wasteful and other times plainly wrong (e.g. those free vars may want |
| 3160 | to be setcar'd). */ | 3157 | to be setcar'd). */ |
| 3161 | 3158 | ||
| 3162 | XSETFASTINT (len, nargs); | ||
| 3163 | val = Fmake_vector (len, Qnil); | ||
| 3164 | |||
| 3165 | p = XVECTOR (val); | ||
| 3166 | for (i = 0; i < nargs; i++) | 3159 | for (i = 0; i < nargs; i++) |
| 3167 | p->contents[i] = args[i]; | 3160 | p->contents[i] = args[i]; |
| 3168 | make_byte_code (p); | 3161 | make_byte_code (p); |
| @@ -3354,7 +3347,7 @@ free_misc (Lisp_Object misc) | |||
| 3354 | and `o' for Lisp_Object. Up to 4 objects can be specified. */ | 3347 | and `o' for Lisp_Object. Up to 4 objects can be specified. */ |
| 3355 | 3348 | ||
| 3356 | Lisp_Object | 3349 | Lisp_Object |
| 3357 | format_save_value (const char *fmt, ...) | 3350 | make_save_value (const char *fmt, ...) |
| 3358 | { | 3351 | { |
| 3359 | va_list ap; | 3352 | va_list ap; |
| 3360 | int len = strlen (fmt); | 3353 | int len = strlen (fmt); |
| @@ -3402,15 +3395,19 @@ format_save_value (const char *fmt, ...) | |||
| 3402 | return val; | 3395 | return val; |
| 3403 | } | 3396 | } |
| 3404 | 3397 | ||
| 3405 | /* Return a Lisp_Save_Value object containing POINTER and INTEGER. | 3398 | /* The most common task it to save just one C pointer. */ |
| 3406 | Most code should use this to package C integers and pointers | ||
| 3407 | to call record_unwind_protect. The unwind function can get the | ||
| 3408 | C values back using XSAVE_POINTER and XSAVE_INTEGER. */ | ||
| 3409 | 3399 | ||
| 3410 | Lisp_Object | 3400 | Lisp_Object |
| 3411 | make_save_value (void *pointer, ptrdiff_t integer) | 3401 | make_save_pointer (void *pointer) |
| 3412 | { | 3402 | { |
| 3413 | return format_save_value ("pi", pointer, integer); | 3403 | Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); |
| 3404 | struct Lisp_Save_Value *p = XSAVE_VALUE (val); | ||
| 3405 | |||
| 3406 | p->area = 0; | ||
| 3407 | p->type0 = SAVE_POINTER; | ||
| 3408 | p->data[0].pointer = pointer; | ||
| 3409 | p->type1 = p->type2 = p->type3 = SAVE_UNUSED; | ||
| 3410 | return val; | ||
| 3414 | } | 3411 | } |
| 3415 | 3412 | ||
| 3416 | /* Free a Lisp_Save_Value object. Do not use this function | 3413 | /* Free a Lisp_Save_Value object. Do not use this function |
| @@ -6533,7 +6530,7 @@ die (const char *msg, const char *file, int line) | |||
| 6533 | } | 6530 | } |
| 6534 | #endif | 6531 | #endif |
| 6535 | 6532 | ||
| 6536 | /* Initialization */ | 6533 | /* Initialization. */ |
| 6537 | 6534 | ||
| 6538 | void | 6535 | void |
| 6539 | init_alloc_once (void) | 6536 | init_alloc_once (void) |
| @@ -6548,9 +6545,9 @@ init_alloc_once (void) | |||
| 6548 | #endif | 6545 | #endif |
| 6549 | 6546 | ||
| 6550 | #ifdef DOUG_LEA_MALLOC | 6547 | #ifdef DOUG_LEA_MALLOC |
| 6551 | mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */ | 6548 | mallopt (M_TRIM_THRESHOLD, 128 * 1024); /* Trim threshold. */ |
| 6552 | mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */ | 6549 | mallopt (M_MMAP_THRESHOLD, 64 * 1024); /* Mmap threshold. */ |
| 6553 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); /* max. number of mmap'ed areas */ | 6550 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); /* Max. number of mmap'ed areas. */ |
| 6554 | #endif | 6551 | #endif |
| 6555 | init_strings (); | 6552 | init_strings (); |
| 6556 | init_vectors (); | 6553 | init_vectors (); |