Re: [rvm-research] liverange + java keywords

Erik Brangs <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Hi,

On 28.10.2013 03:23, "C. Bergström" wrote:
> ----------
> 1) How do I access these keywords : synchronized, wait, notify, run, 
> thread and runnable

The methods notify() and wait() are defined on java.lang.Object. Jikes RVM replaces the java.lang.Object from the class library with its own implementation. Look for the source code under the directory libraryInterface/Common. Methods related to threading directly call matching methods in org.jikesrvm.scheduler.RVMThread. The situation for java.lang.Thread is similar: the methods that need JVM support eventually call methods in RVMThread. Runnable is a normal Java interface and AFAIK not treated specially.

If you have not changed the components.dir property in the build, the source code for the class library will be in your Jikes RVM directory. For example, if you were using Eclipse, you could use the "Open Resource" functionality to take a look at the Classpath implementation of java.lang.Thread. Note that some code from the class library is replaced by our implementations from the libraryInterface directory.

> For example synchronized
> -----------
> http://stackoverflow.com/questions/417285/equivalent-code-for-instance-method-synchronization-in-java/649740#649740
> 
> |public  synchronized  void  someMethod()  {
>    //stuff
> }|
> 
> and
> 
> |public  void  someMethod()  {
>    synchronized  (this)  {
>      //stuff
>    }
> }
> 
> --------
> Generated IR (if the above link is to be believed)

That's the bytecode generated by a Java compiler. The IR for a JVM JIT compiler may differ. For example, The High Level IR of the Jikes RVM optimizing compiler contains operators for runtime checks that are required by the JVM specification (e.g. array bounds checks). In case you haven't already done so, take a look at the user guide for more information about the IR.

> --------
> public synchronized someMethod()V
>    RETURN
> 

The optimizing compiler would insert MONITORENTER and MONITOREXIT calls into the IR when compiling this method. This happens in completePrologue(..) and completeEpilogue(..) in GenerationContext.

> Is the source semantics for "synchronized" still available or lost in 
> the lowering process? (Ideally I'd like access at the LIR level)

The very first step in the conversion to LIR expands the MONITOREXIT and MONITORENTER bytecodes into calls to methods from our Lock implementation. See ExpandRuntimeServices for details. For more details about the whole HIR->LIR conversion, see HIR2LIR(..) in OptimizationPlanner.

Please note that the Jikes RVM does not implement the Java Memory Model correctly.


Kind regards,

Erik Brangs

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
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.