aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-03-13 17:26:05 +0100
committerMattias EngdegÄrd2022-03-13 17:51:49 +0100
commit3ed79cdbf21039fa209c421f746c0b49ec33f4da (patch)
treef6d3c5dbf4f1d5ea1a413c80293b1abc52571ff3 /src/eval.c
parent267f41c7ce1e02f392b57aa338d387e7627df184 (diff)
downloademacs-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/eval.c')
-rw-r--r--src/eval.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index b1c1a8c676b..c46b74ac40c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1233,6 +1233,7 @@ unwind_to_catch (struct handler *catch, enum nonlocal_exit type,
1233 eassert (handlerlist == catch); 1233 eassert (handlerlist == catch);
1234 1234
1235 lisp_eval_depth = catch->f_lisp_eval_depth; 1235 lisp_eval_depth = catch->f_lisp_eval_depth;
1236 set_act_rec (current_thread, catch->act_rec);
1236 1237
1237 sys_longjmp (catch->jmp, 1); 1238 sys_longjmp (catch->jmp, 1);
1238} 1239}
@@ -1673,6 +1674,7 @@ push_handler_nosignal (Lisp_Object tag_ch_val, enum handlertype handlertype)
1673 c->next = handlerlist; 1674 c->next = handlerlist;
1674 c->f_lisp_eval_depth = lisp_eval_depth; 1675 c->f_lisp_eval_depth = lisp_eval_depth;
1675 c->pdlcount = SPECPDL_INDEX (); 1676 c->pdlcount = SPECPDL_INDEX ();
1677 c->act_rec = get_act_rec (current_thread);
1676 c->poll_suppress_count = poll_suppress_count; 1678 c->poll_suppress_count = poll_suppress_count;
1677 c->interrupt_input_blocked = interrupt_input_blocked; 1679 c->interrupt_input_blocked = interrupt_input_blocked;
1678 handlerlist = c; 1680 handlerlist = c;