From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: please review new branch feature/byte-unwind-protect Date: Tue, 23 Jan 2018 11:37:10 -0500 Message-ID: References: <87inbtnobf.fsf@tromey.com> <87zi54ing6.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1516725390 18880 195.159.176.226 (23 Jan 2018 16:36:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 23 Jan 2018 16:36:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 23 17:36:26 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee1YO-0003eB-5e for ged-emacs-devel@m.gmane.org; Tue, 23 Jan 2018 17:36:08 +0100 Original-Received: from localhost ([::1]:39084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee1aO-0001lp-IK for ged-emacs-devel@m.gmane.org; Tue, 23 Jan 2018 11:38:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee1aD-0001kT-EN for emacs-devel@gnu.org; Tue, 23 Jan 2018 11:38:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ee1aA-0004EB-Ac for emacs-devel@gnu.org; Tue, 23 Jan 2018 11:38:01 -0500 Original-Received: from [195.159.176.226] (port=41445 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ee1aA-0004Df-3L for emacs-devel@gnu.org; Tue, 23 Jan 2018 11:37:58 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ee1Xh-0001Hz-0a for emacs-devel@gnu.org; Tue, 23 Jan 2018 17:35:25 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:0I1OodgCo9oDOdh+CNjt+nx/d/c= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:222172 Archived-At: > It's partly for efficiency -- I didn't benchmark it though. I'd be interested to see some benchmarks, as well (e.g. comparing old-unwind-protect vs new-unwind-protect vs prog1, where the prog1 case is used as the "speed of light" reference). > Also this seems like an un-finished to-do item from the lexical binding > conversion. Not exactly "unfinished", but yes, it's a good change. > I don't think there's a cost to this change. There's always costs: - fewer bytecodes left. - incompatility of .elc files. - potentially slower execution (hopefully it's the reverse, but without measuring it, it's difficult to be sure). - subtle changes (e.g. the debugger backtrace, or the behavior of called-interactively-p when called from within the 2nd part of an unwind-protect). >From where I stand I think they're worth the trouble, tho it depends on the benchmarks (I don't have a good intuition for the cost of setjmp, mostly, so while I think/hope that it will make things faster, I'm not completely sure). BTW, when I wrote those FIXME, the implementation strategy I was thinking of was: - use byte-codes with a similar semantics to the ones you introduce. - implement the pushunwindprotect by pushing onto the specpdl stack an entry that contains a reference to the bytecode stack and bytecode's pc (note: no setjmp). - when running the unwind_protect during a non-local exit (i.e. from unbind_to), run the byte-code interpreter using that saved stack and pc. Stefan