Java Code Examples for java.util.EnumSet#clone()

The following examples show how to use java.util.EnumSet#clone() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: buck   File: Optimizer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Runs the optimizer with a strategy to minimize the number of rop-form
 * registers used by the end result. Dex bytecode does not have instruction
 * forms that take register numbers larger than 15 for all instructions.
 * If we've produced a method that uses more than 16 registers, try again
 * with a different strategy to see if we can get under the bar. The end
 * result will be much more efficient.
 *
 * @param rmeth method to process
 * @param paramWidth the total width, in register-units, of this method's
 * parameters
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param steps set of optional optimization steps to run
 * @return optimized method
 */
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth,
        int paramWidth, boolean isStatic,
        EnumSet<OptionalStep> steps) {
    SsaMethod ssaMeth;
    RopMethod resultMeth;

    ssaMeth = SsaConverter.convertToSsaMethod(
            rmeth, paramWidth, isStatic);

    EnumSet<OptionalStep> newSteps = steps.clone();

    /*
     * CONST_COLLECTOR trades insns for registers, which is not an
     * appropriate strategy here.
     */
    newSteps.remove(OptionalStep.CONST_COLLECTOR);

    runSsaFormSteps(ssaMeth, newSteps);

    resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true);
    return resultMeth;
}
 
Example 2
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 3
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 4
Source Project: Box   File: Optimizer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Runs the optimizer with a strategy to minimize the number of rop-form
 * registers used by the end result. Dex bytecode does not have instruction
 * forms that take register numbers larger than 15 for all instructions.
 * If we've produced a method that uses more than 16 registers, try again
 * with a different strategy to see if we can get under the bar. The end
 * result will be much more efficient.
 *
 * @param rmeth method to process
 * @param paramWidth the total width, in register-units, of this method's
 * parameters
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param steps set of optional optimization steps to run
 * @return optimized method
 */
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth,
        int paramWidth, boolean isStatic,
        EnumSet<OptionalStep> steps) {
    SsaMethod ssaMeth;
    RopMethod resultMeth;

    ssaMeth = SsaConverter.convertToSsaMethod(
            rmeth, paramWidth, isStatic);

    EnumSet<OptionalStep> newSteps = steps.clone();

    /*
     * CONST_COLLECTOR trades insns for registers, which is not an
     * appropriate strategy here.
     */
    newSteps.remove(OptionalStep.CONST_COLLECTOR);

    runSsaFormSteps(ssaMeth, newSteps);

    resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true);
    return resultMeth;
}
 
Example 5
Source Project: jdk8u60   File: FlagOpTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 6
/**
 * Runs the optimizer with a strategy to minimize the number of rop-form
 * registers used by the end result. Dex bytecode does not have instruction
 * forms that take register numbers larger than 15 for all instructions.
 * If we've produced a method that uses more than 16 registers, try again
 * with a different strategy to see if we can get under the bar. The end
 * result will be much more efficient.
 *
 * @param rmeth method to process
 * @param paramWidth the total width, in register-units, of this method's
 * parameters
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param steps set of optional optimization steps to run
 * @return optimized method
 */
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth,
        int paramWidth, boolean isStatic,
        EnumSet<OptionalStep> steps) {
    SsaMethod ssaMeth;
    RopMethod resultMeth;

    ssaMeth = SsaConverter.convertToSsaMethod(
            rmeth, paramWidth, isStatic);

    EnumSet<OptionalStep> newSteps = steps.clone();

    /*
     * CONST_COLLECTOR trades insns for registers, which is not an
     * appropriate strategy here.
     */
    newSteps.remove(OptionalStep.CONST_COLLECTOR);

    runSsaFormSteps(ssaMeth, newSteps);

    resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true);
    return resultMeth;
}
 
Example 7
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 8
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 9
Source Project: javaide   File: Optimizer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Runs the optimizer with a strategy to minimize the number of rop-form
 * registers used by the end result. Dex bytecode does not have instruction
 * forms that take register numbers larger than 15 for all instructions.
 * If we've produced a method that uses more than 16 registers, try again
 * with a different strategy to see if we can get under the bar. The end
 * result will be much more efficient.
 *
 * @param rmeth method to process
 * @param paramWidth the total width, in register-units, of this method's
 * parameters
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param steps set of optional optimization steps to run
 * @return optimized method
 */
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth,
        int paramWidth, boolean isStatic,
        EnumSet<OptionalStep> steps) {
    SsaMethod ssaMeth;
    RopMethod resultMeth;

    ssaMeth = SsaConverter.convertToSsaMethod(
            rmeth, paramWidth, isStatic);

    EnumSet<OptionalStep> newSteps = steps.clone();

    /*
     * CONST_COLLECTOR trades insns for registers, which is not an
     * appropriate strategy here.
     */
    newSteps.remove(OptionalStep.CONST_COLLECTOR);

    runSsaFormSteps(ssaMeth, newSteps);

    resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true);
    return resultMeth;
}
 
