This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Inline JVM assembly (was: Kawa and Google Summer of Code?_
- From: Charles Turner <chturne at gmail dot com>
- To: Jamison Hope <jrh at theptrgroup dot com>
- Cc: "kawa at sourceware dot org list" <kawa at sourceware dot org>
- Date: Mon, 11 Mar 2013 22:47:52 +0000
- Subject: Inline JVM assembly (was: Kawa and Google Summer of Code?_
On 11 March 2013 22:19, Jamison Hope <jrh@theptrgroup.com> wrote:
> Here's another idea that I've had running around the back of my head for
> a while but haven't had any time to actually try to implement it:
>
> SICP Chapter 5 presents a register machine simulator written as Scheme
> code. What if we cross that idea with Kawa's compiler to have a way
> to embed JVM assembly language instructions -- or a close approximation,
> anyway -- inside of Scheme code?
>
> So we'd have something like this, maybe:
>
> (define (gcd a::int b::int) ::int
> (asm
> test-b:
> (iload (reg b))
> (ifne (label gcd-loop))
> (iload (reg a))
> (goto (label gcd-done))
> gcd-loop:
> (iload (reg b))
> (iload (reg a))
> (iload (reg b))
> (irem)
> (istore (reg b))
> (istore (reg a))
> (goto (label test-b))
> gcd-done:
> (ireturn)))
>
Not sure what utility that would bring to Kawa programmers, seems like
the opposite direction Kawa takes from the JVM :D.
I agree that it would be fun to try and implement!
Charles.