[LLVMdev] Getting address of label in jitted code

Dan Gohman gohman at apple.com
Fri Jan 23 09:50:53 PST 2009


On Jan 23, 2009, at 3:23 AM, Mark Shannon wrote:

> Dan,
>
>>
>> On Jan 22, 2009, at 3:45 AM, Mark Shannon wrote:
>>
>>> Hi,
>>>
>>> I need to get the address of a label in jitted code.
>>> (This is so that I can insert a jump into the machine code to resume
>>> interpretation from compiled code)
>>
>> Hello,
>>
>> What's your plan for restoring register and memory state?
>
> Put everything in memory at the yield point,
> (its for x86 only at the moment).
> Not super efficient, but should work.


Is your interpreter stackless? If it's stackless, you can put
your entrypoint at the beginning of a Function, and then just
call it.

LLVM doesn't support taking the real address of a label. It may
some day, but that won't by itself make it safe to jump into
compiled code from separately-compiled code. To do that, you'd
need to arrange some stable set of assumptions about the state
of the machine at the time of the jump, and a way to tell the
code generator where and how to stay within the assumptions.
And that's essentially what function calling conventions
already are.

Dan




More information about the llvm-dev mailing list