guile-devel
[Top][All Lists]
Advanced

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

Troubles with Objcode and Storing JIT Pointers


From: Noah Lavine
Subject: Troubles with Objcode and Storing JIT Pointers
Date: Mon, 21 Jun 2010 14:19:31 -0400

Hello all,

I have hit a snag in my attempt to add a JIT backend to Guile: I don't
know where to store the JITed code.

There was a discussion of this a few weeks ago in which it was decided
to try to make a simple and quick JIT engine that would be invisible
to Scheme, hoping to eventually make a full AOT compilation engine
using GCC. I am working on this JIT engine. What I need in this is
some way to stash the JIT code I've made for a procedure in such a way
that I can get it back again if I need to run the same procedure
again.

My current attempt tries to put it in the struct scm_objcode structure
as an extra pointer, but the trouble is that scm_objcodes are made
directly from bytecode, by just casting the bytecode to a struct
scm_objcode. That by itself wouldn't be a terrible problem, because I
can rearrange things in memory behind-the-scenes to hide the extra
pointer, but objcodes can also be embedded in other objcodes. In order
to make this work correctly, I'd either have to scan every bytecode
that becomes an objcode, find any embedded objcodes, and add space for
the new pointer, or modify the bytecode compiler to leave extra room.
Of these two, I think the second option would be best because it would
be faster, but then the fact that the objcode structure has an extra
pointer is trickling up to Scheme code, and I'm not sure where the
abstraction leakage would stop. (Bytecode? Assembly code?)

I could fix this by not allowing objcode slices, and instead having
some sort of indirection, but that removes some efficiency that might
be important.

Another option is to store the JITed code with the procedure object,
but a procedure is already four machine words, and making it any
bigger could mess up the machine cache.

Can anyone suggest a solution?

Thanks
Noah



reply via email to

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