diff options
| author | Stefan Monnier | 2012-06-11 11:13:27 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-06-11 11:13:27 -0400 |
| commit | 3017f87fbd0461b9460e7261a095fc86e166b30e (patch) | |
| tree | 602f00d509104a3ff9e6ee0808396dc50afc906f /src | |
| parent | 1b9b4cf4c1152f06153ac9c141fb9f724b984884 (diff) | |
| download | emacs-3017f87fbd0461b9460e7261a095fc86e166b30e.tar.gz emacs-3017f87fbd0461b9460e7261a095fc86e166b30e.zip | |
Don't purify in Fmake_byte_code.
* src/alloc.c (make_byte_code): New function.
(Fmake_byte_code): Use it. Don't purify here.
* src/lread.c (read1): Use it as well to avoid extra allocation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/alloc.c | 44 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/lread.c | 4 |
4 files changed, 34 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1aba1913f46..dc2e6845c50 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-06-11 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * alloc.c (make_byte_code): New function. | ||
| 4 | (Fmake_byte_code): Use it. Don't purify here. | ||
| 5 | * lread.c (read1): Use it as well to avoid extra allocation. | ||
| 6 | |||
| 1 | 2012-06-11 Chong Yidong <cyd@gnu.org> | 7 | 2012-06-11 Chong Yidong <cyd@gnu.org> |
| 2 | 8 | ||
| 3 | * image.c (imagemagick_load_image): Implement transparency. | 9 | * image.c (imagemagick_load_image): Implement transparency. |
diff --git a/src/alloc.c b/src/alloc.c index da2b7ac4330..7051af9b99c 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3401,6 +3401,19 @@ usage: (vector &rest OBJECTS) */) | |||
| 3401 | return val; | 3401 | return val; |
| 3402 | } | 3402 | } |
| 3403 | 3403 | ||
| 3404 | void | ||
| 3405 | make_byte_code (struct Lisp_Vector *v) | ||
| 3406 | { | ||
| 3407 | if (v->header.size > 1 && STRINGP (v->contents[1]) | ||
| 3408 | && STRING_MULTIBYTE (v->contents[1])) | ||
| 3409 | /* BYTECODE-STRING must have been produced by Emacs 20.2 or the | ||
| 3410 | earlier because they produced a raw 8-bit string for byte-code | ||
| 3411 | and now such a byte-code string is loaded as multibyte while | ||
| 3412 | raw 8-bit characters converted to multibyte form. Thus, now we | ||
| 3413 | must convert them back to the original unibyte form. */ | ||
| 3414 | v->contents[1] = Fstring_as_unibyte (v->contents[1]); | ||
| 3415 | XSETPVECTYPE (v, PVEC_COMPILED); | ||
| 3416 | } | ||
| 3404 | 3417 | ||
| 3405 | DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, | 3418 | DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, |
| 3406 | doc: /* Create a byte-code object with specified arguments as elements. | 3419 | doc: /* Create a byte-code object with specified arguments as elements. |
| @@ -3424,28 +3437,21 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT | |||
| 3424 | ptrdiff_t i; | 3437 | ptrdiff_t i; |
| 3425 | register struct Lisp_Vector *p; | 3438 | register struct Lisp_Vector *p; |
| 3426 | 3439 | ||
| 3427 | XSETFASTINT (len, nargs); | 3440 | /* We used to purecopy everything here, if purify-flga was set. This worked |
| 3428 | if (!NILP (Vpurify_flag)) | 3441 | OK for Emacs-23, but with Emacs-24's lexical binding code, it can be |
| 3429 | val = make_pure_vector (nargs); | 3442 | dangerous, since make-byte-code is used during execution to build |
| 3430 | else | 3443 | closures, so any closure built during the preload phase would end up |
| 3431 | val = Fmake_vector (len, Qnil); | 3444 | copied into pure space, including its free variables, which is sometimes |
| 3445 | just wasteful and other times plainly wrong (e.g. those free vars may want | ||
| 3446 | to be setcar'd). */ | ||
| 3432 | 3447 | ||
| 3433 | if (nargs > 1 && STRINGP (args[1]) && STRING_MULTIBYTE (args[1])) | 3448 | XSETFASTINT (len, nargs); |
| 3434 | /* BYTECODE-STRING must have been produced by Emacs 20.2 or the | 3449 | val = Fmake_vector (len, Qnil); |
| 3435 | earlier because they produced a raw 8-bit string for byte-code | ||
| 3436 | and now such a byte-code string is loaded as multibyte while | ||
| 3437 | raw 8-bit characters converted to multibyte form. Thus, now we | ||
| 3438 | must convert them back to the original unibyte form. */ | ||
| 3439 | args[1] = Fstring_as_unibyte (args[1]); | ||
| 3440 | 3450 | ||
| 3441 | p = XVECTOR (val); | 3451 | p = XVECTOR (val); |
| 3442 | for (i = 0; i < nargs; i++) | 3452 | for (i = 0; i < nargs; i++) |
| 3443 | { | 3453 | p->contents[i] = args[i]; |
| 3444 | if (!NILP (Vpurify_flag)) | 3454 | make_byte_code (p); |
| 3445 | args[i] = Fpurecopy (args[i]); | ||
| 3446 | p->contents[i] = args[i]; | ||
| 3447 | } | ||
| 3448 | XSETPVECTYPE (p, PVEC_COMPILED); | ||
| 3449 | XSETCOMPILED (val, p); | 3455 | XSETCOMPILED (val, p); |
| 3450 | return val; | 3456 | return val; |
| 3451 | } | 3457 | } |
| @@ -3470,7 +3476,7 @@ union aligned_Lisp_Symbol | |||
| 3470 | 3476 | ||
| 3471 | /* Each symbol_block is just under 1020 bytes long, since malloc | 3477 | /* Each symbol_block is just under 1020 bytes long, since malloc |
| 3472 | really allocates in units of powers of two and uses 4 bytes for its | 3478 | really allocates in units of powers of two and uses 4 bytes for its |
| 3473 | own overhead. */ | 3479 | own overhead. */ |
| 3474 | 3480 | ||
| 3475 | #define SYMBOL_BLOCK_SIZE \ | 3481 | #define SYMBOL_BLOCK_SIZE \ |
| 3476 | ((1020 - sizeof (struct symbol_block *)) / sizeof (union aligned_Lisp_Symbol)) | 3482 | ((1020 - sizeof (struct symbol_block *)) / sizeof (union aligned_Lisp_Symbol)) |
diff --git a/src/lisp.h b/src/lisp.h index acadcf50183..9e108d950d3 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2880,6 +2880,7 @@ extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, int); | |||
| 2880 | extern Lisp_Object make_pure_c_string (const char *data); | 2880 | extern Lisp_Object make_pure_c_string (const char *data); |
| 2881 | extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); | 2881 | extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); |
| 2882 | EXFUN (Fgarbage_collect, 0); | 2882 | EXFUN (Fgarbage_collect, 0); |
| 2883 | extern void make_byte_code (struct Lisp_Vector *); | ||
| 2883 | EXFUN (Fmake_byte_code, MANY); | 2884 | EXFUN (Fmake_byte_code, MANY); |
| 2884 | EXFUN (Fmake_bool_vector, 2); | 2885 | EXFUN (Fmake_bool_vector, 2); |
| 2885 | extern Lisp_Object Qchar_table_extra_slots; | 2886 | extern Lisp_Object Qchar_table_extra_slots; |
diff --git a/src/lread.c b/src/lread.c index 726f1f0e905..8a9088b8ed2 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2551,8 +2551,8 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) | |||
| 2551 | build them using function calls. */ | 2551 | build them using function calls. */ |
| 2552 | Lisp_Object tmp; | 2552 | Lisp_Object tmp; |
| 2553 | tmp = read_vector (readcharfun, 1); | 2553 | tmp = read_vector (readcharfun, 1); |
| 2554 | return Fmake_byte_code (ASIZE (tmp), | 2554 | make_byte_code (XVECTOR (tmp)); |
| 2555 | XVECTOR (tmp)->contents); | 2555 | return tmp; |
| 2556 | } | 2556 | } |
| 2557 | if (c == '(') | 2557 | if (c == '(') |
| 2558 | { | 2558 | { |