aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c44
1 files changed, 25 insertions, 19 deletions
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
3404void
3405make_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
3405DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, 3418DEFUN ("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))