unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Davis Herring" <herring@lanl.gov>
To: "Alin Soare" <as1789@gmail.com>
Cc: Emacs Dev <emacs-devel@gnu.org>
Subject: Re: please help concerning specpdl
Date: Mon, 6 Dec 2010 08:22:30 -0800 (PST)	[thread overview]
Message-ID: <35942.130.55.118.19.1291652550.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <AANLkTim-O08+aton9kyOjf-EBfPUhL494rra5CaB7BzU@mail.gmail.com>

> count = SPECPDL_INDEX ();
> record_unwind_protect
> val = Fprogn (args);
> return unbind_to (count, val);

> Can you explain me the logic of specpdl please ?

The specpdl contains information needed to remove variable bindings and
provide other services that are guaranteed even in the case of abnormal
exit.  Abnormal exits operate by calling longjmp(3), so there's no
guaranteed chance to perform cleanup in the normal flow of execution.  But
the function that calls longjmp(3) (`unwind_to_catch') first peruses the
specpdl and handles its elements appropriately, so the guaranteed
operations happen.  The actual unwinding is done by `unbind_to', so if the
body exits normally, we just call that to perform the unwinding operations
without longjmp(3).

So: the count identifies how far to unwind in case of normal exit (in case
of abnormal exit, we'll unwind farther anyway, so we don't need `count'). 
The `record_unwind_protect' registers something to do at unwind-time, and
then `unbind_to' performs it unless `unwind_to_catch' does.  `val' is
passed to `unbind_to' for GC reasons, I believe.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.



  reply	other threads:[~2010-12-06 16:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04  5:33 please help concerning specpdl Alin Soare
2010-12-06 16:22 ` Davis Herring [this message]
2010-12-14 21:25   ` Alin Soare
2010-12-15  0:14     ` Davis Herring
2010-12-15  0:53       ` Ken Raeburn

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=35942.130.55.118.19.1291652550.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=as1789@gmail.com \
    --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).