puniverse / quasar

Fibers, Channels and Actors for the JVM
http://docs.paralleluniverse.co/quasar/
Other
4.56k stars 575 forks source link

suspendableCallSiteNames seems to be not emitted to @Instrumented annotation while AOT instrumentation #265

Closed pjBooms closed 7 years ago

pjBooms commented 7 years ago

I have a simple Quasar Test like here:

import co.paralleluniverse.fibers.*;

public class Test {

    @Suspendable
    public static void suspendableTest(int i) {
        System.out.println("Hello from suspendable method " + i);
    }

    public static void main(String[] args) {
        System.out.println("Hello from main");

        new Fiber<Integer>() {
            @Override
            protected Integer run() throws SuspendExecution, InterruptedException {
                for (int i = 0; i < 10; i++) {
                    suspendableTest(i);
                }
                return 0;
            }
        }.start();
        System.out.println("Hello from main");
    }
}

that is passed through AOT instrumentation.

when I disassemble Test$1.class with javap - v Test$1.class I see the following

  protected java.lang.Object run() throws co.paralleluniverse.fibers.SuspendExecution, java.lang.InterruptedException;
    descriptor: ()Ljava/lang/Object;
    flags: ACC_PROTECTED, ACC_BRIDGE, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokevirtual #4                  // Method run:()Ljava/lang/Integer;
         4: areturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   LTest$1;
      LineNumberTable:
        line 14: 0
        line 14: 1
        line 14: 1
    Exceptions:
      throws co.paralleluniverse.fibers.SuspendExecution, java.lang.InterruptedException
    RuntimeVisibleAnnotations:
      0: #47(#48=[I#89],#93=[I#90],#50=I#89,#52=I#89,#54=Z#90)

where I can see that Instrumented annotation has suspendableCallSites, suspendableCallSitesOffsetsAfterInstr attributes but not suspendableCallSiteNames.

As I see from InstrumentMethod.collectCallsites that all above attributes are actually collected simultaneously:

                       suspCallsBcis[count] = i;
                       suspCallsSourceLines[count] = currSourceLine;
                       callSiteNames.add(getSuspendableCallName(in));

So it puzzles me why they are not emitted at InstrumentMethod.emitInstrumentedAnn.

The original problem that I have that when SuspendableHelper.isCallSiteInstrumented is invoked it does not see callSiteNames and hence checks for instrumentation by source line only. But when a stack trace element does not have a source line, Quasar claims that a call site is not instrumented while in fact it is. Thus you have a strong dependency on a fact that a stack trace always has source lines (while they can be stripped).

pjBooms commented 7 years ago

I have just noticed that suspendableCallSiteNames is not released yet while I used released version for AOT instrumentation. When do you release it?