com.android.dx.util.BitIntSet Java Examples

The following examples show how to use com.android.dx.util.BitIntSet. 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: InterferenceRegisterMapper.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a register's interference set to the interference list,
 * growing it if necessary.
 *
 * @param newReg register in new namespace
 * @param oldReg register in old namespace
 */
private void addInterfence(int newReg, int oldReg) {
    newRegInterference.ensureCapacity(newReg + 1);

    while (newReg >= newRegInterference.size()) {
        newRegInterference.add(new BitIntSet(newReg +1));
    }

    oldRegInterference.mergeInterferenceSet(
            oldReg, newRegInterference.get(newReg));
}
 
Example #2
Source File: InterferenceRegisterMapper.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance
 *
 * @param countOldRegisters number of registers in old namespace
 */
public InterferenceRegisterMapper(InterferenceGraph oldRegInterference,
        int countOldRegisters) {
    super(countOldRegisters);

    newRegInterference = new ArrayList<BitIntSet>();
    this.oldRegInterference = oldRegInterference;
}
 
Example #3
Source File: InterferenceRegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance
 *
 * @param countOldRegisters number of registers in old namespace
 */
public InterferenceRegisterMapper(InterferenceGraph oldRegInterference,
        int countOldRegisters) {
    super(countOldRegisters);

    newRegInterference = new ArrayList<BitIntSet>();
    this.oldRegInterference = oldRegInterference;
}
 
Example #4
Source File: InterferenceRegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a register's interference set to the interference list,
 * growing it if necessary.
 *
 * @param newReg register in new namespace
 * @param oldReg register in old namespace
 */
private void addInterfence(int newReg, int oldReg) {
    newRegInterference.ensureCapacity(newReg + 1);

    while (newReg >= newRegInterference.size()) {
        newRegInterference.add(new BitIntSet(newReg +1));
    }

    oldRegInterference.mergeInterferenceSet(
            oldReg, newRegInterference.get(newReg));
}
 
Example #5
Source File: InterferenceRegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance
 *
 * @param countOldRegisters number of registers in old namespace
 */
public InterferenceRegisterMapper(InterferenceGraph oldRegInterference,
        int countOldRegisters) {
    super(countOldRegisters);

    newRegInterference = new ArrayList<BitIntSet>();
    this.oldRegInterference = oldRegInterference;
}
 
Example #6
Source File: InterferenceRegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a register's interference set to the interference list,
 * growing it if necessary.
 *
 * @param newReg register in new namespace
 * @param oldReg register in old namespace
 */
private void addInterfence(int newReg, int oldReg) {
    newRegInterference.ensureCapacity(newReg + 1);

    while (newReg >= newRegInterference.size()) {
        newRegInterference.add(new BitIntSet(newReg +1));
    }

    oldRegInterference.mergeInterferenceSet(
            oldReg, newRegInterference.get(newReg));
}
 
Example #7
Source File: InterferenceRegisterMapper.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a register's interference set to the interference list,
 * growing it if necessary.
 *
 * @param newReg register in new namespace
 * @param oldReg register in old namespace
 */
private void addInterfence(int newReg, int oldReg) {
    newRegInterference.ensureCapacity(newReg + 1);

    while (newReg >= newRegInterference.size()) {
        newRegInterference.add(new BitIntSet(newReg +1));
    }

    oldRegInterference.mergeInterferenceSet(
            oldReg, newRegInterference.get(newReg));
}
 
Example #8
Source File: InterferenceRegisterMapper.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance
 *
 * @param countOldRegisters number of registers in old namespace
 */
public InterferenceRegisterMapper(InterferenceGraph oldRegInterference,
        int countOldRegisters) {
    super(countOldRegisters);

    newRegInterference = new ArrayList<BitIntSet>();
    this.oldRegInterference = oldRegInterference;
}
 
