unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Paul Eggert <eggert@cs.ucla.edu>
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 09:21:48 -0400	[thread overview]
Message-ID: <jwvtxjlto3t.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <51EE4645.4000904@cs.ucla.edu> (Paul Eggert's message of "Tue, 23 Jul 2013 10:00:53 +0100")

> 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.

Why?

> 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.

Oh, man, that's even worse than I thought.  This is really bad, it means
that it suffers from the same kind of limitations as alloca, i.e. it is
tricky to use and coders need to be extra aware of it (e.g. common code
refactoring can be unsafe).

> 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

We've lived with it for what... almost 30 years?

> This would slow down execution very slightly, though.

As mentioned, the extra cases in unbind_to also cause a minor slowdown,
so I don't think this is a significant argument.

>> 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 problem is not the number of instructions but the time taken by each
instruction because correctly predicting indirect jumps is very
expensive and adding cases to the switch will increase the number
of mispredictions.


        Stefan



  reply	other threads:[~2013-07-23 13:21 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
2013-07-23 13:21     ` Stefan Monnier [this message]
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=jwvtxjlto3t.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /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).