/** * * @param sources old register set * @return new mapped register set, or old if nothing has changed. */ public final RegisterSpecSet map(RegisterSpecSet sources) { int sz = sources.getMaxSize(); RegisterSpecSet newSources = new RegisterSpecSet(getNewRegisterCount()); for (int i = 0; i < sz; i++) { RegisterSpec registerSpec = sources.get(i); if (registerSpec != null) { newSources.put(map(registerSpec)); } } newSources.setImmutable(); // Return the old sources if nothing has changed. return newSources.equals(sources) ? sources : newSources; } }
/** * Returns an instance that is identical to this one, except that * all register numbers are offset by the given amount. Mutability * of the result is inherited from the original. * * @param delta the amount to offset the register numbers by * @return {@code non-null;} an appropriately-constructed instance */ public RegisterSpecSet withOffset(int delta) { int len = specs.length; RegisterSpecSet result = new RegisterSpecSet(len + delta); for (int i = 0; i < len; i++) { RegisterSpec spec = specs[i]; if (spec != null) { result.put(spec.withOffset(delta)); } } result.size = size; if (isImmutable()) { result.setImmutable(); } return result; }
/** * Gets a mutable copy of the register set associated with the * start of the block with the given index. This returns a * newly-allocated empty {@link RegisterSpecSet} of appropriate * max size if there is not yet any set associated with the block. * * @param index {@code >= 0;} the block index * @return {@code non-null;} the associated register set */ public RegisterSpecSet mutableCopyOfStarts(int index) { RegisterSpecSet result = getStarts0(index); return (result != null) ? result.mutableCopy() : new RegisterSpecSet(regCount); }
/** * Put the entire contents of the given set into this one. * * @param set {@code non-null;} the set to put into this instance */ public void putAll(RegisterSpecSet set) { int max = set.getMaxSize(); for (int i = 0; i < max; i++) { RegisterSpec spec = set.get(i); if (spec != null) { put(spec); } } }
/** * Makes and return a mutable copy of this instance. * * @return {@code non-null;} the mutable copy */ public RegisterSpecSet mutableCopy() { int len = specs.length; RegisterSpecSet copy = new RegisterSpecSet(len); for (int i = 0; i < len; i++) { RegisterSpec spec = specs[i]; if (spec != null) { copy.put(spec); } } copy.size = size; return copy; } }
if (canThrowDuringLastInsn && (i == freezeSecondaryStateAt)) { primaryState.setImmutable(); primaryState = primaryState.mutableCopy(); if (result != null && primaryState.get(result.getReg()) != null) { primaryState.remove(primaryState.get(result.getReg())); RegisterSpec already = primaryState.get(result); = primaryState.localItemToSpec(result.getLocalItem()); primaryState.remove(previous); primaryState.put(result); primaryState.setImmutable();
RegisterSpecSet newStart = start.mutableCopy(); if (start.size() != 0) { newStart.intersect(specs, true); } else { newStart = specs.mutableCopy(); if (start.equals(newStart)) { return false; newStart.setImmutable(); setStarts(label, newStart);
/** {@inheritDoc} */ @Override protected String listingString0(boolean noteIndices) { int sz = locals.size(); int max = locals.getMaxSize(); StringBuffer sb = new StringBuffer(100 + sz * 40); sb.append("local-snapshot"); for (int i = 0; i < max; i++) { RegisterSpec spec = locals.get(i); if (spec != null) { sb.append("\n "); sb.append(LocalStart.localString(spec)); } } return sb.toString(); }
aboutToProcess(address, regNum); RegisterSpec existingLocal = regs.get(regNum); RegisterSpec movedLocal = regs.findMatchingLocal(startedLocal); if (movedLocal != null) { regs.put(startedLocal); endIndices[regNum] = -1; return; RegisterSpec justBelow = regs.get(regNum - 1); if ((justBelow != null) && justBelow.isCategory2()) { addOrUpdateEnd(address, RegisterSpec justAbove = regs.get(regNum + 1); if (justAbove != null) { addOrUpdateEnd(address,
/** * Gets the element with the same register number as the given * spec, if any. This is just a convenient shorthand for * {@code get(spec.getReg())}. * * @param spec {@code non-null;} spec with the desired register number * @return {@code null-ok;} the element with the matching register number or * {@code null} if there is none */ public RegisterSpec get(RegisterSpec spec) { return get(spec.getReg()); }
/** * Constructs an instance. * * @param method {@code non-null;} the method being represented by this instance */ public LocalVariableInfo(SsaMethod method) { if (method == null) { throw new NullPointerException("method == null"); } List<SsaBasicBlock> blocks = method.getBlocks(); this.regCount = method.getRegCount(); this.emptySet = new RegisterSpecSet(regCount); this.blockStarts = new RegisterSpecSet[blocks.size()]; this.insnAssignments = new HashMap<SsaInsn, RegisterSpec>(/*hint here*/); emptySet.setImmutable(); }
if (canThrowDuringLastInsn && (i == freezeSecondaryStateAt)) { primaryState.setImmutable(); primaryState = primaryState.mutableCopy(); if (result != null && primaryState.get(result.getReg()) != null) { primaryState.remove(primaryState.get(result.getReg())); RegisterSpec already = primaryState.get(result); = primaryState.localItemToSpec(result.getLocalItem()); primaryState.remove(previous); primaryState.put(result); primaryState.setImmutable();
RegisterSpecSet newStart = start.mutableCopy(); if (start.size() != 0) { newStart.intersect(specs, true); } else { newStart = specs.mutableCopy(); if (start.equals(newStart)) { return false; newStart.setImmutable(); setStarts(label, newStart);
/** * Put the entire contents of the given set into this one. * * @param set {@code non-null;} the set to put into this instance */ public void putAll(RegisterSpecSet set) { int max = set.getMaxSize(); for (int i = 0; i < max; i++) { RegisterSpec spec = set.get(i); if (spec != null) { put(spec); } } }
/** {@inheritDoc} */ @Override protected String listingString0(boolean noteIndices) { int sz = locals.size(); int max = locals.getMaxSize(); StringBuffer sb = new StringBuffer(100 + sz * 40); sb.append("local-snapshot"); for (int i = 0; i < max; i++) { RegisterSpec spec = locals.get(i); if (spec != null) { sb.append("\n "); sb.append(LocalStart.localString(spec)); } } return sb.toString(); }
aboutToProcess(address, regNum); RegisterSpec existingLocal = regs.get(regNum); RegisterSpec movedLocal = regs.findMatchingLocal(startedLocal); if (movedLocal != null) { regs.put(startedLocal); endIndices[regNum] = -1; return; RegisterSpec justBelow = regs.get(regNum - 1); if ((justBelow != null) && justBelow.isCategory2()) { addOrUpdateEnd(address, RegisterSpec justAbove = regs.get(regNum + 1); if (justAbove != null) { addOrUpdateEnd(address,
/** * Makes and return a mutable copy of this instance. * * @return {@code non-null;} the mutable copy */ public RegisterSpecSet mutableCopy() { int len = specs.length; RegisterSpecSet copy = new RegisterSpecSet(len); for (int i = 0; i < len; i++) { RegisterSpec spec = specs[i]; if (spec != null) { copy.put(spec); } } copy.size = size; return copy; } }
/** * Gets the element with the same register number as the given * spec, if any. This is just a convenient shorthand for * {@code get(spec.getReg())}. * * @param spec {@code non-null;} spec with the desired register number * @return {@code null-ok;} the element with the matching register number or * {@code null} if there is none */ public RegisterSpec get(RegisterSpec spec) { return get(spec.getReg()); }
/** * Constructs an instance. * * @param method {@code non-null;} the method being represented by this instance */ public LocalVariableInfo(SsaMethod method) { if (method == null) { throw new NullPointerException("method == null"); } List<SsaBasicBlock> blocks = method.getBlocks(); this.regCount = method.getRegCount(); this.emptySet = new RegisterSpecSet(regCount); this.blockStarts = new RegisterSpecSet[blocks.size()]; this.insnAssignments = new HashMap<SsaInsn, RegisterSpec>(/*hint here*/); emptySet.setImmutable(); }
if (canThrowDuringLastInsn && (i == freezeSecondaryStateAt)) { primaryState.setImmutable(); primaryState = primaryState.mutableCopy(); if (result != null && primaryState.get(result.getReg()) != null) { primaryState.remove(primaryState.get(result.getReg())); RegisterSpec already = primaryState.get(result); = primaryState.localItemToSpec(result.getLocalItem()); primaryState.remove(previous); primaryState.put(result); primaryState.setImmutable();