aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/alloc.c b/src/alloc.c
index d6ba4d97905..76d49d2efd6 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3429,23 +3429,6 @@ usage: (vector &rest OBJECTS) */)
3429 return val; 3429 return val;
3430} 3430}
3431 3431
3432void
3433make_byte_code (struct Lisp_Vector *v)
3434{
3435 /* Don't allow the global zero_vector to become a byte code object. */
3436 eassert (0 < v->header.size);
3437
3438 if (v->header.size > 1 && STRINGP (v->contents[1])
3439 && STRING_MULTIBYTE (v->contents[1]))
3440 /* BYTECODE-STRING must have been produced by Emacs 20.2 or the
3441 earlier because they produced a raw 8-bit string for byte-code
3442 and now such a byte-code string is loaded as multibyte while
3443 raw 8-bit characters converted to multibyte form. Thus, now we
3444 must convert them back to the original unibyte form. */
3445 v->contents[1] = Fstring_as_unibyte (v->contents[1]);
3446 XSETPVECTYPE (v, PVEC_COMPILED);
3447}
3448
3449DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, 3432DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
3450 doc: /* Create a byte-code object with specified arguments as elements. 3433 doc: /* Create a byte-code object with specified arguments as elements.
3451The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant 3434The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant
@@ -3464,8 +3447,14 @@ stack before executing the byte-code.
3464usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) 3447usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */)
3465 (ptrdiff_t nargs, Lisp_Object *args) 3448 (ptrdiff_t nargs, Lisp_Object *args)
3466{ 3449{
3467 Lisp_Object val = make_uninit_vector (nargs); 3450 if (! ((FIXNUMP (args[COMPILED_ARGLIST])
3468 struct Lisp_Vector *p = XVECTOR (val); 3451 || CONSP (args[COMPILED_ARGLIST])
3452 || NILP (args[COMPILED_ARGLIST]))
3453 && STRINGP (args[COMPILED_BYTECODE])
3454 && !STRING_MULTIBYTE (args[COMPILED_BYTECODE])
3455 && VECTORP (args[COMPILED_CONSTANTS])
3456 && FIXNATP (args[COMPILED_STACK_DEPTH])))
3457 error ("Invalid byte-code object");
3469 3458
3470 /* We used to purecopy everything here, if purify-flag was set. This worked 3459 /* We used to purecopy everything here, if purify-flag was set. This worked
3471 OK for Emacs-23, but with Emacs-24's lexical binding code, it can be 3460 OK for Emacs-23, but with Emacs-24's lexical binding code, it can be
@@ -3474,10 +3463,8 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
3474 copied into pure space, including its free variables, which is sometimes 3463 copied into pure space, including its free variables, which is sometimes
3475 just wasteful and other times plainly wrong (e.g. those free vars may want 3464 just wasteful and other times plainly wrong (e.g. those free vars may want
3476 to be setcar'd). */ 3465 to be setcar'd). */
3477 3466 Lisp_Object val = Fvector (nargs, args);
3478 memcpy (p->contents, args, nargs * sizeof *args); 3467 XSETPVECTYPE (XVECTOR (val), PVEC_COMPILED);
3479 make_byte_code (p);
3480 XSETCOMPILED (val, p);
3481 return val; 3468 return val;
3482} 3469}
3483 3470
@@ -5019,8 +5006,9 @@ mark_stack (char const *bottom, char const *end)
5019#endif 5006#endif
5020} 5007}
5021 5008
5022/* This is a trampoline function that flushes registers to the stack, 5009/* flush_stack_call_func is the trampoline function that flushes
5023 and then calls FUNC. ARG is passed through to FUNC verbatim. 5010 registers to the stack, and then calls FUNC. ARG is passed through
5011 to FUNC verbatim.
5024 5012
5025 This function must be called whenever Emacs is about to release the 5013 This function must be called whenever Emacs is about to release the
5026 global interpreter lock. This lets the garbage collector easily 5014 global interpreter lock. This lets the garbage collector easily
@@ -5028,7 +5016,20 @@ mark_stack (char const *bottom, char const *end)
5028 Lisp. 5016 Lisp.
5029 5017
5030 It is invalid to run any Lisp code or to allocate any GC memory 5018 It is invalid to run any Lisp code or to allocate any GC memory
5031 from FUNC. */ 5019 from FUNC.
5020
5021 Note: all register spilling is done in flush_stack_call_func before
5022 flush_stack_call_func1 is activated.
5023
5024 flush_stack_call_func1 is responsible for identifying the stack
5025 address range to be scanned. It *must* be carefully kept as
5026 noinline to make sure that registers has been spilled before it is
5027 called, otherwise given __builtin_frame_address (0) typically
5028 returns the frame pointer (base pointer) and not the stack pointer
5029 [1] GC will miss to scan callee-saved registers content
5030 (Bug#41357).
5031
5032 [1] <https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html>. */
5032 5033
5033NO_INLINE void 5034NO_INLINE void
5034flush_stack_call_func1 (void (*func) (void *arg), void *arg) 5035flush_stack_call_func1 (void (*func) (void *arg), void *arg)