diff options
| author | Zach Shaftel | 2020-06-19 14:53:20 -0400 |
|---|---|---|
| committer | rocky | 2020-06-26 20:05:16 -0400 |
| commit | 0cb1df1edd86986d5d7a3ecf607fe78af03d62a0 (patch) | |
| tree | 11a5664dfff6f9545481f30a8e5c46cfef1ff770 /src | |
| parent | 58e112fe18abe48321a9a9b676d76fdb68ee833a (diff) | |
| download | emacs-feature/zach-soc-bytecode-in-traceback.tar.gz emacs-feature/zach-soc-bytecode-in-traceback.zip | |
Store the bytecode offset in thread_statefeature/zach-soc-bytecode-in-traceback
* src/lisp.h:
* src/eval.c (backtrace_byte_offset): Remove global variable, and
put it...
* src/thread.h (thread_state): ...in here as
m_backtrace_byte_offset, and define backtrace_byte_offset as a
macro that points to it.
* src/bytecode.c (UPDATE_OFFSET): Move out of #ifdef
BYTE_CODE_THREADED.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bytecode.c | 7 | ||||
| -rw-r--r-- | src/eval.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/thread.h | 5 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 6b7e9cbc7b9..8e3cddf7851 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -311,6 +311,10 @@ enum byte_code_op | |||
| 311 | 311 | ||
| 312 | #define TOP (*top) | 312 | #define TOP (*top) |
| 313 | 313 | ||
| 314 | /* Update the thread's bytecode offset, just before NEXT. */ | ||
| 315 | |||
| 316 | #define UPDATE_OFFSET (backtrace_byte_offset = pc - bytestr_data) | ||
| 317 | |||
| 314 | DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, | 318 | DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, |
| 315 | doc: /* Function used internally in byte-compiled code. | 319 | doc: /* Function used internally in byte-compiled code. |
| 316 | The first argument, BYTESTR, is a string of byte code; | 320 | The first argument, BYTESTR, is a string of byte code; |
| @@ -424,14 +428,13 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 424 | Threading provides a performance boost. These macros are how | 428 | Threading provides a performance boost. These macros are how |
| 425 | we allow the code to be compiled both ways. */ | 429 | we allow the code to be compiled both ways. */ |
| 426 | #ifdef BYTE_CODE_THREADED | 430 | #ifdef BYTE_CODE_THREADED |
| 427 | #define UPDATE_OFFSET (backtrace_byte_offset = pc - bytestr_data); | ||
| 428 | /* The CASE macro introduces an instruction's body. It is | 431 | /* The CASE macro introduces an instruction's body. It is |
| 429 | either a label or a case label. */ | 432 | either a label or a case label. */ |
| 430 | #define CASE(OP) insn_ ## OP | 433 | #define CASE(OP) insn_ ## OP |
| 431 | /* NEXT is invoked at the end of an instruction to go to the | 434 | /* NEXT is invoked at the end of an instruction to go to the |
| 432 | next instruction. It is either a computed goto, or a | 435 | next instruction. It is either a computed goto, or a |
| 433 | plain break. */ | 436 | plain break. */ |
| 434 | #define NEXT UPDATE_OFFSET goto *(targets[op = FETCH]) | 437 | #define NEXT UPDATE_OFFSET; goto *(targets[op = FETCH]) |
| 435 | /* FIRST is like NEXT, but is only used at the start of the | 438 | /* FIRST is like NEXT, but is only used at the start of the |
| 436 | interpreter body. In the switch-based interpreter it is the | 439 | interpreter body. In the switch-based interpreter it is the |
| 437 | switch, so the threaded definition must include a semicolon. */ | 440 | switch, so the threaded definition must include a semicolon. */ |
diff --git a/src/eval.c b/src/eval.c index 5b43b81a6ca..73ad3d3bc90 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -56,8 +56,6 @@ Lisp_Object Vrun_hooks; | |||
| 56 | /* FIXME: We should probably get rid of this! */ | 56 | /* FIXME: We should probably get rid of this! */ |
| 57 | Lisp_Object Vsignaling_function; | 57 | Lisp_Object Vsignaling_function; |
| 58 | 58 | ||
| 59 | int backtrace_byte_offset = -1; | ||
| 60 | |||
| 61 | /* These would ordinarily be static, but they need to be visible to GDB. */ | 59 | /* These would ordinarily be static, but they need to be visible to GDB. */ |
| 62 | bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; | 60 | bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE; |
| 63 | Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; | 61 | Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE; |
diff --git a/src/lisp.h b/src/lisp.h index ef6302a4670..f413d7a45ec 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4113,7 +4113,6 @@ extern Lisp_Object Vautoload_queue; | |||
| 4113 | extern Lisp_Object Vrun_hooks; | 4113 | extern Lisp_Object Vrun_hooks; |
| 4114 | extern Lisp_Object Vsignaling_function; | 4114 | extern Lisp_Object Vsignaling_function; |
| 4115 | extern Lisp_Object inhibit_lisp_code; | 4115 | extern Lisp_Object inhibit_lisp_code; |
| 4116 | extern int backtrace_byte_offset; | ||
| 4117 | 4116 | ||
| 4118 | /* To run a normal hook, use the appropriate function from the list below. | 4117 | /* To run a normal hook, use the appropriate function from the list below. |
| 4119 | The calling convention: | 4118 | The calling convention: |
diff --git a/src/thread.h b/src/thread.h index a09929fa440..b5e3f0f9c51 100644 --- a/src/thread.h +++ b/src/thread.h | |||
| @@ -103,6 +103,11 @@ struct thread_state | |||
| 103 | union specbinding *m_specpdl_ptr; | 103 | union specbinding *m_specpdl_ptr; |
| 104 | #define specpdl_ptr (current_thread->m_specpdl_ptr) | 104 | #define specpdl_ptr (current_thread->m_specpdl_ptr) |
| 105 | 105 | ||
| 106 | /* The offset of the current op of the byte-code function being | ||
| 107 | executed. */ | ||
| 108 | int m_backtrace_byte_offset; | ||
| 109 | #define backtrace_byte_offset (current_thread->m_backtrace_byte_offset) | ||
| 110 | |||
| 106 | /* Depth in Lisp evaluations and function calls. */ | 111 | /* Depth in Lisp evaluations and function calls. */ |
| 107 | intmax_t m_lisp_eval_depth; | 112 | intmax_t m_lisp_eval_depth; |
| 108 | #define lisp_eval_depth (current_thread->m_lisp_eval_depth) | 113 | #define lisp_eval_depth (current_thread->m_lisp_eval_depth) |