示例#1
0
  // Store the invariant for later printing. Ignore duplicate
  // invariants at the same program point.
  private static boolean store_invariant(
      String predicate, String index, HashedConsequent consequent, String pptname) {
    if (!pptname_to_conditions.containsKey(pptname)) {
      pptname_to_conditions.put(pptname, new HashMap<String, Map<String, HashedConsequent>>());
    }

    Map<String, Map<String, HashedConsequent>> cluster_to_conditions =
        pptname_to_conditions.get(pptname);
    if (!cluster_to_conditions.containsKey(predicate)) {
      cluster_to_conditions.put(predicate, new HashMap<String, HashedConsequent>());
    }

    Map<String, HashedConsequent> conditions = cluster_to_conditions.get(predicate);
    if (conditions.containsKey(index)) {
      HashedConsequent old = conditions.get(index);
      if (old.fakeFor != null && consequent.fakeFor == null) {
        // We already saw (say) "x != y", but we're "x == y", so replace it.
        conditions.remove(index);
        conditions.remove(old.fakeFor);
        conditions.put(index, consequent);
        return true;
      }
      return false;
    } else {
      conditions.put(index, consequent);
      return true;
    }
  }
  /**
   * method to repair the 1.4.2 parallel scavenge counters that are incorrectly initialized by the
   * JVM when UseAdaptiveSizePolicy is set. This bug couldn't be fixed for 1.4.2 FCS due to putback
   * restrictions.
   */
  private void kludgeMantis(Map<String, Monitor> map, StringMonitor args) {
    /*
     * the HotSpot 1.4.2 JVM with the +UseParallelGC option along
     * with its default +UseAdaptiveSizePolicy option has a bug with
     * the initialization of the sizes of the eden and survivor spaces.
     * See bugid 4890736.
     *
     * note - use explicit 1.4.2 counter names here - don't update
     * to latest counter names or attempt to find aliases.
     */

    String cname = "hotspot.gc.collector.0.name";
    StringMonitor collector = (StringMonitor) map.get(cname);

    if (collector.stringValue().compareTo("PSScavenge") == 0) {
      boolean adaptiveSizePolicy = true;

      /*
       * HotSpot processes the -XX:Flags/.hotspotrc arguments prior to
       * processing the command line arguments. This allows the command
       * line arguments to override any defaults set in .hotspotrc
       */
      cname = "hotspot.vm.flags";
      StringMonitor flags = (StringMonitor) map.get(cname);
      String allArgs = flags.stringValue() + " " + args.stringValue();

      /*
       * ignore the -XX: prefix as it only applies to the arguments
       * passed from the command line (i.e. the invocation api).
       * arguments passed through .hotspotrc omit the -XX: prefix.
       */
      int ahi = allArgs.lastIndexOf("+AggressiveHeap");
      int aspi = allArgs.lastIndexOf("-UseAdaptiveSizePolicy");

      if (ahi != -1) {
        /*
         * +AggressiveHeap was set, check if -UseAdaptiveSizePolicy
         * is set after +AggressiveHeap.
         */
        //
        if ((aspi != -1) && (aspi > ahi)) {
          adaptiveSizePolicy = false;
        }
      } else {
        /*
         * +AggressiveHeap not set, must be +UseParallelGC. The
         * relative position of -UseAdaptiveSizePolicy is not
         * important in this case, as it will override the
         * UseParallelGC default (+UseAdaptiveSizePolicy) if it
         * appears anywhere in the JVM arguments.
         */
        if (aspi != -1) {
          adaptiveSizePolicy = false;
        }
      }

      if (adaptiveSizePolicy) {
        // adjust the buggy AdaptiveSizePolicy size counters.

        // first remove the real counters.
        String eden_size = "hotspot.gc.generation.0.space.0.size";
        String s0_size = "hotspot.gc.generation.0.space.1.size";
        String s1_size = "hotspot.gc.generation.0.space.2.size";
        map.remove(eden_size);
        map.remove(s0_size);
        map.remove(s1_size);

        // get the maximum new generation size
        String new_max_name = "hotspot.gc.generation.0.capacity.max";
        LongMonitor new_max = (LongMonitor) map.get(new_max_name);

        /*
         * replace the real counters with pseudo counters that are
         * initialized to to the correct values. The maximum size of
         * the eden and survivor spaces are supposed to be:
         *    max_eden_size = new_size - (2*alignment).
         *    max_survivor_size = new_size - (2*alignment).
         * since we don't know the alignment value used, and because
         * of other parallel scavenge bugs that result in oversized
         * spaces, we just set the maximum size of each space to the
         * full new gen size.
         */
        Monitor monitor = null;

        LongBuffer lb = LongBuffer.allocate(1);
        lb.put(new_max.longValue());
        monitor = new PerfLongMonitor(eden_size, Units.BYTES, Variability.CONSTANT, false, lb);
        map.put(eden_size, monitor);

        monitor = new PerfLongMonitor(s0_size, Units.BYTES, Variability.CONSTANT, false, lb);
        map.put(s0_size, monitor);

        monitor = new PerfLongMonitor(s1_size, Units.BYTES, Variability.CONSTANT, false, lb);
        map.put(s1_size, monitor);
      }
    }
  }
  private void discoverAndRunProcs(
      Context context,
      Set<TypeElement> annotationsPresent,
      List<ClassSymbol> topLevelClasses,
      List<PackageSymbol> packageInfoFiles) {
    Map<String, TypeElement> unmatchedAnnotations =
        new HashMap<String, TypeElement>(annotationsPresent.size());

    for (TypeElement a : annotationsPresent) {
      unmatchedAnnotations.put(a.getQualifiedName().toString(), a);
    }

    // Give "*" processors a chance to match
    if (unmatchedAnnotations.size() == 0) unmatchedAnnotations.put("", null);

    DiscoveredProcessors.ProcessorStateIterator psi = discoveredProcs.iterator();
    // TODO: Create proper argument values; need past round
    // information to fill in this constructor.  Note that the 1
    // st round of processing could be the last round if there
    // were parse errors on the initial source files; however, we
    // are not doing processing in that case.

    Set<Element> rootElements = new LinkedHashSet<Element>();
    rootElements.addAll(topLevelClasses);
    rootElements.addAll(packageInfoFiles);
    rootElements = Collections.unmodifiableSet(rootElements);

    RoundEnvironment renv =
        new JavacRoundEnvironment(false, false, rootElements, JavacProcessingEnvironment.this);

    while (unmatchedAnnotations.size() > 0 && psi.hasNext()) {
      ProcessorState ps = psi.next();
      Set<String> matchedNames = new HashSet<String>();
      Set<TypeElement> typeElements = new LinkedHashSet<TypeElement>();

      for (Map.Entry<String, TypeElement> entry : unmatchedAnnotations.entrySet()) {
        String unmatchedAnnotationName = entry.getKey();
        if (ps.annotationSupported(unmatchedAnnotationName)) {
          matchedNames.add(unmatchedAnnotationName);
          TypeElement te = entry.getValue();
          if (te != null) typeElements.add(te);
        }
      }

      if (matchedNames.size() > 0 || ps.contributed) {
        boolean processingResult = callProcessor(ps.processor, typeElements, renv);
        ps.contributed = true;
        ps.removeSupportedOptions(unmatchedProcessorOptions);

        if (printProcessorInfo || verbose) {
          log.printNoteLines(
              "x.print.processor.info",
              ps.processor.getClass().getName(),
              matchedNames.toString(),
              processingResult);
        }

        if (processingResult) {
          unmatchedAnnotations.keySet().removeAll(matchedNames);
        }
      }
    }
    unmatchedAnnotations.remove("");

    if (lint && unmatchedAnnotations.size() > 0) {
      // Remove annotations processed by javac
      unmatchedAnnotations.keySet().removeAll(platformAnnotations);
      if (unmatchedAnnotations.size() > 0) {
        log = Log.instance(context);
        log.warning("proc.annotations.without.processors", unmatchedAnnotations.keySet());
      }
    }

    // Run contributing processors that haven't run yet
    psi.runContributingProcs(renv);

    // Debugging
    if (options.isSet("displayFilerState")) filer.displayState();
  }
 public synchronized void setVariable(String variable, String value) {
   if (value == null) variables.remove(value);
   else variables.put(variable, value);
 }