Re: [rvm-research] Missing pickAllocator() call
Robin Garner <[email protected]> Thu, 16 Aug 2018 01:52:52 +1000
| Newsgroups | gmane.comp.java.jikes.rvm.devel |
|---|---|
| Message-ID | <CADjFg8Stwpro5a6V4si+yP0Ux96gXODHVDt7P3Uk9DqO7aVDCQ@mail.gmail.com> |
What do you see if you enable 'traceAllocator' in MemoryManager ? My suspicion is that the first invocation is calling the pickAllocator(RVMType type) variant of the method, probably via a NEW_UNRESOLVED opcode. Catching these allocations probably requires looking for the annotation in the compiler (ExpandRuntimeServices, BaselineCompiler), rather than in pickAllocator, and compiling it as a parameter to the unresolvedNewScalar invocation. I guess you could pass the RVMMethod object through to unresolvedNewScalar, but I have a feeling that would be harder. HTH, Robin On Wed, Aug 15, 2018 at 7:04 AM Ruben Peter Vervaeke < [email protected]> wrote: > Hi, > > > I am writing a small application to test the workings of my rvm > implementation. It contains 3 methods that are called in turn. Each method > is annotated with an AllocationStrategy annotation. This annotation is > checked in the pickAllocator(RVMType type, RVMMethod method) method > of the MemoryManager class for determining an appropriate allocator. > Unfortunately when I run my application the pickAllocator(...) method > doesn't find the annotation for the very *first* method. All *subsequent* > method calls are in fact good, in the sense that the AllocationStrategy > annotation is found on the methods. > > > I have debugged this and found that the pickAllocator(RVMType type, > RVMMethod method) method is simply not called for the first method. I > don't understand why. Does anyone knows why this is happening? If so, any > idea how to fix this? > > > Thanks in advance > > > Ruben > > > > *App.java* > > > public class App { > > public static void main(String[] args) throws InterruptedException { > > App app = new App(); > > System.out.println("Invoking instantiateHighlyWrittenObjects..."); > app.instantiateHighlyWrittenObjects(); > System.out.println("Invoking instantiateHighlyWrittenObjects done"); > > System.out.println("Invoking instantiateMediumWrittenObjects..."); > app.instantiateMediumWrittenObjects(); > System.out.println("Invoking instantiateMediumWrittenObjects done"); > > System.out.println("Invoking instantiateNoneWrittenObjects..."); > app.instantiateNoneWrittenObjects(); > System.out.println("Invoking instantiateNoneWrittenObjects done"); > > // Force GC > System.gc(); > } > > @AllocationStrategy(mutationRate = AllocationStrategy.MutationRate.HIGH) > public void instantiateHighlyWrittenObjects() { > for (int i = 0; i < 3; i++) { > Example o = new Example(); > } > } > > @AllocationStrategy(mutationRate = AllocationStrategy.MutationRate.MID) > public void instantiateMediumWrittenObjects() { > for (int i = 0; i < 3; i++) { > Example o = new Example(); > } > } > > @AllocationStrategy(mutationRate = AllocationStrategy.MutationRate.NONE) > public void instantiateNoneWrittenObjects() { > for (int i = 0; i < 3; i++) { > Example o = new Example(); > } > } > } > > > *MemoryManager.java* > > > @Uninterruptible > public final class MemoryManager { > > ... > > > @Interruptible > public static int pickAllocator(RVMType type, RVMMethod method) { > if (traceAllocator) { > VM.sysWrite("allocator for "); > VM.sysWrite(type.getDescriptor()); > VM.sysWrite(": "); > } > if (method != null) { > // We should strive to be allocation-free here. > RVMClass cls = method.getDeclaringClass(); > byte[] clsBA = cls.getDescriptor().toByteArray(); > if (Selected.Constraints.get().withGCspy()) { > if (isPrefix("Lorg/mmtk/vm/gcspy/", clsBA) || isPrefix("[Lorg/mmtk/vm/gcspy/", clsBA)) { > if (traceAllocator) { > VM.sysWriteln("GCSPY"); > } > return Plan.ALLOC_GCSPY; > } > } > if (method.getName().toString().startsWith("instantiate")) { > VM.sysWriteln("Checking AllocationStrategy on method: " + method.getName()); > } > AllocationStrategy allocationStrategy = method.getAllocationStrategy(); > if (allocationStrategy != null) { > if (traceASAllocator) { > VM.sysWriteln("Found AllocationStrategy on method: " + method.getName()); > } > AllocationStrategy.MutationRate mutationRate = allocationStrategy.mutationRate(); > if (traceASAllocator) { > VM.sysWriteln("MutationRate: " + mutationRate.name()); > } > switch (mutationRate) { > case NONE: > if (traceAllocator || traceASAllocator) { > VM.sysWriteln("DEFAULT_NVM"); > } > return Plan.ALLOC_DEFAULT_NVM; > default: > if (traceAllocator || traceASAllocator) { > VM.sysWriteln("DEFAULT_DRAM"); > } > return Plan.ALLOC_DEFAULT_DRAM; > } > } > if (isPrefix("Lorg/jikesrvm/mm/mmtk/ReferenceProcessor", clsBA)) { > if (traceAllocator) { > VM.sysWriteln("DEFAULT"); > } > return Plan.ALLOC_DEFAULT_DRAM; > } > if (isPrefix("Lorg/mmtk/", clsBA) || isPrefix("Lorg/jikesrvm/mm/", clsBA)) { > if (traceAllocator) { > VM.sysWriteln("NONMOVING"); > } > return Plan.ALLOC_NON_MOVING; > } > if (method.isNonMovingAllocation()) { > return Plan.ALLOC_NON_MOVING; > } > } > if (traceAllocator) { > VM.sysWriteln(type.getMMAllocator()); > } > return type.getMMAllocator(); > } > > *...* > > *}* > > > > > > *Output when run:* > > > rvervaek@rvervaek-VirtualBox:~/IdeaProjects/jikesrvm-as$ > ./dist/production_x86_64-linux/rvm -Xms80M -X:gc:boundedNursery=4M > -X:gc:variableSizeHeap=false -Dprobes=Replay,MMTk > -X:aos:initial_compiler=base -X:aos:enable_bulk_compile=true > -X:aos:enable_recompilation=false -X:availableProcessors=4 -X:gc:threads=2 > -cp /home/rvervaek/Artifacts/as-method.jar App > Invoking instantiateHighlyWrittenObjects... > Creating Example object... > Creating Example object... > Creating Example object... > Invoking instantiateHighlyWrittenObjects done > Invoking instantiateMediumWrittenObjects... > *Checking AllocationStrategy on method: instantiateMediumWrittenObjects* > Found AllocationStrategy on method: instantiateMediumWrittenObjects > MutationRate: MID > DEFAULT_DRAM > Creating Example object... > Creating Example object... > Creating Example object... > Invoking instantiateMediumWrittenObjects done > Invoking instantiateNoneWrittenObjects... > *Checking AllocationStrategy on method: instantiateNoneWrittenObjects* > Found AllocationStrategy on method: instantiateNoneWrittenObjects > MutationRate: NONE > DEFAULT_NVM > Creating Example object... > Creating Example object... > Creating Example object... > Invoking instantiateNoneWrittenObjects done > > > > > ------------------------------------------------------------------------------ > 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