Re: [rvm-research] Strange behavior in baseline compiler

Robin Garner <[email protected]> Fri, 8 Jun 2018 15:16:33 +1000
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
On 08/06/18 11:36, David P Grove wrote:
>
> Shoaib Akram <[email protected]> wrote on 06/07/2018 07:06:40 PM:
> >
> > I am observing a strange behavior in my code additions to the
> > baseline compiler. I cut a long story short and provide a simplified
> > example. I  obtain a monotonically increasing integer value from a
> > new module which I have placed in myJikes/rvm/src/org/jikesrvm/ot/
> > OriginTracking.java. All this class does is:
> >
> > private static int allocation_site = 2;
> >
> >   public static final int getValueFromLocation() {
> >     allocation_site += 2;
> >     return allocation_site;
> >   }
> >
> > In the BaselineCompilerImpl.java I obtain a value by calling
> > getValueFromLocation() in the emit_unresolved_new() method:
> >
> > protected final void emit_unresolved_new(TypeReference typeRef) {
> >     int value = OriginTracking.getValueFromLocation();
> >     VM.sysWriteln(value);
> >     rest of the method ….
> > }
> >
> > The first time getValueFromLocation() is called the value printed on
> > screen is 43044. How can this happen?
> >
> > This behavior is consistent across benchmarks and invocations :(
> >
> > If I comment out the allocation_site += 2 line in
> > getValueFromLocation, I get the correct value of 2.
> >
> > Any insight is welcome.
> >
>
> My guess is that the code is executed during BootImageWriting.  The 
> value 43044 is the value of the field at the time the bootimage is 
> written, so that value is carried over into runtime.
>
> --dave
>

Further to Dave's answer, if you want all the allocation sites in the 
boot image to have site # 0, you could do something like this:

 >   public static final int getValueFromLocation() {
 >     if (!VM.runningVM) return 0;
 >     allocation_site += 2;
 >     return allocation_site;
 >   }

cheers, Robin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Jikesrvm-researchers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers