diff options
| author | Mattias EngdegÄrd | 2022-03-13 17:26:05 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-03-13 17:51:49 +0100 |
| commit | 3ed79cdbf21039fa209c421f746c0b49ec33f4da (patch) | |
| tree | f6d3c5dbf4f1d5ea1a413c80293b1abc52571ff3 /src/lisp.h | |
| parent | 267f41c7ce1e02f392b57aa338d387e7627df184 (diff) | |
| download | emacs-3ed79cdbf21039fa209c421f746c0b49ec33f4da.tar.gz emacs-3ed79cdbf21039fa209c421f746c0b49ec33f4da.zip | |
Separate bytecode stack
Use a dedicated stack for bytecode, instead of using the C stack.
Stack frames are managed explicitly and we stay in the same
exec_byte_code activation throughout bytecode function calls and
returns. In other words, exec_byte_code no longer uses recursion
for calling bytecode functions.
This results in better performance, and bytecode recursion is no
longer limited by the size of the C stack. The bytecode stack is
currently of fixed size but overflow is handled gracefully by
signalling a Lisp error instead of the hard crash that we get now.
In addition, GC marking of the stack is now faster and more precise.
Full precision could be attained if desired.
* src/alloc.c (ATTRIBUTE_NO_SANITIZE_ADDRESS): Make non-static.
* src/bytecode.c (enum stack_frame_index, BC_STACK_SIZE)
(sf_get_ptr, sf_set_ptr, sf_get_lisp_ptr, sf_set_lisp_ptr)
(sf_get_saved_pc, sf_set_saved_pc, init_bc_thread, free_bc_thread)
(mark_bytecode, Finternal_stack_stats, valid_sp): New.
(exec_byte_code): Adapt to use the new bytecode stack.
(syms_of_bytecode): Add defsubr.
* src/eval.c (unwind_to_catch): Restore saved stack frame.
(push_handler_nosignal): Save stack frame.
* src/lisp.h (struct handler): Add act_rec member.
(get_act_rec, set_act_rec): New.
* src/thread.c (mark_one_thread): Call mark_bytecode.
(finalize_one_thread): Free bytecode thread state.
(Fmake_thread, init_threads): Set up bytecode thread state.
* src/thread.h (struct bc_thread_state): New.
(struct thread_state): Add bytecode thread state.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index 5e3590675d1..8053bbc9777 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3546,6 +3546,7 @@ struct handler | |||
| 3546 | sys_jmp_buf jmp; | 3546 | sys_jmp_buf jmp; |
| 3547 | EMACS_INT f_lisp_eval_depth; | 3547 | EMACS_INT f_lisp_eval_depth; |
| 3548 | specpdl_ref pdlcount; | 3548 | specpdl_ref pdlcount; |
| 3549 | Lisp_Object *act_rec; | ||
| 3549 | int poll_suppress_count; | 3550 | int poll_suppress_count; |
| 3550 | int interrupt_input_blocked; | 3551 | int interrupt_input_blocked; |
| 3551 | }; | 3552 | }; |
| @@ -4087,6 +4088,7 @@ extern void alloc_unexec_pre (void); | |||
| 4087 | extern void alloc_unexec_post (void); | 4088 | extern void alloc_unexec_post (void); |
| 4088 | extern void mark_stack (char const *, char const *); | 4089 | extern void mark_stack (char const *, char const *); |
| 4089 | extern void flush_stack_call_func1 (void (*func) (void *arg), void *arg); | 4090 | extern void flush_stack_call_func1 (void (*func) (void *arg), void *arg); |
| 4091 | extern void mark_memory (void const *start, void const *end); | ||
| 4090 | 4092 | ||
| 4091 | /* Force callee-saved registers and register windows onto the stack, | 4093 | /* Force callee-saved registers and register windows onto the stack, |
| 4092 | so that conservative garbage collection can see their values. */ | 4094 | so that conservative garbage collection can see their values. */ |
| @@ -4855,6 +4857,21 @@ extern void syms_of_bytecode (void); | |||
| 4855 | extern Lisp_Object exec_byte_code (Lisp_Object, ptrdiff_t, | 4857 | extern Lisp_Object exec_byte_code (Lisp_Object, ptrdiff_t, |
| 4856 | ptrdiff_t, Lisp_Object *); | 4858 | ptrdiff_t, Lisp_Object *); |
| 4857 | extern Lisp_Object get_byte_code_arity (Lisp_Object); | 4859 | extern Lisp_Object get_byte_code_arity (Lisp_Object); |
| 4860 | extern void init_bc_thread (struct bc_thread_state *bc); | ||
| 4861 | extern void free_bc_thread (struct bc_thread_state *bc); | ||
| 4862 | extern void mark_bytecode (struct bc_thread_state *bc); | ||
| 4863 | |||
| 4864 | INLINE Lisp_Object * | ||
| 4865 | get_act_rec (struct thread_state *th) | ||
| 4866 | { | ||
| 4867 | return th->bc.fp; | ||
| 4868 | } | ||
| 4869 | |||
| 4870 | INLINE void | ||
| 4871 | set_act_rec (struct thread_state *th, Lisp_Object *act_rec) | ||
| 4872 | { | ||
| 4873 | th->bc.fp = act_rec; | ||
| 4874 | } | ||
| 4858 | 4875 | ||
| 4859 | /* Defined in macros.c. */ | 4876 | /* Defined in macros.c. */ |
| 4860 | extern void init_macros (void); | 4877 | extern void init_macros (void); |