[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/zach-soc-bytecode-in-traceback 0cb1df1 2/2: Store the bytecode o
From: |
Rocky Bernstein |
Subject: |
feature/zach-soc-bytecode-in-traceback 0cb1df1 2/2: Store the bytecode offset in thread_state |
Date: |
Fri, 26 Jun 2020 20:05:29 -0400 (EDT) |
branch: feature/zach-soc-bytecode-in-traceback
commit 0cb1df1edd86986d5d7a3ecf607fe78af03d62a0
Author: Zach Shaftel <zshaftel@gmail.com>
Commit: rocky <rocky@gnu.org>
Store the bytecode offset in thread_state
* 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.
---
src/bytecode.c | 7 +++++--
src/eval.c | 2 --
src/lisp.h | 1 -
src/thread.h | 5 +++++
4 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/bytecode.c b/src/bytecode.c
index 6b7e9cb..8e3cddf 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -311,6 +311,10 @@ enum byte_code_op
#define TOP (*top)
+/* Update the thread's bytecode offset, just before NEXT. */
+
+#define UPDATE_OFFSET (backtrace_byte_offset = pc - bytestr_data)
+
DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0,
doc: /* Function used internally in byte-compiled code.
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,
Threading provides a performance boost. These macros are how
we allow the code to be compiled both ways. */
#ifdef BYTE_CODE_THREADED
-#define UPDATE_OFFSET (backtrace_byte_offset = pc - bytestr_data);
/* The CASE macro introduces an instruction's body. It is
either a label or a case label. */
#define CASE(OP) insn_ ## OP
/* NEXT is invoked at the end of an instruction to go to the
next instruction. It is either a computed goto, or a
plain break. */
-#define NEXT UPDATE_OFFSET goto *(targets[op = FETCH])
+#define NEXT UPDATE_OFFSET; goto *(targets[op = FETCH])
/* FIRST is like NEXT, but is only used at the start of the
interpreter body. In the switch-based interpreter it is the
switch, so the threaded definition must include a semicolon. */
diff --git a/src/eval.c b/src/eval.c
index 5b43b81..73ad3d3 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -56,8 +56,6 @@ Lisp_Object Vrun_hooks;
/* FIXME: We should probably get rid of this! */
Lisp_Object Vsignaling_function;
-int backtrace_byte_offset = -1;
-
/* These would ordinarily be static, but they need to be visible to GDB. */
bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE;
diff --git a/src/lisp.h b/src/lisp.h
index ef6302a..f413d7a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4113,7 +4113,6 @@ extern Lisp_Object Vautoload_queue;
extern Lisp_Object Vrun_hooks;
extern Lisp_Object Vsignaling_function;
extern Lisp_Object inhibit_lisp_code;
-extern int backtrace_byte_offset;
/* To run a normal hook, use the appropriate function from the list below.
The calling convention:
diff --git a/src/thread.h b/src/thread.h
index a09929f..b5e3f0f 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -103,6 +103,11 @@ struct thread_state
union specbinding *m_specpdl_ptr;
#define specpdl_ptr (current_thread->m_specpdl_ptr)
+ /* The offset of the current op of the byte-code function being
+ executed. */
+ int m_backtrace_byte_offset;
+#define backtrace_byte_offset (current_thread->m_backtrace_byte_offset)
+
/* Depth in Lisp evaluations and function calls. */
intmax_t m_lisp_eval_depth;
#define lisp_eval_depth (current_thread->m_lisp_eval_depth)