Esempio n. 1
0
  /** {@inheritDoc} */
  public void close(int suiteType) throws NoClassDefFoundError {
    long time = 0;
    this.suiteType = suiteType;

    if (verbose()) {
      Tracer.trace("[Translator: computing closure...");
      time = System.currentTimeMillis();
    }

    computeClosure();

    if (translationStrategy == BY_SUITE || translationStrategy == BY_TRANSLATION) {
      if (verbose()) {
        time = System.currentTimeMillis() - time;
        Tracer.traceln(time + "ms.]");
        Tracer.trace("[Translator: whole-suite optimizing and inlining...");
        time = System.currentTimeMillis();
      }
      // bytecode optimizations and inlining go here

      if (Arg.get(Arg.DEAD_METHOD_ELIMINATION).getBool()) {
        dme = new DeadMethodEliminator(this);
        dme.computeMethodsUsed();
      }

      if (Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool()) {
        dce = new DeadClassEliminator(this);
        dce.computeClassesUsed();
      }

      if (verbose()) {
        time = System.currentTimeMillis() - time;
        Tracer.traceln(time + "ms.]");
        Tracer.trace("[Translator: phase2...");
        time = System.currentTimeMillis();
      }

      for (int cno = 0; cno < suite.getClassCount(); cno++) {
        Klass klass = suite.getKlass(cno);
        Assert.always(Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool() || (klass != null));
        if (klass != null) {
          convertPhase2(klass);
        }
      }
    }
    classFiles.clear();

    if (verbose()) {
      time = System.currentTimeMillis() - time;
      Tracer.traceln(time + "ms.]");

      if (VM.isVeryVerbose()) {
        InstructionEmitter.printUncalledNativeMethods();
      }
    }
    Assert.always(lastClassNameStack.empty());
  }