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/
-------------------------------------------------------------------