This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]