Exemplo 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());
  }
Exemplo n.º 2
0
 public byte[] getResourceData(String name) {
   Assert.that(VM.isHosted() || VM.getCurrentIsolate().getLeafSuite() == suite);
   try {
     byte[] bytes = classPath.getBytes(name);
     ResourceFile resourceFile = new ResourceFile(name, bytes);
     suite.installResource(resourceFile);
     return bytes;
   } catch (IOException e) {
     return null;
   }
 }
Exemplo n.º 3
0
  /** Load and converts the closure of classes in the current suite. */
  public void computeClosure() {
    boolean changed = true;
    while (changed) {
      changed = false;
      for (int cno = 0; cno < suite.getClassCount(); cno++) {
        Klass klass = suite.getKlass(cno);

        if (klass == null) {
          continue; // if not floats, or if deferred errors, there can be some missing classes
        }

        if (klass.getState() < Klass.STATE_LOADED) {
          load(klass);
          changed = true;
        }
        if (klass.getState() < Klass.STATE_CONVERTING) {
          convert(klass);
          changed = true;
        }
      }
    }
  }