예제 #1
0
 /** * Code to be instrumented when an interaction point is encountered. */
 private void onInteractionPointEncounter() {
   if (iparams.trappingInteractionPoints()) {
     mv.visitMethodInsn(INVOKESTATIC, "virtualtime/EventNotifier", "_interactionPoint", "()V");
   }
 }
예제 #2
0
  /**
   * * Constructor setting the parameters of the method
   *
   * @param arg0 the method visitor object to write the new code
   * @param _methodId the unique JINE id of the method
   * @param isProfiled should we add instrumentation code to profile the method
   * @param access access rules of the method
   * @param cName class name
   * @param mName method name
   * @param desc arguments description
   * @param signature signature
   * @param exceptions array of strings with the possibly thrown exception classes
   * @param _iparams instrumentation parameters as selected by the user options
   */
  public BasicBlockMethodAdapter(
      MethodVisitor arg0,
      int _methodId,
      boolean isProfiled,
      int access,
      String cName,
      String mName,
      String desc,
      String signature,
      String[] exceptions,
      InstrumentationParameters _iparams,
      MethodAdaptationInfo _methodAdaptationInfo) {

    super(arg0);

    instrumentationStatsRecord = InstrumentationRecordFactory.getRecord();

    allStartingTryCatchingBlockLabels = null;
    allEndingTryCatchingBlockLabels = null;
    tryCatchDepth = 0;

    iparams = _iparams;
    methodAdaptationInfo = _methodAdaptationInfo;

    methodId = _methodId;

    className = cName;
    methodName = mName;
    methodDesc = desc;

    isSynchronised = (access & ACC_SYNCHRONIZED) != 0;
    isStatic = (access & ACC_STATIC) != 0;

    profile =
        isProfiled
            && !(isSynchronised
                && (iparams.trappingInteractionPoints()
                    || (iparams
                        .usingExternalInstrumentation()))); // sync methods are profiled externally
                                                            // when IPs are trapped

    // Some methods
    if (iparams.exceptionHandlingEverywhere()) {
      instrumentExceptionHandlingCode = true;
    } else {
      instrumentExceptionHandlingCode = false;
    }

    // Register the methodId to the VTF
    if (profile) {
      instrumentationStatsRecord.setProfiled();

      if (!iparams.isRetransformingInstrumentation()) {
        EventNotifier.registerMethod(
            cName + " " + mName + " " + desc, methodId, _iparams.getMethod0());
      } else {
        instrumentationStatsRecord.setRetransformed();
      }

      shouldBeWrappedWithVexOptimizerLoop =
          iparams.shouldBeWrappedWithVexOptimizerLoop(mName); // wrap the first appearance of main
      if (shouldBeWrappedWithVexOptimizerLoop) {
        System.out.println("will wrap vex optimizer " + cName + " " + mName + " " + desc);
      }

      if (iparams.methodShouldBeAdapted(methodId)) {
        if (exceptions != null && exceptions.length > 0) {
          instrumentExceptionHandlingCode = true;
        }
      }
    }

    if (DEBUG) {
      System.out.println("Instrumenting  " + cName + " -> " + mName + "(" + methodId + ")" + desc);
    }

    performanceModelParameters = null;
  }