Example #9
Source File: FirstFitAllocator.java    From Box with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
    int oldRegCount = ssaMeth.getRegCount();

    BasicRegisterMapper mapper
            = new BasicRegisterMapper(oldRegCount);

    int nextNewRegister = 0;

    if (PRESLOT_PARAMS) {
        /*
         * Reserve space for the params at the bottom of the register
         * space. Later, we'll flip the params to the end of the register
         * space.
         */

        nextNewRegister = ssaMeth.getParamWidth();
    }

    for (int i = 0; i < oldRegCount; i++) {
        if (mapped.get(i)) {
            // we already got this one
            continue;
        }

        int maxCategory = getCategoryForSsaReg(i);
        IntSet current = new BitIntSet(oldRegCount);

        interference.mergeInterferenceSet(i, current);

        boolean isPreslotted = false;
        int newReg = 0;

        if (PRESLOT_PARAMS && isDefinitionMoveParam(i)) {
            // Any move-param definition must be a NormalSsaInsn
            NormalSsaInsn defInsn = (NormalSsaInsn)
                   ssaMeth.getDefinitionForRegister(i);

            newReg = paramNumberFromMoveParam(defInsn);

            mapper.addMapping(i, newReg, maxCategory);
            isPreslotted = true;
        } else {
            mapper.addMapping(i, nextNewRegister, maxCategory);
            newReg = nextNewRegister;
        }

        for (int j = i + 1; j < oldRegCount; j++) {
            if (mapped.get(j) || isDefinitionMoveParam(j)) {
                continue;
            }

            /*
             * If reg j doesn't interfere with the current mapping.
             * Also, if this is a pre-slotted method parameter, we
             * can't use more than the original param width.
             */
            if (!current.has(j)
                    && !(isPreslotted
                        && (maxCategory < getCategoryForSsaReg(j)))) {

                interference.mergeInterferenceSet(j, current);

                maxCategory = Math.max(maxCategory,
                        getCategoryForSsaReg(j));

                mapper.addMapping(j, newReg, maxCategory);
                mapped.set(j);
            }
        }

        mapped.set(i);
        if (!isPreslotted) {
            nextNewRegister += maxCategory;
        }
    }

    return mapper;
}
 
Example #10
Source File: FirstFitAllocator.java    From buck with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
    int oldRegCount = ssaMeth.getRegCount();

    BasicRegisterMapper mapper
            = new BasicRegisterMapper(oldRegCount);

    int nextNewRegister = 0;

    if (PRESLOT_PARAMS) {
        /*
         * Reserve space for the params at the bottom of the register
         * space. Later, we'll flip the params to the end of the register
         * space.
         */

        nextNewRegister = ssaMeth.getParamWidth();
    }

    for (int i = 0; i < oldRegCount; i++) {
        if (mapped.get(i)) {
            // we already got this one
            continue;
        }

        int maxCategory = getCategoryForSsaReg(i);
        IntSet current = new BitIntSet(oldRegCount);

        interference.mergeInterferenceSet(i, current);

        boolean isPreslotted = false;
        int newReg = 0;

        if (PRESLOT_PARAMS && isDefinitionMoveParam(i)) {
            // Any move-param definition must be a NormalSsaInsn
            NormalSsaInsn defInsn = (NormalSsaInsn)
                   ssaMeth.getDefinitionForRegister(i);

            newReg = paramNumberFromMoveParam(defInsn);

            mapper.addMapping(i, newReg, maxCategory);
            isPreslotted = true;
        } else {
            mapper.addMapping(i, nextNewRegister, maxCategory);
            newReg = nextNewRegister;
        }

        for (int j = i + 1; j < oldRegCount; j++) {
            if (mapped.get(j) || isDefinitionMoveParam(j)) {
                continue;
            }

            /*
             * If reg j doesn't interfere with the current mapping.
             * Also, if this is a pre-slotted method parameter, we
             * can't use more than the original param width.
             */
            if (!current.has(j)
                    && !(isPreslotted
                        && (maxCategory < getCategoryForSsaReg(j)))) {

                interference.mergeInterferenceSet(j, current);

                maxCategory = Math.max(maxCategory,
                        getCategoryForSsaReg(j));

                mapper.addMapping(j, newReg, maxCategory);
                mapped.set(j);
            }
        }

        mapped.set(i);
        if (!isPreslotted) {
            nextNewRegister += maxCategory;
        }
    }

    return mapper;
}
 
