unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: guile-devel@gnu.org
Subject: Re: The progress of hacking guile and prolog
Date: Fri, 5 Nov 2010 22:19:54 +0100	[thread overview]
Message-ID: <201011052219.54556.stefan.itampe@gmail.com> (raw)
In-Reply-To: <87bp66q8g5.fsf@gnu.org>

[-- Attachment #1: Type: Text/Plain, Size: 2387 bytes --]

Ok, for the c generator, here are some code attached. I would 
just study this there is bit's still missing and you need to wait for me to
dig up the details. My point is to suggest  ideas for what can be done. 
I don't assume that this is it. But it's a nice playing ground.

So it is a hack, here is what I do.

(use modules (language glil compile-assembly))
(set! *compile-to-c* #t)
(define (f N) 
	(set! <c-dummy> '<c-code-tag>)   ;; This tagg!! initiate the compiler 
	                                 ;; and c-fkn will use the
                 		         ;; <c-code-tag> slot :-)
 
	(let loop ((I N) (X 0)) 
	(if (eq? I 0) 
	X  (loop 
	(- I 1) (+ X 1)))))
(generate-c-fkns "fkn")

Then in a sub-directory called cboost from the starting directory you find
fkn.c and a makefile. e.g.

Makefile:
=========
libguile-fkn.so : fkn.c
	gcc -shared -O2 -o libguile-fkn.so -fPIC fkn.c

fkn.c:
======
#include "cfkn.h"
#define LOCAL_REF(i)     fp[i]
#define LOCAL_SET(i,v)   fp[i] = (v)
void cfkn3676(SCM *fp, SCM **spp)
{
 /* setup of environment */
 SCM *objects, *free, program, *sp, sss[100];
 sp = sss;
 program = fp[-1];
 objects = SCM_I_VECTOR_WELTS (SCM_PROGRAM_OBJTABLE (program));    
 free    = SCM_PROGRAM_FREE_VARIABLES(program);
 /* compiled section */
 LCASE3666:


goto L3668;
LCASE3665:
sp++; *sp = LOCAL_REF(1);
sp++; *sp = SCM_I_MAKINUM(0);
sp-=2; if(!scm_is_eq(sp[1],sp[2])) goto L3669;
sp++; *sp = LOCAL_REF(2);
RETURN;
L3669:
sp++; *sp = LOCAL_REF(1);
SUB1;
sp++; *sp = LOCAL_REF(2);
ADD1;
LOCAL_SET(2,*sp)              ; sp--;
LOCAL_SET(1,*sp)              ; sp--;
goto LCASE3665;
L3668:
sp++; *sp = LOCAL_REF(0);
sp++; *sp = SCM_I_MAKINUM(0);
LOCAL_SET(2,*sp)              ; sp--;
LOCAL_SET(1,*sp)              ; sp--;
goto LCASE3665;

}

void init_fkn.c()
{
   SCM cfkn3676_sym;
   

   cfkn3676_sym = scm_from_locale_symbol("cfkn3676");
   

   printf("loading fkn %s as adres %x.\n","cfkn3676",&cfkn3676);
   

   scm_define(cfkn3676_sym,SCM_PACK(((scm_t_bits) &cfkn3676) | 2));
   
}


So compileing and loading the shared library into guile you should be able 
to issue (f 1000000) and get a correct and fast result. 

I'm did not find my cfkn.h file but I'll send you the stuff I have. I modify
glil->assembly and add offload some bit's into an extra file into the same
directory also a vm-instruction is added to be able to start the c-code.

Have fun
Stefan


[-- Attachment #2: compile2c.tar.gz --]
[-- Type: application/x-compressed-tar, Size: 9983 bytes --]

  parent reply	other threads:[~2010-11-05 21:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 20:23 The progress of hacking guile and prolog Stefan Israelsson Tampe
2010-11-03 23:43 ` Ludovic Courtès
2010-11-04  2:40   ` Noah Lavine
2010-11-10 17:55     ` Stefan Israelsson Tampe
2010-11-11 19:10       ` Noah Lavine
2010-11-11 16:26     ` Ludovic Courtès
2010-11-11 19:13       ` Noah Lavine
2010-11-11 19:15       ` Noah Lavine
2010-11-15 23:10     ` Typechecking I Stefan Israelsson Tampe
2010-11-20 11:46       ` Andy Wingo
2010-11-20 11:25     ` The progress of hacking guile and prolog Andy Wingo
2010-11-24  1:54       ` Noah Lavine
2010-11-24 16:45         ` Stefan Israelsson Tampe
2010-11-24 18:00         ` piper schemigan Stefan Israelsson Tampe
2010-11-24 20:18           ` Andreas Rottmann
2010-11-25 21:17           ` Ludovic Courtès
2010-11-26 22:18             ` Stefan Israelsson Tampe
2010-11-28 22:30               ` Guile-SCSH Ludovic Courtès
2010-11-28 23:02                 ` Guile-SCSH Stefan Israelsson Tampe
2010-11-28 23:24                   ` Guile-SCSH Jose A. Ortega Ruiz
2010-11-29 18:56                     ` Guile-SCSH Stefan Israelsson Tampe
2010-11-29 21:26                     ` http://gitorious.org/guile-scsh/guile-scsh Stefan Israelsson Tampe
2010-11-30 23:21                       ` Guile-Facade Ludovic Courtès
2010-11-25 21:26         ` The progress of hacking guile and prolog Ludovic Courtès
2010-11-26 16:41           ` Noah Lavine
2010-11-26 10:45         ` Andy Wingo
2010-11-20 11:26     ` Andy Wingo
2010-11-04 17:57   ` Stefan Israelsson Tampe
2010-11-05 21:19   ` Stefan Israelsson Tampe [this message]
2010-11-19 23:11     ` GLIL->C compilation Ludovic Courtès
2010-11-19 23:20       ` Stefan Israelsson Tampe
2010-11-19 23:56         ` Ludovic Courtès
2010-11-20 12:18           ` Andy Wingo

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=201011052219.54556.stefan.itampe@gmail.com \
    --to=stefan.itampe@gmail.com \
    --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).