use of com.taobao.android.dx.util.BitIntSet in project atlas by alibaba.
the class InterferenceRegisterMapper method addInterfence.
/**
* 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));
}
use of com.taobao.android.dx.util.BitIntSet in project atlas by alibaba.
the class FirstFitAllocator method allocateRegisters.
/** {@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;
}
Aggregations