emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unwind-protect for lexical binding


From: Sergey Mozgovoy
Subject: unwind-protect for lexical binding
Date: Mon, 10 Mar 2014 20:42:59 -0700 (PDT)

I propose a patch for Emacs 24.3 that implements a new byte code for
unwind-protect which is more friendly for lexical scope.

100  lex-unwind-protect <address>   ------o
103  {protection body}                            |
...    .................                                   |
176  byte-return                                    |
177  {protected-form}        <------------------o
...    ..................
217  byte-unbind 1
...    ..................


This works as shown above: execution of `unwind-protect' starts with
retaining where the protection body is and jumping to the protected
form.  When unwinding, the remembered element is popped off the
specpdl stack, and a call into the necessary spot inside the bytecode
string is made.

I'll be very thankful to see any comments and thoughts on this idea.

Unfortunately, for this aproach to work I had to disable some
byte-level optimizations in `byte-opt.el' -- namely, the
`byte-after-unbind-ops' variable and the corresponding trick which
moves some bytecodes past an `unbind'.

Here's a list of patched files:

alloc.c.diff <http://emacs.1067599.n5.nabble.com/file/n316523/alloc.c.diff>  
bytecode.c.diff
<http://emacs.1067599.n5.nabble.com/file/n316523/bytecode.c.diff>  
lisp.h.diff <http://emacs.1067599.n5.nabble.com/file/n316523/lisp.h.diff>  
bytecomp.el.diff
<http://emacs.1067599.n5.nabble.com/file/n316523/bytecomp.el.diff>  
byte-opt.el.diff
<http://emacs.1067599.n5.nabble.com/file/n316523/byte-opt.el.diff>  
cconv.el.diff
<http://emacs.1067599.n5.nabble.com/file/n316523/cconv.el.diff>  

---
Best regards,
Sergey Mozgovoy.



--
View this message in context: 
http://emacs.1067599.n5.nabble.com/unwind-protect-for-lexical-binding-tp316523.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]