From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Hugo =?utf-8?Q?H=C3=B6rnquist?= Newsgroups: gmane.lisp.guile.devel Subject: Re: A different stack discipline Date: Sat, 3 Nov 2018 16:29:41 +0100 Message-ID: <20181102191524.GB947@STATENS_laptop> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: blaine.gmane.org 1541258872 7970 195.159.176.226 (3 Nov 2018 15:27:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2018 15:27:52 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Nov 03 16:27:48 2018 Return-path: Envelope-to: guile-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 1gIxpz-0001xJ-Ds for guile-devel@m.gmane.org; Sat, 03 Nov 2018 16:27:47 +0100 Original-Received: from localhost ([::1]:55957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIxs6-00035A-1B for guile-devel@m.gmane.org; Sat, 03 Nov 2018 11:29:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIxs2-000355-5a for guile-devel@gnu.org; Sat, 03 Nov 2018 11:29:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIxrx-0007k8-Bz for guile-devel@gnu.org; Sat, 03 Nov 2018 11:29:53 -0400 Original-Received: from mail.lysator.liu.se ([130.236.254.3]:56849) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gIxrw-0007ch-T7 for guile-devel@gnu.org; Sat, 03 Nov 2018 11:29:49 -0400 Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 8775840004 for ; Sat, 3 Nov 2018 16:29:44 +0100 (CET) Original-Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 69B4940026; Sat, 3 Nov 2018 16:29:44 +0100 (CET) Original-Received: from STATENS_laptop (h-109-128.A163.priv.bahnhof.se [94.254.109.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 687D940004; Sat, 3 Nov 2018 16:29:43 +0100 (CET) Content-Disposition: inline In-Reply-To: X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 130.236.254.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19713 Archived-At: 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