[LLVMdev] GCModuleInfo and MCJIT

Gaël Thomas gael.thomas00 at gmail.com
Fri Dec 20 04:01:15 PST 2013


Hi all,

I continue my post because I made a mistake: there is no need to
preserve and to restore the section in finishAssembly (I faced a
really ugly bug elsewhere caused by random values in floatting point
registers, which was hidden by preserving the section).

So, basically, if you want to use gcroot with mcjit, it's easy: just
generate the stack maps in the data section, just like in
ErlangGCPrinter.cpp or OcamlGCPrinter.cpp, and then, you can find this
stack map in mcjit by using mcjit::getGlobalValueAddress.

See you,
Gaël








2013/12/18 Gaël Thomas <gael.thomas00 at gmail.com>:
> Hi,
>
> I have the solution to my problem :). And the llvm gc infrastructure
> can work with the current MCJIT without any change (good news).
>
> I will explain what I have done to find the garbage collector metadata
> generated by llvm with MCJIT, I'm pretty sure that it could help
> someone.
>
> And it's very easy. You just have to activate a static gcprinter for
> the assembly. A very good example is given in
> OcamlGCPrinter.cpp/OCamlGC.cpp. The only problem with the hook of
> OcamlGCPrinter::finishAssembly() is that it changes the current
> section to emit the gc metadata in the data section. And it does not
> work with MCJIT. I don't know why, probably because somewhere, an
> AsmPrinter or MCJIT supposes that another section is active after the
> call to finishAssembly. To solve the problem, you just have to add
>
>     const MCSection* sec = AP.getCurrentSection();
>
> et the beginning of finishAssembly, and
>
>     AP.OutStreamer.SwitchSection(sec);
>
> at the end.
>
> See you,
> Gaël
>
>
>
> 2013/12/18 Gaël Thomas <gael.thomas00 at gmail.com>:
>> Hi!
>>
>> I have now a more precise question, I hope that this time, someone
>> will be able to help me :)
>>
>> I'm now able to find the gc meta data. To find this data, I simply
>> register a GCMetadataPrinter (just like during an AOT compilation). A
>> GCMetadataprinter is called at the end of the compilation of a module
>> after having assigned the slots to the live roots. I have almost
>> everything except that at this step, a collection point (aka safepoint
>> in the GC world) is describe by:
>> * a MCSymbol, which indicates the location of a safepoint (basically
>> the instruction pointer that follows the safepoint)
>> * a list of live roots, each one is described by an offset relative to
>> the frame pointer.
>>
>> Now, I would like to find the concrete address of the MCSymbol. And I
>> don't know how I could find this information. When I generate the
>> assembly, I don't have the actual location of the function (I
>> manipulate the AsmPrinter but it's not directly the object file). And
>> after having loaded the object file, I don't know how I could find the
>> concrete address of the MCSymbol. When I call
>> mcjit->getGlobalValueAddress("safepoint-symb"), mcjit is unable to
>> find it in the object file.
>>
>> Any idea?
>> Gaël
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2013/12/15 Gaël Thomas <gael.thomas00 at gmail.com>:
>>> Hi all,
>>>
>>> So, MCJIT is working with vmkit, that's great. However, I need to
>>> retrieve the GCModuleInfo and the MachineCodeEmitter used during the
>>> compilation process. And I don't know how I should proceed? I'm trying
>>> to understand how they are preserved with the old jit, but I have to
>>> say that I'm a little bit lost because I haven't a global view of the
>>> code... So, any help would be greatly appreciated!
>>>
>>> See you,
>>> Gaël
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> -------------------------------------------------------------------
>>> Gaël Thomas, Associate Professor, UPMC
>>> http://pagesperso-systeme.lip6.fr/Gael.Thomas/
>>> -------------------------------------------------------------------
>>
>>
>>
>> --
>> -------------------------------------------------------------------
>> Gaël Thomas, Associate Professor, UPMC
>> http://pagesperso-systeme.lip6.fr/Gael.Thomas/
>> -------------------------------------------------------------------
>
>
>
> --
> -------------------------------------------------------------------
> Gaël Thomas, Associate Professor, UPMC
> http://pagesperso-systeme.lip6.fr/Gael.Thomas/
> -------------------------------------------------------------------



-- 
-------------------------------------------------------------------
Gaël Thomas, Associate Professor, UPMC
http://pagesperso-systeme.lip6.fr/Gael.Thomas/
-------------------------------------------------------------------




More information about the llvm-dev mailing list