diff options
| author | Tom Tromey | 2018-01-20 12:25:26 -0700 |
|---|---|---|
| committer | Tom Tromey | 2018-01-22 22:11:26 -0700 |
| commit | 916094a84f0ab31be31aa6c3632f14176b4e882a (patch) | |
| tree | 5d14b3b849b7b63f19577bd45bbbd85cdba0b702 /src/bytecode.c | |
| parent | a6b4b9b4af5405b62cbd59f5ce23ca0fe0027ac7 (diff) | |
| download | emacs-feature/byte-unwind-protect.tar.gz emacs-feature/byte-unwind-protect.zip | |
Add new bytecodes for unwind-protectfeature/byte-unwind-protect
* lisp/emacs-lisp/byte-opt.el (disassemble-offset): Handle
byte-pushunwindprotect.
* lisp/emacs-lisp/bytecomp.el (byte-pushunwindprotect)
(byte-endunwindprotect): New bytecodes.
(byte-goto-ops): Add byte-pushunwindprotect.
(byte-compile-unwind-protect): Emit new bytecodes.
(byte-compile-goto): Handle byte-pushunwindprotect.
* lisp/emacs-lisp/cconv.el (cconv-convert): Don't special-case
unwind-protect when byte-compile--use-old-handlers.
(cconv-analyze-form): Likewise.
* src/bytecode.c (Bpushunwindprotect, Bendunwindprotect): New bytecodes.
(exec_byte_code): Implement new bytecodes.
* test/src/bytecode-tests.el: New file.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 55b193ffb2f..62ba2ca69d0 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -132,6 +132,8 @@ DEFINE (Bunbind7, 057) \ | |||
| 132 | DEFINE (Bpophandler, 060) \ | 132 | DEFINE (Bpophandler, 060) \ |
| 133 | DEFINE (Bpushconditioncase, 061) \ | 133 | DEFINE (Bpushconditioncase, 061) \ |
| 134 | DEFINE (Bpushcatch, 062) \ | 134 | DEFINE (Bpushcatch, 062) \ |
| 135 | DEFINE (Bpushunwindprotect, 063) \ | ||
| 136 | DEFINE (Bendunwindprotect, 064) \ | ||
| 135 | \ | 137 | \ |
| 136 | DEFINE (Bnth, 070) \ | 138 | DEFINE (Bnth, 070) \ |
| 137 | DEFINE (Bsymbolp, 071) \ | 139 | DEFINE (Bsymbolp, 071) \ |
| @@ -770,6 +772,45 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 770 | NEXT; | 772 | NEXT; |
| 771 | } | 773 | } |
| 772 | 774 | ||
| 775 | CASE (Bpushunwindprotect): /* New in 27.1. */ | ||
| 776 | { | ||
| 777 | struct handler *c = push_handler (Qt, CATCHER_ALL); | ||
| 778 | c->bytecode_dest = FETCH2; | ||
| 779 | c->bytecode_top = top; | ||
| 780 | |||
| 781 | if (sys_setjmp (c->jmp)) | ||
| 782 | { | ||
| 783 | struct handler *c = handlerlist; | ||
| 784 | top = c->bytecode_top; | ||
| 785 | op = c->bytecode_dest; | ||
| 786 | handlerlist = c->next; | ||
| 787 | /* Push the exception value, plus a flag indicating | ||
| 788 | that re-throwing is necessary. This will be used | ||
| 789 | by Bendunwindprotect. */ | ||
| 790 | PUSH (c->val); | ||
| 791 | PUSH (Qt); | ||
| 792 | goto op_branch; | ||
| 793 | } | ||
| 794 | |||
| 795 | NEXT; | ||
| 796 | } | ||
| 797 | CASE (Bendunwindprotect): /* New in 27.1. */ | ||
| 798 | { | ||
| 799 | Lisp_Object flag = POP; | ||
| 800 | |||
| 801 | if (!NILP (flag)) | ||
| 802 | { | ||
| 803 | Lisp_Object err = POP; | ||
| 804 | |||
| 805 | if (EQ (XCAR (err), Qsignal)) | ||
| 806 | Fsignal (XCAR (XCDR (err)), XCDR (XCDR (err))); | ||
| 807 | else | ||
| 808 | Fthrow (XCAR (XCDR (err)), XCDR (XCDR (err))); | ||
| 809 | } | ||
| 810 | |||
| 811 | NEXT; | ||
| 812 | } | ||
| 813 | |||
| 773 | CASE (Bpushcatch): /* New in 24.4. */ | 814 | CASE (Bpushcatch): /* New in 24.4. */ |
| 774 | type = CATCHER; | 815 | type = CATCHER; |
| 775 | goto pushhandler; | 816 | goto pushhandler; |
| @@ -798,7 +839,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 798 | handlerlist = handlerlist->next; | 839 | handlerlist = handlerlist->next; |
| 799 | NEXT; | 840 | NEXT; |
| 800 | 841 | ||
| 801 | CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ | 842 | CASE (Bunwind_protect): /* Obsolete since 27.1. */ |
| 802 | { | 843 | { |
| 803 | Lisp_Object handler = POP; | 844 | Lisp_Object handler = POP; |
| 804 | /* Support for a function here is new in 24.4. */ | 845 | /* Support for a function here is new in 24.4. */ |