unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r113437: New unwind-protect flavors to better type-check C callbacks.
Date: Tue, 23 Jul 2013 10:00:53 +0100	[thread overview]
Message-ID: <51EE4645.4000904@cs.ucla.edu> (raw)
In-Reply-To: <jwv8v0z44mi.fsf-monnier+emacs@gnu.org>

On 07/22/2013 05:13 AM, Stefan Monnier wrote:
> I much preferred having a single record_unwind.

The old way was simpler, but it had a problem:
record_unbind_protect (foo, make_save_value (...))  didn't
work when make_save_value exhausted memory and threw an
error.  To avoid the problem, there needs to be a way to
invoke record_unwind_protect without the possibility of
throwing an error before the protection is in place.

record_unwind_protect_ptr does that, since the caller
already can have a local variable in the C stack, and pass
its address.  This works because every function that calls
record_unwind_protect_ptr also calls unbind_to to undo it,
before returning.

It wouldn't be feasible to convert all uses of
record_unwind_protect to record_unwind_protect_ptr, because
not every function that calls record_unbind_protect also
calls unbind_to.

Removing record_unwind_protect_int would not be trivial,
since one can't simply replace it with record_unwind_protect
+ make_integer (as not all 'int' values fit into Lisp
integers), and one can't simply replace it by passing an int
* to record_unwind_protect_ptr (as not all functions that
invoke record_unwind_protect_int also call unbind_to).

We could trivially remove record_unwind_protect_void by
using one of the other methods and passing a dummy argument.
This would slow down execution very slightly, though.  Plus,
an advantage of having record_unwind_protect_void and
record_unwind_protect_int is it catches more type errors at
the C level.

> No strong technical arguments for it (other than the fact that the
> added SPECPDL_UNWIND_* cases in the switch slow down `unbind').

It shouldn't slow down 'unbind', at least on my x86-64
platform, since the switch is implemented as an indirect
jump, which means that adding cases doesn't add any
instructions for the existing cases.  The new code should
even speed up 'unbind' a tad, at least for the void case,
since it can avoid passing an argument that the unwinder
doesn't look at.




  reply	other threads:[~2013-07-23  9:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1UzCuc-0001NQ-T1@vcs.savannah.gnu.org>
2013-07-22  4:13 ` [Emacs-diffs] trunk r113437: New unwind-protect flavors to better type-check C callbacks Stefan Monnier
2013-07-23  9:00   ` Paul Eggert [this message]
2013-07-23 13:21     ` Stefan Monnier
2013-07-24  7:23       ` Paul Eggert
2013-07-24 14:08         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51EE4645.4000904@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).