diff options
| author | Zach Shaftel | 2020-06-12 17:01:00 -0400 |
|---|---|---|
| committer | Zach Shaftel | 2020-06-12 17:01:00 -0400 |
| commit | f6ec28d7974785b625e395d57cb18d1f2110fe4c (patch) | |
| tree | 9635b02347bf994a52aa98dd5c4445bd5e4fa1a2 /src/bytecode.c | |
| parent | 629d1790ede73d859c503354f2beb1316cf7df8f (diff) | |
| download | emacs-f6ec28d7974785b625e395d57cb18d1f2110fe4c.tar.gz emacs-f6ec28d7974785b625e395d57cb18d1f2110fe4c.zip | |
Store bytecode offset within exec_byte_code
* src/bytecode.c (exec_byte_code): Store offset in the backtrace frame
for the function being executed, before calling Ffuncall.
* src/eval.c (record_in_backtrace): Don't record the offset.
(backtrace_next, backtrace_top): Move declarations to lisp.h.
* src/lisp.h (backtrace_next, backtrace_top): Declare.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 6b7e9cbc7b9..f4900fc588f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -378,6 +378,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 378 | memcpy (bytestr_data, SDATA (bytestr), bytestr_length); | 378 | memcpy (bytestr_data, SDATA (bytestr), bytestr_length); |
| 379 | unsigned char const *pc = bytestr_data; | 379 | unsigned char const *pc = bytestr_data; |
| 380 | ptrdiff_t count = SPECPDL_INDEX (); | 380 | ptrdiff_t count = SPECPDL_INDEX (); |
| 381 | union specbinding *bt_frame = specpdl_ptr; | ||
| 382 | bt_frame = backtrace_next (bt_frame); | ||
| 381 | 383 | ||
| 382 | if (!NILP (args_template)) | 384 | if (!NILP (args_template)) |
| 383 | { | 385 | { |
| @@ -424,14 +426,16 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 424 | Threading provides a performance boost. These macros are how | 426 | Threading provides a performance boost. These macros are how |
| 425 | we allow the code to be compiled both ways. */ | 427 | we allow the code to be compiled both ways. */ |
| 426 | #ifdef BYTE_CODE_THREADED | 428 | #ifdef BYTE_CODE_THREADED |
| 427 | #define UPDATE_OFFSET (backtrace_byte_offset = pc - bytestr_data); | 429 | #define UPDATE_OFFSET(to) \ |
| 430 | if (bt_frame->kind == SPECPDL_BACKTRACE) \ | ||
| 431 | bt_frame->bt.bytecode_offset = (to); | ||
| 428 | /* The CASE macro introduces an instruction's body. It is | 432 | /* The CASE macro introduces an instruction's body. It is |
| 429 | either a label or a case label. */ | 433 | either a label or a case label. */ |
| 430 | #define CASE(OP) insn_ ## OP | 434 | #define CASE(OP) insn_ ## OP |
| 431 | /* NEXT is invoked at the end of an instruction to go to the | 435 | /* NEXT is invoked at the end of an instruction to go to the |
| 432 | next instruction. It is either a computed goto, or a | 436 | next instruction. It is either a computed goto, or a |
| 433 | plain break. */ | 437 | plain break. */ |
| 434 | #define NEXT UPDATE_OFFSET goto *(targets[op = FETCH]) | 438 | #define NEXT goto *(targets[op = FETCH]) |
| 435 | /* FIRST is like NEXT, but is only used at the start of the | 439 | /* FIRST is like NEXT, but is only used at the start of the |
| 436 | interpreter body. In the switch-based interpreter it is the | 440 | interpreter body. In the switch-based interpreter it is the |
| 437 | switch, so the threaded definition must include a semicolon. */ | 441 | switch, so the threaded definition must include a semicolon. */ |
| @@ -633,6 +637,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 633 | } | 637 | } |
| 634 | } | 638 | } |
| 635 | #endif | 639 | #endif |
| 640 | UPDATE_OFFSET(pc - bytestr_data); | ||
| 636 | TOP = Ffuncall (op + 1, &TOP); | 641 | TOP = Ffuncall (op + 1, &TOP); |
| 637 | NEXT; | 642 | NEXT; |
| 638 | } | 643 | } |
| @@ -1449,7 +1454,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 1449 | unbind_to (count, Qnil); | 1454 | unbind_to (count, Qnil); |
| 1450 | error ("binding stack not balanced (serious byte compiler bug)"); | 1455 | error ("binding stack not balanced (serious byte compiler bug)"); |
| 1451 | } | 1456 | } |
| 1452 | backtrace_byte_offset = -1; | 1457 | UPDATE_OFFSET(-1); |
| 1453 | Lisp_Object result = TOP; | 1458 | Lisp_Object result = TOP; |
| 1454 | SAFE_FREE (); | 1459 | SAFE_FREE (); |
| 1455 | return result; | 1460 | return result; |