From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel Subject: A different stack discipline Date: Wed, 31 Oct 2018 21:55:06 +0100 Message-ID: Reply-To: mikael@djurfeldt.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000017ab1e05798c8516" X-Trace: blaine.gmane.org 1541019223 12885 195.159.176.226 (31 Oct 2018 20:53:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Oct 2018 20:53:43 +0000 (UTC) To: Andy Wingo , guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Oct 31 21:53:38 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 1gHxUf-0003Fu-LV for guile-devel@m.gmane.org; Wed, 31 Oct 2018 21:53:37 +0100 Original-Received: from localhost ([::1]:33490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHxWl-0001xL-Si for guile-devel@m.gmane.org; Wed, 31 Oct 2018 16:55:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHxWh-0001xG-Tn for guile-devel@gnu.org; Wed, 31 Oct 2018 16:55:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHxWa-0006Mg-E5 for guile-devel@gnu.org; Wed, 31 Oct 2018 16:55:42 -0400 Original-Received: from mail-it1-f175.google.com ([209.85.166.175]:54845) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHxWP-0006CK-1M for guile-devel@gnu.org; Wed, 31 Oct 2018 16:55:28 -0400 Original-Received: by mail-it1-f175.google.com with SMTP id d6so14761558itl.4 for ; Wed, 31 Oct 2018 13:55:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:from:date:message-id :subject:to:cc; bh=TajxDM/ewFnbpR4dYOulP/vqtCvpOKYjdohsyQvlTxU=; b=mo0K4+05c1fwO7x7pa4UXX1gbMI8mPF4Wb9lYlgsm54MX48gdEV9ovE7FaNTLcRJeO 99sQmgbPLk4hz49wGXjF1NRN75LOfQ0U8yVl+tg1FXzDIhTzEoaSDZTz6b5ZzOmMACoL EJaigdHBoIzH0MLJ+05zVSOMhC02qDHGxaRn5kLh0D9fv537jBfp5aTubO927bqGu/N1 rP1VOQ4qOsIChn/ggw7wW534haDQ/gTp/Pd91OYq+9PWiwgtY0xDI2BN++gANfKYrDt5 I8+qEnM3oE90A+8QeSWtp/N2TVThxsEQxAqJkH68z9lJlBwpzidK5yctbbfCMKto5dEy LQVQ== X-Gm-Message-State: AGRZ1gK6aU2AjZMJ3THo2xaVE9pdSdzbTOOmy+AhlQnuJktxj9hQpfOJ JA7LRLSm9oJCobIYqacSZYWDlGX/WlRlYGXlPS0= X-Google-Smtp-Source: AJdET5cpB1fGytC+tuLa86/gh7BoIVoDGYJ/drmhMLuTSGBGQ5yPRz0BxmL8mKFD/RV3zfRO7HTnEDjW+Z+6K5lsPmM= X-Received: by 2002:a05:660c:687:: with SMTP id n7mr3204001itk.59.1541019318852; Wed, 31 Oct 2018 13:55:18 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.166.175 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:19710 Archived-At: --00000000000017ab1e05798c8516 Content-Type: text/plain; charset="UTF-8" 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. --00000000000017ab1e05798c8516 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've looked a little at the Guil= e 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 mac= hine 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 regist= er with the continuation of the subroutine (as described here: https://mitpress.mit.edu/sites/default/files/sicp/full-t= ext/book/book-Z-H-31.html#%_sec_5.1.4 ). A subroutine ends with a branc= h to its continuation (stored in the continue register).

It seems to me that this 1. is natural to scheme since tail recursio= n doesn't need to be handled differently than ordinary calls, 2. that i= t 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.

--00000000000017ab1e05798c8516--