[racket] Fw: assembly language

From: Hugh Aguilar (hughaguilar96 at yahoo.com)
Date: Wed Sep 26 23:08:31 EDT 2012

----- Forwarded Message -----
From: Hugh Aguilar <hughaguilar96 at yahoo.com>
To: Stephen Bloch <bloch at adelphi.edu> 
Sent: Wednesday, September 26, 2012 8:07 PM
Subject: Re: [racket] assembly language

You are right that a threaded Forth doesn't need to do any assembly --- it just "compiles" pointers to functions (code field addresses) in a thread. This can and has been done with traditional assemblers such as HLA. I'm not interested in that though.
I want to generate machine-code functions. This involves assembling at run-time (for the forth system, which is compile-time for the Forth application program).
I don't really understand JIT. I suppose the idea is to save memory by compiling the program as threaded code (which is much smaller than machine-code), but to convert this into machine-code "just in time" for it to run. I suppose this involves pasting together the code from all of those sub-functions in the threaded stream to create a sequence of machine-code. It seems like this conversion would take so much time that it would outweigh any speed advantage of running machine-code rather than threaded code. It must work somehow though, as it seems to be done quite a lot (the JVM for example).
I'm not planning on JIT (especially as I don't understand it). I just want the compiler to assemble actual text source-code rather than paste together code snippets, which I am finding to be a hassle. This will be done at compile-time for the Forth application --- at run-time the Forth application just runs.


From: Stephen Bloch <bloch at adelphi.edu>
To: Hugh Aguilar <hughaguilar96 at yahoo.com> 
Cc: Tony Garnock-Jones <tonyg at ccs.neu.edu>; "users at racket-lang.org" <users at racket-lang.org> 
Sent: Tuesday, September 25, 2012 5:12 PM
Subject: Re: [racket] assembly language

On Sep 25, 2012, at 7:38 PM, Hugh Aguilar <hughaguilar96 at yahoo.com> wrote:

I am writing a Forth system. I want it to be interactive in the usual Forth way. This means assembling a function at run-time and immediately being able to run the assembled function.
>... I'm much better off if I can just assemble the functions at run-time for the Forth system (which is compile-time for the user's Forth program).
The traditional way to implement a Forth compiler, IIUC,  isn't to generate executable machine code at all, but rather to generate a sequence of word-references that are interpreted as procedure calls by the Forth interpreter (which is in native executable code, but written in advance). 

Or are you talking about some kind of JIT compiler?

Stephen Bloch 
sbloch at adelphi.edu

who last implemented a Forth system in 1983; I presume things have changed since then!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120926/ff47a62e/attachment-0001.html>

Posted on the users mailing list.