[DGD] question about I_SWITCH
Felix A. Croes
felix at dworkin.nl
Sat Jun 26 14:52:19 CEST 2010
Carter Cheng <cartercheng at gmail.com> wrote:
> I have been working on a prototype for the JIT for dgd-osr but ran
> into a few issues with some of the opcodes that I am still trying to
> resolve. In particular I_SWITCH does not translate well into LLVM
> bitcode since a function that returns a program counter is not useful
> in this context. I am curious if this data can be decoded internally
> by the interpreter and converted into a series of jumps (or if this
> could be done by the dgd compiler).
Well, of course the interpreter already decodes I_SWITCH internally,
so anything it does you can replicate. You should think of I_SWITCH
as a type of jumptable, which can of course be converted.
> The other two opcodes I am having some problems with are I_CATCH and
> I_RLIMITS. These two seem to recusrively call i_interpret and I cannot
> really do this in llvm. I suspect the correct strategy is to replace
> this recursive call with a series of basic blocks with an exception
> block in the case of I_CATCH and work with compiling perhaps two
> versions of every function at some point one with rlimit type counters
> and one without.
These can also be converted, but there is one thing you have to take
into account: an I_RETURN instruction can return from a function, but
also from a I_CATCH or I_RLIMITS recursive call. What your code should
do is keep track of the current context, and perform the appropriate
task. You can do that at JIT compile time; the possible meanings of
I_RETURN do not overlap for any instance of the instruction in the
code.
Regards,
Felix Croes
More information about the DGD
mailing list