/** * Clear the info about which rows (in which original iterators and which row nums within them) were combined on * the previous step. */ private void clearCombinedRowsInfo() { for (int originalIteratorIndex = indexesOfCurrentlyCombinedOriginalIterators.nextSetBit(0); originalIteratorIndex >= 0; originalIteratorIndex = indexesOfCurrentlyCombinedOriginalIterators.nextSetBit(originalIteratorIndex + 1)) { minCurrentlyCombinedRowNumByOriginalIteratorIndex[originalIteratorIndex] = MIN_CURRENTLY_COMBINED_ROW_NUM_UNSET_VALUE; } indexesOfCurrentlyCombinedOriginalIterators.clear(); }
/** * Creates new instance for nested structure. * @param base parent's level * @param offsets offsets from parent's level. */ public IndentLevel(IndentLevel base, int... offsets) { final BitSet src = base.levels; for (int i = src.nextSetBit(0); i >= 0; i = src.nextSetBit(i + 1)) { for (int offset : offsets) { levels.set(i + offset); } } }
public static List<BlockNode> bitSetToBlocks(MethodNode mth, BitSet bs) { int size = bs.cardinality(); if (size == 0) { return Collections.emptyList(); } List<BlockNode> blocks = new ArrayList<>(size); for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { BlockNode block = mth.getBasicBlocks().get(i); blocks.add(block); } return blocks; }
private static void placePhi(MethodNode mth, int regNum, LiveVarAnalysis la) { List<BlockNode> blocks = mth.getBasicBlocks(); int blocksCount = blocks.size(); BitSet hasPhi = new BitSet(blocksCount); BitSet processed = new BitSet(blocksCount); Deque<BlockNode> workList = new LinkedList<>(); BitSet assignBlocks = la.getAssignBlocks(regNum); for (int id = assignBlocks.nextSetBit(0); id >= 0; id = assignBlocks.nextSetBit(id + 1)) { processed.set(id); workList.add(blocks.get(id)); } while (!workList.isEmpty()) { BlockNode block = workList.pop(); BitSet domFrontier = block.getDomFrontier(); for (int id = domFrontier.nextSetBit(0); id >= 0; id = domFrontier.nextSetBit(id + 1)) { if (!hasPhi.get(id) && la.isLive(id, regNum)) { BlockNode df = blocks.get(id); addPhi(mth, df, regNum); hasPhi.set(id); if (!processed.get(id)) { processed.set(id); workList.add(df); } } } } }
@Benchmark public BitSet bitset() { BitSet result = new BitSet(); for(int i = 0; i < bitSets.length; ++i) { BitSetWithOffset bit = bitSets[i]; int currentBit = bit.bitset.nextSetBit(0); while(currentBit != -1) { result.set(currentBit + bit.offset); currentBit = bit.bitset.nextSetBit(currentBit + 1); } } return result; }
if(origNumber != null) { for(ValueInfo vi : vals) { if(vi.origValues.get(origNumber.getNumber()) && !vi.derivedValues.get(number)) { vi.derivedValues.set(number); result = true; for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) { list = values.get(i); if(list == null) {
@SuppressWarnings("unchecked") public ArrayTypes getArrayTypesBefore(Stmt s, Local arrayLocal) { if (!isConstantBefore(s, arrayLocal)) { return null; } ArrayTypes toRet = new ArrayTypes(); int varRef = localToInt.get(arrayLocal); ArrayTypesInternal ati = getFlowBefore(s).state[varRef]; toRet.possibleSizes = new HashSet<Integer>(); toRet.possibleTypes = new Set[ati.typeState.length]; for (int i = ati.sizeState.nextSetBit(0); i >= 0; i = ati.sizeState.nextSetBit(i + 1)) { toRet.possibleSizes.add(rvSizeToInt.get(i)); } for (int i = 0; i < toRet.possibleTypes.length; i++) { toRet.possibleTypes[i] = new HashSet<Type>(); for (int j = ati.typeState[i].nextSetBit(0); j >= 0; j = ati.typeState[i].nextSetBit(j + 1)) { toRet.possibleTypes[i].add(rvTypeToInt.get(j)); } if (!ati.mustAssign.get(i)) { toRet.possibleTypes[i].add(NullType.v()); } } return toRet; }
static CharMatcher from(BitSet chars, String description) { // Compute the filter. long filter = 0; int size = chars.cardinality(); boolean containsZero = chars.get(0); // Compute the hash table. char[] table = new char[chooseTableSize(size)]; int mask = table.length - 1; for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) { // Compute the filter at the same time. filter |= 1L << c; int index = smear(c) & mask; while (true) { // Check for empty. if (table[index] == 0) { table[index] = (char) c; break; } // Linear probing. index = (index + 1) & mask; } } return new SmallCharMatcher(table, filter, containsZero, description); }
@Override protected void merge(ArrayState in1, ArrayState in2, ArrayState out) { out.active.clear(); out.active.or(in1.active); out.active.or(in2.active); BitSet in2_excl = (BitSet) in2.active.clone(); in2_excl.andNot(in1.active); for (int i = in1.active.nextSetBit(0); i >= 0; i = in1.active.nextSetBit(i + 1)) { if (in1.state[i] == null) { out.state[i] = null; } else if (in2.active.get(i)) { if (in2.state[i] == null) { out.state[i] = null; } else { out.state[i] = mergeTypeStates(in1.state[i], in2.state[i]); } } else { out.state[i] = in1.state[i]; } } for (int i = in2_excl.nextSetBit(0); i >= 0; i = in2_excl.nextSetBit(i + 1)) { out.state[i] = in2.state[i]; } }
private void setPostRegisterTypeAndPropagateChanges(AnalyzedInstruction analyzedInstruction, int registerNumber, RegisterType registerType) { BitSet changedInstructions = new BitSet(instructions.size()); for (int instructionIndex=changedInstructions.nextSetBit(0); instructionIndex>=0; instructionIndex=changedInstructions.nextSetBit(instructionIndex+1)) { changedInstructions.clear(instructionIndex);
protected Object calcSelectValue(BitSet types, ParameterContext paramContext) { if (selectValue instanceof String && selectValue.toString().startsWith("$")) { BitSet mask = tagRuleMask.get(selectValue.toString().substring(1)); if (mask != null && mask.intersects(types)) { BitSet findBit = new BitSet(mask.length()); findBit.or(mask); findBit.and(types); int value = findBit.nextSetBit(0); return parseValueFromTag(value, selectType); } } else if (selectValue instanceof String && selectValue.toString().startsWith(":")) { String p = ((String) selectValue).substring(1); if (paramContext != null && paramContext.vars.containsKey(p)) { selectValue = parseValue(paramContext.vars.get(p), selectType); } else { return null; } } return selectValue; }
public boolean doOneRound (int[] bestTimes, int[] bestNonTransferTimes, int[] previousPatterns, boolean useFrequencies) { stopsTouched.clear(); // clear any stops left over from previous round. PATTERNS: for (int p = patternsTouched.nextSetBit(0); p >= 0; p = patternsTouched.nextSetBit(p+1)) { bestNonTransferTimes[stopIndex] = remainOnBoardTime; stopsTouched.set(stopIndex); allStopsTouched.set(stopIndex); bestNonTransferTimes[stopIndex] = arrivalTime; stopsTouched.set(stopIndex); allStopsTouched.set(stopIndex);
BitSet availablePieces = peer.getAvailablePieces(); for (int i = availablePieces.nextSetBit(0); i >= 0; i = availablePieces.nextSetBit(i + 1)) { this.pieces[i].noLongerAt(peer); if (requested != null) { for (Piece piece : requested) { this.requestedPieces.set(piece.getIndex(), false); new Object[]{ peer, availablePieces.cardinality(), this.completedPieces.cardinality(), this.pieces.length }); logger.trace("We now have {} piece(s) and {} outstanding request(s): {}", new Object[]{ this.completedPieces.cardinality(), this.requestedPieces.cardinality(), this.requestedPieces
public BitSet getTransitiveOutputSet(int input) { BitSet visited = new BitSet(); BitSet result = new BitSet(); LinkedList<Integer> workList = new LinkedList<>(); workList.addLast(input); while (!workList.isEmpty()) { Integer valueNumber = workList.removeFirst(); visited.set(valueNumber); BitSet outputSet = getOutputSet(valueNumber); result.or(outputSet); for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) { if (!visited.get(i)) { workList.addLast(i); } } } return result; }
public ConstantPool(DataInputStream in) throws IOException { int size = in.readUnsignedShort(); pool = new ArrayList<>(size); BitSet[] nextPass = {new BitSet(size), new BitSet(size), new BitSet(size)}; case CodeConstants.CONSTANT_MethodType: pool.add(new PrimitiveConstant(tag, in.readUnsignedShort())); nextPass[0].set(i); break; nextPass[0].set(i); break; case CodeConstants.CONSTANT_InvokeDynamic: pool.add(new LinkConstant(tag, in.readUnsignedShort(), in.readUnsignedShort())); nextPass[1].set(i); break; while ((idx = pass.nextSetBit(idx + 1)) > 0) { pool.get(idx).resolveConstant(this);
DexStmtNode p = stack.pop(); int index = p.__index; if (!access.get(index)) { access.set(index); } else { continue; if (handlers.get(index)) { Local ex = newLocal(); emit(Stmts.nIdentity(ex, Exprs.nExceptionRef("Ljava/lang/Throwable;"))); for (int i = ex.nextSetBit(0); i >= 0; i = ex.nextSetBit(i + 1)) { merge(frame, i); stack.push(insnList.get(i));
if (bits.get(fromIndex)) { return singletonList(universe[fromIndex]); int i = bits.nextSetBit(fromIndex); if (i < 0 || i >= toIndex) { return emptyList(); break; i = bits.nextSetBit(i + 1); if (i < 0 || i >= toIndex) { break;
static CharMatcher from(BitSet chars, String description) { // Compute the filter. long filter = 0; int size = chars.cardinality(); boolean containsZero = chars.get(0); // Compute the hash table. char[] table = new char[chooseTableSize(size)]; int mask = table.length - 1; for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) { // Compute the filter at the same time. filter |= 1L << c; int index = smear(c) & mask; while (true) { // Check for empty. if (table[index] == 0) { table[index] = (char) c; break; } // Linear probing. index = (index + 1) & mask; } } return new SmallCharMatcher(table, filter, containsZero, description); }
void enhanceViaMergeTree() { values = new HashMap<>(); for (Entry<Integer, ValueInfo> entry : observedValues.entrySet()) { BitSet outputSet = vna.getMergeTree().getTransitiveOutputSet(entry.getKey()); outputSet.set(entry.getKey()); entry.getValue().origValues = outputSet; for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) { Set<ValueInfo> list = values.get(i); if(list == null) { list = new HashSet<>(); values.put(i, list); } list.add(entry.getValue()); } } }
/** * Remove exception handlers from block nodes bitset */ public static void cleanBitSet(MethodNode mth, BitSet bs) { for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { BlockNode block = mth.getBasicBlocks().get(i); if (isBlockMustBeCleared(block)) { bs.clear(i); } } }