Re: [rvm-research] Jikes Code Cache Management

Michael Bond <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
On 05/08/2013 03:39 PM, Eliot Moss wrote:
> On 5/7/2013 1:39 PM, Pushparaj Motamari wrote:
>
>> I need help regarding Good resources to start understanding the Code Cache Management in JikesRVM?
> Dear Pushparaj -- AFAIK it is not something I would actually
> call a cache.  Code gets generated for some methods as part of
> the system build process (namely for those methods needed by
> the system itself).  When the system is about to run a method
> that has not yet been compiled, then the method will be compiled.
> The default policy will use the "baseline" (non-optimizing)
> compiler.  There are various controls that can override the
> policy.
>
> If a method is seen to be executed frequently enough, it will
> be re-compiled with the optimizing compiler -- sometimes multiple
> times (at increasing levels of optimization).  Future calls
> go to the latest version, and it is even possible to redirect
> calls *currently in progress* to new code using a technique
> called On Stack Replacement (OSR).  If you want to grasp that,
> I recommend reading the conference paper about it.
>
> Anyway, as newer version are compiled, older ones fall into
> disuse, but AFAIK the space is not reclaimed.  Compiled code
> resides in a space separate from the main garbage collected
> heap, and is never moved by the GC, which means that references
> to code, or positions within code (e.g., return addresses)
> do not have to be updated.  (If I am wrong about the space
> being reclaimed, then clearly it is managed by a mark-sweep /
> free-list kind of technique.)

Old versions of compiled methods can be reclaimed if they're no longer 
executing (i.e., not on the stack). A starting place for seeing how 
that's done is

CompiledMethods.snipObsoleteCompiledMethods()

By default, USE_CODE_SPACE is true, and (machine) code is allocated into 
special code spaces that are non-moving spaces. However, if 
USE_CODE_SPACE is false, then it looks like code is allocated into the 
default space, which could be a moving space. Assuming that's right, 
then I'm not entirely sure how pointers to code are updated. At least 
some calls are indirect: they go through TIBs (virtual dispatch) or the 
JTOC (static methods), so just updating these tables is sufficient. Are 
all calls indirect, or are there direct calls in the code that need to 
be updated by updating pointers in the code itself? I suspect that all 
calls are performed indirectly rather than having absolute hard-coded 
callee addresses in the code.

Cheers,
Mike

>
> So, is the space management you wanted to know about, really,
> or the recompilation policies?
>
> Regards -- Eliot Moss
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> Jikesrvm-researchers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.