Java Code Examples for com.android.dx.rop.code.RegisterSpecList#set()

The following examples show how to use com.android.dx.rop.code.RegisterSpecList#set() . 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 File: NormalSsaInsn.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 2
Source File: NormalSsaInsn.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 3
Source File: NormalSsaInsn.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 4
Source File: NormalSsaInsn.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 5
Source File: Code.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static RegisterSpecList concatenate(Local<?> first, Local<?>[] rest) {
    int offset = (first != null) ? 1 : 0;
    RegisterSpecList result = new RegisterSpecList(offset + rest.length);
    if (first != null) {
        result.set(0, first.spec());
    }
    for (int i = 0; i < rest.length; i++) {
        result.set(i + offset, rest[i].spec());
    }
    return result;
}
 
Example 6
Source File: FirstFitLocalCombiningAllocator.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 7
Source File: Form35c.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 8
Source File: Code.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
private static RegisterSpecList concatenate(Local<?> first, Local<?>[] rest) {
    int offset = (first != null) ? 1 : 0;
    RegisterSpecList result = new RegisterSpecList(offset + rest.length);
    if (first != null) {
        result.set(0, first.spec());
    }
    for (int i = 0; i < rest.length; i++) {
        result.set(i + offset, rest[i].spec());
    }
    return result;
}
 
Example 9
Source File: FirstFitLocalCombiningAllocator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 10
Source File: RegisterMapper.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}
 
Example 11
Source File: Form35c.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 12
Source File: Form45cc.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 13
Source File: Form45cc.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 14
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 15
Source File: RegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}
 
Example 16
Source File: Form35c.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 17
Source File: Form45cc.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 18
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a bit set of SSA registers into a RegisterSpecList containing
 * the definition specs of all the registers.
 *
 * @param ssaSet {@code non-null;} set of SSA registers
 * @return list of RegisterSpecs as noted above
 */
RegisterSpecList ssaSetToSpecs(IntSet ssaSet) {
    RegisterSpecList result = new RegisterSpecList(ssaSet.elements());

    IntIterator iter = ssaSet.iterator();

    int i = 0;
    while (iter.hasNext()) {
        result.set(i++, getDefinitionSpecForSsaReg(iter.next()));
    }

    return result;
}
 
Example 19
Source File: RegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}
 
Example 20
Source File: Form35c.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}