aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/alloc.c b/src/alloc.c
index ebc55857ea0..b7ebaa63a5b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3421,23 +3421,6 @@ usage: (vector &rest OBJECTS) */)
3421 return val; 3421 return val;
3422} 3422}
3423 3423
3424void
3425make_byte_code (struct Lisp_Vector *v)
3426{
3427 /* Don't allow the global zero_vector to become a byte code object. */
3428 eassert (0 < v->header.size);
3429
3430 if (v->header.size > 1 && STRINGP (v->contents[1])
3431 && STRING_MULTIBYTE (v->contents[1]))
3432 /* BYTECODE-STRING must have been produced by Emacs 20.2 or the
3433 earlier because they produced a raw 8-bit string for byte-code
3434 and now such a byte-code string is loaded as multibyte while
3435 raw 8-bit characters converted to multibyte form. Thus, now we
3436 must convert them back to the original unibyte form. */
3437 v->contents[1] = Fstring_as_unibyte (v->contents[1]);
3438 XSETPVECTYPE (v, PVEC_COMPILED);
3439}
3440
3441DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, 3424DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
3442 doc: /* Create a byte-code object with specified arguments as elements. 3425 doc: /* Create a byte-code object with specified arguments as elements.
3443The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant 3426The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant
@@ -3456,8 +3439,14 @@ stack before executing the byte-code.
3456usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) 3439usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */)
3457 (ptrdiff_t nargs, Lisp_Object *args) 3440 (ptrdiff_t nargs, Lisp_Object *args)
3458{ 3441{
3459 Lisp_Object val = make_uninit_vector (nargs); 3442 if (! ((FIXNUMP (args[COMPILED_ARGLIST])
3460 struct Lisp_Vector *p = XVECTOR (val); 3443 || CONSP (args[COMPILED_ARGLIST])
3444 || NILP (args[COMPILED_ARGLIST]))
3445 && STRINGP (args[COMPILED_BYTECODE])
3446 && !STRING_MULTIBYTE (args[COMPILED_BYTECODE])
3447 && VECTORP (args[COMPILED_CONSTANTS])
3448 && FIXNATP (args[COMPILED_STACK_DEPTH])))
3449 error ("Invalid byte-code object");
3461 3450
3462 /* We used to purecopy everything here, if purify-flag was set. This worked 3451 /* We used to purecopy everything here, if purify-flag was set. This worked
3463 OK for Emacs-23, but with Emacs-24's lexical binding code, it can be 3452 OK for Emacs-23, but with Emacs-24's lexical binding code, it can be
@@ -3466,10 +3455,8 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
3466 copied into pure space, including its free variables, which is sometimes 3455 copied into pure space, including its free variables, which is sometimes
3467 just wasteful and other times plainly wrong (e.g. those free vars may want 3456 just wasteful and other times plainly wrong (e.g. those free vars may want
3468 to be setcar'd). */ 3457 to be setcar'd). */
3469 3458 Lisp_Object val = Fvector (nargs, args);
3470 memcpy (p->contents, args, nargs * sizeof *args); 3459 XSETPVECTYPE (XVECTOR (val), PVEC_COMPILED);
3471 make_byte_code (p);
3472 XSETCOMPILED (val, p);
3473 return val; 3460 return val;
3474} 3461}
3475 3462