Example 10
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 11
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 12
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 13
Source Project: hottub   File: FlagOpTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 14
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 15
public void testFlagsSizedOrderedParallelCollect() {
    EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
    EnumSet<StreamOpFlag> serKnown = parKnown.clone();

    List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
    for (StreamOpFlag f : parKnown) {
        ops.add(CollectorOps.collector());
        ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
                                         parKnown,
                                         serKnown));
        serKnown.remove(f);
    }
    ops.add(CollectorOps.collector());
    ops.add(new ParSerTestFlagExpectedOp<>(0,
                                     parKnown,
                                     EnumSet.noneOf(StreamOpFlag.class)));

    TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
    @SuppressWarnings("rawtypes")
    IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);

    withData(data).ops(opsArray).exercise();
}
 
Example 16
Source Project: gemfirexd-oss   File: GemFireXDUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static EnumSet<TransactionFlag> addTXFlag(TransactionFlag flag,
    EnumSet<TransactionFlag> flagSingleton,
    EnumSet<TransactionFlag> currentFlags) {
  if (currentFlags == null) {
    return flagSingleton;
  }
  // don't overwrite static single sized flags
  else if (currentFlags.size() == 1) {
    currentFlags = currentFlags.clone();
  }
  currentFlags.add(flag);
  return currentFlags;
}
 
Example 17
Source Project: gemfirexd-oss   File: GemFireXDUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static EnumSet<TransactionFlag> addTXFlag(TransactionFlag flag,
    EnumSet<TransactionFlag> flagSingleton,
    EnumSet<TransactionFlag> currentFlags) {
  if (currentFlags == null) {
    return flagSingleton;
  }
  // don't overwrite static single sized flags
  else if (currentFlags.size() == 1) {
    currentFlags = currentFlags.clone();
  }
  currentFlags.add(flag);
  return currentFlags;
}
 
Example 18
Source Project: domino-jna   File: MIMEStream.java    License: Apache License 2.0 3 votes vote down vote up
/**
 *  Creates a MIME stream, serializes the named items into it, and returns the MIME stream.<br>
 *  Specify the flag {@link MimeStreamOpenOptions#RFC2822_INCLUDE_HEADERS}
 *  to flush all RFC2822 headers to the output MIME stream; i.e.,
 *  the message's initial headers -- To, From, Subject, Date, etc.<br>
 *  <br>
 *  Also specify the flag {@link MimeStreamOpenOptions#MIME_INCLUDE_HEADERS}
 *  to flush all MIME entity headers to the output MIME stream.
 * 
 * @param note note
 * @param itemName item name
 * @param flags open flags (e.g. whether to include RFC822 and headers)
 * @return MIME stream
 */
public static MIMEStream newStreamForRead(NotesNote note, String itemName, EnumSet<MimeStreamOpenOptions> flags) {
	EnumSet<MimeStreamOpenOptions> flagsClone = flags.clone();
	
	int dwOpenFlags = MimeStreamOpenOptions.toBitMaskInt(flagsClone);
	dwOpenFlags = dwOpenFlags | NotesConstants.MIME_STREAM_OPEN_READ;
	return new MIMEStream(note, itemName, dwOpenFlags);
}
 
Example 19
Source Project: domino-jna   File: MIMEStream.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates a MIME stream. Use {@link #putLine(String)}
 * or {@link #write(Reader)} to specify the MIME data to be written, then
 * call {@link #itemize(EnumSet)} to write the data to the document.
 * 
 * @param note note
 * @param itemName mime item to write content
 * @param flags open flags
 * @return MIME stream
 */
public static MIMEStream newStreamForWrite(NotesNote note, String itemName, EnumSet<MimeStreamOpenOptions> flags) {
	EnumSet<MimeStreamOpenOptions> flagsClone = flags.clone();

	int dwOpenFlags = MimeStreamOpenOptions.toBitMaskInt(flagsClone);
	dwOpenFlags = dwOpenFlags | NotesConstants.MIME_STREAM_OPEN_WRITE;
	return new MIMEStream(note, itemName, dwOpenFlags);
}
 
Example 20
/**
 * Use this constructor when you want to specify which keys to add to the MDC.
 * You could still add custom keys via {@link #setProperty(IoSession, String, String)}
 * @param keys set of keys that should be added to the MDC
 *
 * @see #setProperty(org.apache.mina.core.session.IoSession, String, String)
 */
public MdcInjectionFilter(EnumSet<MdcKey> keys) {
    this.mdcKeys = keys.clone();
}