Example #11
Source File: FirstFitAllocator.java    From Box with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
    int oldRegCount = ssaMeth.getRegCount();

    BasicRegisterMapper mapper
            = new BasicRegisterMapper(oldRegCount);

    int nextNewRegister = 0;

    if (PRESLOT_PARAMS) {
        /*
         * Reserve space for the params at the bottom of the register
         * space. Later, we'll flip the params to the end of the register
         * space.
         */

        nextNewRegister = ssaMeth.getParamWidth();
    }

    for (int i = 0; i < oldRegCount; i++) {
        if (mapped.get(i)) {
            // we already got this one
            continue;
        }

        int maxCategory = getCategoryForSsaReg(i);
        IntSet current = new BitIntSet(oldRegCount);

        interference.mergeInterferenceSet(i, current);

        boolean isPreslotted = false;
        int newReg = 0;

        if (PRESLOT_PARAMS && isDefinitionMoveParam(i)) {
            // Any move-param definition must be a NormalSsaInsn
            NormalSsaInsn defInsn = (NormalSsaInsn)
                   ssaMeth.getDefinitionForRegister(i);

            newReg = paramNumberFromMoveParam(defInsn);

            mapper.addMapping(i, newReg, maxCategory);
            isPreslotted = true;
        } else {
            mapper.addMapping(i, nextNewRegister, maxCategory);
            newReg = nextNewRegister;
        }

        for (int j = i + 1; j < oldRegCount; j++) {
            if (mapped.get(j) || isDefinitionMoveParam(j)) {
                continue;
            }

            /*
             * If reg j doesn't interfere with the current mapping.
             * Also, if this is a pre-slotted method parameter, we
             * can't use more than the original param width.
             */
            if (!current.has(j)
                    && !(isPreslotted
                        && (maxCategory < getCategoryForSsaReg(j)))) {

                interference.mergeInterferenceSet(j, current);

                maxCategory = Math.max(maxCategory,
                        getCategoryForSsaReg(j));

                mapper.addMapping(j, newReg, maxCategory);
                mapped.set(j);
            }
        }

        mapped.set(i);
        if (!isPreslotted) {
            nextNewRegister += maxCategory;
        }
    }

    return mapper;
}
 
Example #12
Source File: FirstFitAllocator.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
    int oldRegCount = ssaMeth.getRegCount();

    BasicRegisterMapper mapper
            = new BasicRegisterMapper(oldRegCount);

    int nextNewRegister = 0;

    if (PRESLOT_PARAMS) {
        /*
         * Reserve space for the params at the bottom of the register
         * space. Later, we'll flip the params to the end of the register
         * space.
         */

        nextNewRegister = ssaMeth.getParamWidth();
    }

    for (int i = 0; i < oldRegCount; i++) {
        if (mapped.get(i)) {
            // we already got this one
            continue;
        }

        int maxCategory = getCategoryForSsaReg(i);
        IntSet current = new BitIntSet(oldRegCount);

        interference.mergeInterferenceSet(i, current);

        boolean isPreslotted = false;
        int newReg = 0;

        if (PRESLOT_PARAMS && isDefinitionMoveParam(i)) {
            // Any move-param definition must be a NormalSsaInsn
            NormalSsaInsn defInsn = (NormalSsaInsn)
                   ssaMeth.getDefinitionForRegister(i);

            newReg = paramNumberFromMoveParam(defInsn);

            mapper.addMapping(i, newReg, maxCategory);
            isPreslotted = true;
        } else {
            mapper.addMapping(i, nextNewRegister, maxCategory);
            newReg = nextNewRegister;
        }

        for (int j = i + 1; j < oldRegCount; j++) {
            if (mapped.get(j) || isDefinitionMoveParam(j)) {
                continue;
            }

            /*
             * If reg j doesn't interfere with the current mapping.
             * Also, if this is a pre-slotted method parameter, we
             * can't use more than the original param width.
             */
            if (!current.has(j)
                    && !(isPreslotted
                        && (maxCategory < getCategoryForSsaReg(j)))) {

                interference.mergeInterferenceSet(j, current);

                maxCategory = Math.max(maxCategory,
                        getCategoryForSsaReg(j));

                mapper.addMapping(j, newReg, maxCategory);
                mapped.set(j);
            }
        }

        mapped.set(i);
        if (!isPreslotted) {
            nextNewRegister += maxCategory;
        }
    }

    return mapper;
}
 
