[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: native code

From: Matt Wette
Subject: Re: native code
Date: Wed, 22 Feb 2017 13:44:26 -0800

On Feb 22, 2017, at 12:03 PM, Stefan Israelsson Tampe <address@hidden> wrote:
With this we should be able to actually compile guile scheme via the vm ops to C and then gcc to position independent machine code. The main obstacles to use this is that a) C calls are not tail calls and b) it is difficult to manage the stack as we do in guile and have native code interoperate with vm code.

In your dev process are you looking at intermediate stages of .c -> .o to see if gcc is generating tail-calls?  I’m guessing it will (w/ -O2) in many cases.

mwette$ cat sum.c
#include <stdio.h>

int sum(int total, int top) {
  if (top == 1) return total+top;
  else sum(total+top, top-1);

int main() { printf("%d\n", sum(0, 5)); }

mwette$ cat sum.s. # where gcc -O2 [-S] produces tail call in sum()
jmp L10
.align 4,0x90
addl %esi, %edi
subl $1, %esi
cmpl $1, %esi
jne L7
leal 1(%rdi), %eax


reply via email to

[Prev in Thread] Current Thread [Next in Thread]