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/thread.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/thread.h')
| -rw-r--r-- | src/thread.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/thread.h b/src/thread.h index f2755045b2e..a29af702d13 100644 --- a/src/thread.h +++ b/src/thread.h | |||
| @@ -33,6 +33,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 33 | #include "sysselect.h" /* FIXME */ | 33 | #include "sysselect.h" /* FIXME */ |
| 34 | #include "systhread.h" | 34 | #include "systhread.h" |
| 35 | 35 | ||
| 36 | /* Byte-code interpreter thread state. */ | ||
| 37 | struct bc_thread_state { | ||
| 38 | Lisp_Object *fp; /* current frame pointer (see bytecode.c) */ | ||
| 39 | Lisp_Object *stack; | ||
| 40 | Lisp_Object *stack_end; | ||
| 41 | }; | ||
| 42 | |||
| 36 | struct thread_state | 43 | struct thread_state |
| 37 | { | 44 | { |
| 38 | union vectorlike_header header; | 45 | union vectorlike_header header; |
| @@ -181,6 +188,8 @@ struct thread_state | |||
| 181 | 188 | ||
| 182 | /* Threads are kept on a linked list. */ | 189 | /* Threads are kept on a linked list. */ |
| 183 | struct thread_state *next_thread; | 190 | struct thread_state *next_thread; |
| 191 | |||
| 192 | struct bc_thread_state bc; | ||
| 184 | } GCALIGNED_STRUCT; | 193 | } GCALIGNED_STRUCT; |
| 185 | 194 | ||
| 186 | INLINE bool | 195 | INLINE bool |