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

Shoaib Akram <[email protected]> Fri, 8 Jun 2018 09:03:46 +0200
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Thanks. I got it. I have a follow-on question. After obtaining the allocation sites, I print the method signature and bytecode index etc. on screen. I do not see this stuff being printed on the screen during compilation. How can I get the VM.sysWrite() lines below to execute during compilation?

protected final void emit_unresolved_new(TypeReference typeRef) {
    int value = OriginTracking.getValueFromLocation();
    VM.sysWrite("SITE: ");
    VM.sysWrite(method.getDeclaringClass().getDescriptor()); VM.sysWrite(" ");
    VM.sysWrite(method.getName()); VM.sysWrite(" ");
    VM.sysWrite(method.getDescriptor()); VM.sysWrite(" ");
    VM.sysWrite(biStart); VM.sysWrite(" ");
    VM.sysWriteln(value);
}

> On Jun 8, 2018, at 7:16 AM, Robin Garner <[email protected]> wrote:
> 
> 
> On 08/06/18 11:36, David P Grove wrote:
>> Shoaib Akram <[email protected]> <mailto:[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

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