/** * Constructs an instance. This method is private. Use {@link #extract}. * * @param method {@code non-null;} the method to extract from */ private LocalVariableExtractor(SsaMethod method) { if (method == null) { throw new NullPointerException("method == null"); } ArrayList<SsaBasicBlock> blocks = method.getBlocks(); this.method = method; this.blocks = blocks; this.resultInfo = new LocalVariableInfo(method); this.workSet = new BitSet(blocks.size()); }
/** * Gets the register set associated with the start of the given * block. This is just convenient shorthand for * {@code getStarts(block.getLabel())}. * * @param block {@code non-null;} the block in question * @return {@code non-null;} the associated register set */ public RegisterSpecSet getStarts(SsaBasicBlock block) { return getStarts(block.getIndex()); }
/** * Gets the register set associated with the start of the block * with the given index. This returns an empty set with the appropriate * max size if no set was associated with the block in question. * * @param index {@code >= 0;} the block index * @return {@code non-null;} the associated register set */ public RegisterSpecSet getStarts(int index) { RegisterSpecSet result = getStarts0(index); return (result != null) ? result : emptySet; }
= resultInfo.mutableCopyOfStarts(blockIndex); SsaBasicBlock block = blocks.get(blockIndex); List<SsaInsn> insns = block.getInsns(); resultInfo.addAssignment(insn, result); primaryState.put(result); primaryState : secondaryState; if (resultInfo.mergeStarts(succ, state)) { workSet.set(succ);
/** * Merges the given register set into the set for the block with the * given index. If there was not already an associated set, then this * is the same as calling {@link #setStarts}. Otherwise, this will * merge the two sets and call {@link #setStarts} on the result of the * merge. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to merge into the start set * for the block * @return {@code true} if the merge resulted in an actual change * to the associated set (including storing one for the first time) or * {@code false} if there was no change */ public boolean mergeStarts(int index, RegisterSpecSet specs) { RegisterSpecSet start = getStarts0(index); if (start == null) { setStarts(index, specs); return true; } RegisterSpecSet newStart = start.mutableCopy(); newStart.intersect(specs, true); if (start.equals(newStart)) { return false; } newStart.setImmutable(); setStarts(index, newStart); return true; }
/** * Sets the register set associated with the start of the block with * the given index. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to associate with the block */ public void setStarts(int index, RegisterSpecSet specs) { throwIfImmutable(); if (specs == null) { throw new NullPointerException("specs == null"); } try { blockStarts[index] = specs; } catch (ArrayIndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("bogus index"); } }
/** * Does the extraction. * * @return {@code non-null;} the extracted information */ private LocalVariableInfo doit() { //FIXME why is this needed here? if (method.getRegCount() > 0 ) { for (int bi = method.getEntryBlockIndex(); bi >= 0; bi = workSet.nextSetBit(0)) { workSet.clear(bi); processBlock(bi); } } resultInfo.setImmutable(); return resultInfo; }
= resultInfo.mutableCopyOfStarts(blockIndex); SsaBasicBlock block = blocks.get(blockIndex); List<SsaInsn> insns = block.getInsns(); resultInfo.addAssignment(insn, result); primaryState.put(result); primaryState : secondaryState; if (resultInfo.mergeStarts(succ, state)) { workSet.set(succ);
/** * Merges the given register set into the set for the block with the * given index. If there was not already an associated set, then this * is the same as calling {@link #setStarts}. Otherwise, this will * merge the two sets and call {@link #setStarts} on the result of the * merge. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to merge into the start set * for the block * @return {@code true} if the merge resulted in an actual change * to the associated set (including storing one for the first time) or * {@code false} if there was no change */ public boolean mergeStarts(int index, RegisterSpecSet specs) { RegisterSpecSet start = getStarts0(index); boolean changed = false; if (start == null) { setStarts(index, specs); return true; } RegisterSpecSet newStart = start.mutableCopy(); newStart.intersect(specs, true); if (start.equals(newStart)) { return false; } newStart.setImmutable(); setStarts(index, newStart); return true; }
/** * Sets the register set associated with the start of the block with * the given index. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to associate with the block */ public void setStarts(int index, RegisterSpecSet specs) { throwIfImmutable(); if (specs == null) { throw new NullPointerException("specs == null"); } try { blockStarts[index] = specs; } catch (ArrayIndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("bogus index"); } }
/** * Does the extraction. * * @return {@code non-null;} the extracted information */ private LocalVariableInfo doit() { //FIXME why is this needed here? if (method.getRegCount() > 0 ) { for (int bi = method.getEntryBlockIndex(); bi >= 0; bi = workSet.nextSetBit(0)) { workSet.clear(bi); processBlock(bi); } } resultInfo.setImmutable(); return resultInfo; }
= resultInfo.mutableCopyOfStarts(blockIndex); SsaBasicBlock block = blocks.get(blockIndex); List<SsaInsn> insns = block.getInsns(); resultInfo.addAssignment(insn, result); primaryState.put(result); primaryState : secondaryState; if (resultInfo.mergeStarts(succ, state)) { workSet.set(succ);
/** * Merges the given register set into the set for the block with the * given index. If there was not already an associated set, then this * is the same as calling {@link #setStarts}. Otherwise, this will * merge the two sets and call {@link #setStarts} on the result of the * merge. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to merge into the start set * for the block * @return {@code true} if the merge resulted in an actual change * to the associated set (including storing one for the first time) or * {@code false} if there was no change */ public boolean mergeStarts(int index, RegisterSpecSet specs) { RegisterSpecSet start = getStarts0(index); boolean changed = false; if (start == null) { setStarts(index, specs); return true; } RegisterSpecSet newStart = start.mutableCopy(); newStart.intersect(specs, true); if (start.equals(newStart)) { return false; } newStart.setImmutable(); setStarts(index, newStart); return true; }
/** * Gets the register set associated with the start of the block * with the given index. This returns an empty set with the appropriate * max size if no set was associated with the block in question. * * @param index {@code >= 0;} the block index * @return {@code non-null;} the associated register set */ public RegisterSpecSet getStarts(int index) { RegisterSpecSet result = getStarts0(index); return (result != null) ? result : emptySet; }
/** * Sets the register set associated with the start of the block with * the given index. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to associate with the block */ public void setStarts(int index, RegisterSpecSet specs) { throwIfImmutable(); if (specs == null) { throw new NullPointerException("specs == null"); } try { blockStarts[index] = specs; } catch (ArrayIndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("bogus index"); } }
/** * Gets the register set associated with the start of the given * block. This is just convenient shorthand for * {@code getStarts(block.getLabel())}. * * @param block {@code non-null;} the block in question * @return {@code non-null;} the associated register set */ public RegisterSpecSet getStarts(SsaBasicBlock block) { return getStarts(block.getIndex()); }
/** * Constructs an instance. This method is private. Use {@link #extract}. * * @param method {@code non-null;} the method to extract from */ private LocalVariableExtractor(SsaMethod method) { if (method == null) { throw new NullPointerException("method == null"); } ArrayList<SsaBasicBlock> blocks = method.getBlocks(); this.method = method; this.blocks = blocks; this.resultInfo = new LocalVariableInfo(method); this.workSet = new BitSet(blocks.size()); }
/** * Does the extraction. * * @return {@code non-null;} the extracted information */ private LocalVariableInfo doit() { //FIXME why is this needed here? if (method.getRegCount() > 0 ) { for (int bi = method.getEntryBlockIndex(); bi >= 0; bi = workSet.nextSetBit(0)) { workSet.clear(bi); processBlock(bi); } } resultInfo.setImmutable(); return resultInfo; }
= resultInfo.mutableCopyOfStarts(blockIndex); SsaBasicBlock block = blocks.get(blockIndex); List<SsaInsn> insns = block.getInsns(); resultInfo.addAssignment(insn, result); primaryState.put(result); primaryState : secondaryState; if (resultInfo.mergeStarts(succ, state)) { workSet.set(succ);
/** * Merges the given register set into the set for the block with the * given index. If there was not already an associated set, then this * is the same as calling {@link #setStarts}. Otherwise, this will * merge the two sets and call {@link #setStarts} on the result of the * merge. * * @param index {@code >= 0;} the block index * @param specs {@code non-null;} the register set to merge into the start set * for the block * @return {@code true} if the merge resulted in an actual change * to the associated set (including storing one for the first time) or * {@code false} if there was no change */ public boolean mergeStarts(int index, RegisterSpecSet specs) { RegisterSpecSet start = getStarts0(index); boolean changed = false; if (start == null) { setStarts(index, specs); return true; } RegisterSpecSet newStart = start.mutableCopy(); newStart.intersect(specs, true); if (start.equals(newStart)) { return false; } newStart.setImmutable(); setStarts(index, newStart); return true; }