Example #13
Source File: SetFactory.java    From J2ME-Loader with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the dominance-frontier sets.
 *
 * @param szBlocks {@code >=0;} count of basic blocks in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeDomFrontSet(int szBlocks) {
    return szBlocks <= DOMFRONT_SET_THRESHOLD_SIZE
            ? new BitIntSet(szBlocks)
            : new ListIntSet();
}
 
Example #14
Source File: SetFactory.java    From buck with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for register live in/out sets.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeLivenessSet(int countRegs) {
    return countRegs <= LIVENESS_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #15
Source File: SetFactory.java    From buck with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the interference graph sets. Public because
 * InterferenceGraph is in another package.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
public static IntSet makeInterferenceSet(int countRegs) {
    return countRegs <= INTERFERENCE_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #16
Source File: SetFactory.java    From buck with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the dominance-frontier sets.
 *
 * @param szBlocks {@code >=0;} count of basic blocks in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeDomFrontSet(int szBlocks) {
    return szBlocks <= DOMFRONT_SET_THRESHOLD_SIZE
            ? new BitIntSet(szBlocks)
            : new ListIntSet();
}
 
Example #17
Source File: SetFactory.java    From J2ME-Loader with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for register live in/out sets.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeLivenessSet(int countRegs) {
    return countRegs <= LIVENESS_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #18
Source File: SetFactory.java    From J2ME-Loader with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the interference graph sets. Public because
 * InterferenceGraph is in another package.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
public static IntSet makeInterferenceSet(int countRegs) {
    return countRegs <= INTERFERENCE_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #19
Source File: SetFactory.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the dominance-frontier sets.
 *
 * @param szBlocks {@code >=0;} count of basic blocks in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeDomFrontSet(int szBlocks) {
    return szBlocks <= DOMFRONT_SET_THRESHOLD_SIZE
            ? new BitIntSet(szBlocks)
            : new ListIntSet();
}
 
Example #20
Source File: SetFactory.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for register live in/out sets.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeLivenessSet(int countRegs) {
    return countRegs <= LIVENESS_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #21
Source File: SetFactory.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the interference graph sets. Public because
 * InterferenceGraph is in another package.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
public static IntSet makeInterferenceSet(int countRegs) {
    return countRegs <= INTERFERENCE_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #22
Source File: SetFactory.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the dominance-frontier sets.
 *
 * @param szBlocks {@code >=0;} count of basic blocks in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeDomFrontSet(int szBlocks) {
    return szBlocks <= DOMFRONT_SET_THRESHOLD_SIZE
            ? new BitIntSet(szBlocks)
            : new ListIntSet();
}
 
Example #23
Source File: SetFactory.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for register live in/out sets.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
/*package*/ static IntSet makeLivenessSet(int countRegs) {
    return countRegs <= LIVENESS_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}
 
Example #24
Source File: SetFactory.java    From Box with Apache License 2.0 2 votes vote down vote up
/**
 * Make IntSet for the interference graph sets. Public because
 * InterferenceGraph is in another package.
 *
 * @param countRegs {@code >=0;} count of SSA registers used in method
 * @return {@code non-null;} appropriate set
 */
public static IntSet makeInterferenceSet(int countRegs) {
    return countRegs <= INTERFERENCE_SET_THRESHOLD_SIZE
            ? new BitIntSet(countRegs)
            : new ListIntSet();
}