unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Hugo Hörnquist" <hugo@lysator.liu.se>
To: guile-devel@gnu.org
Subject: Re: A different stack discipline
Date: Sat, 3 Nov 2018 16:29:41 +0100	[thread overview]
Message-ID: <20181102191524.GB947@STATENS_laptop> (raw)
In-Reply-To: <CAA2XvwKtY6de9fzF7WXx=sZSMEg6Ja-yit_qh5rRx=TyNrF5Hg@mail.gmail.com>

The section, as far as I can see, just describes a machine
which pushes continuation instead of the PC counter to the
stack.

Also, while in theory quite nice it has the problem that
Guile is really slow in restoring continuations, due to the
fact that we have complete C interoperability.

On Wed, Oct 31, 2018 at 09:55:06PM +0100, Mikael Djurfeldt wrote:
> I've looked a little at the Guile vm and compiler.
> 
> What a beautiful work! It also has very nicely written documentation. Very
> impressive!
> 
> Here's an idea/question:
> 
> SICP describes a register machine with a stack discipline which is
> different from most machine models in that it doesn't have a call
> instruction which pushes the PC onto the stack and a return instruction
> which pops it. Instead it has a continue register: When calling a
> subroutine, you load the continue register with the continuation of the
> subroutine (as described here:
> https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-31.html#%_sec_5.1.4
> ). A subroutine ends with a branch to its continuation (stored in the
> continue register).
> 
> It seems to me that this 1. is natural to scheme since tail recursion
> doesn't need to be handled differently than ordinary calls, 2. that it fits
> the Guile compiler nicely with its CPS soup and 3. that it possibly could
> save vm instructions and stack space.
> 
> Could it be a good idea to switch over to the SICP stack discipline in the
> vm?
> 
> Best regards,
> Mikael D.

-- 
hugo



  reply	other threads:[~2018-11-03 15:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 20:55 A different stack discipline Mikael Djurfeldt
2018-11-03 15:29 ` Hugo Hörnquist [this message]
2018-11-03 18:16   ` Mikael Djurfeldt
2018-11-03 18:49     ` Mikael Djurfeldt

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/guile/

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

  git send-email \
    --in-reply-to=20181102191524.GB947@STATENS_laptop \
    --to=hugo@lysator.liu.se \
    --cc=guile-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.
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).