Java源码示例:com.android.dx.ssa.RegisterMapper
示例1
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
analyzeInstructions();
if (DEBUG) {
printLocalVars();
}
if (DEBUG) System.out.println("--->Mapping local-associated params");
handleLocalAssociatedParams();
if (DEBUG) System.out.println("--->Mapping other params");
handleUnassociatedParameters();
if (DEBUG) System.out.println("--->Mapping invoke-range");
handleInvokeRangeInsns();
if (DEBUG) {
System.out.println("--->Mapping local-associated non-params");
}
handleLocalAssociatedOther();
if (DEBUG) System.out.println("--->Mapping check-cast results");
handleCheckCastResults();
if (DEBUG) System.out.println("--->Mapping phis");
handlePhiInsns();
if (DEBUG) System.out.println("--->Mapping others");
handleNormalUnassociated();
return mapper;
}
示例2
/**
* Performs the conversion.
*
* @return {@code non-null;} rop-form output
*/
private RopMethod convert() {
if (DEBUG) {
interference.dumpToStdout();
}
// These are other allocators for debugging or historical comparison:
// allocator = new NullRegisterAllocator(ssaMeth, interference);
// allocator = new FirstFitAllocator(ssaMeth, interference);
RegisterAllocator allocator =
new FirstFitLocalCombiningAllocator(ssaMeth, interference,
minimizeRegisters);
RegisterMapper mapper = allocator.allocateRegisters();
if (DEBUG) {
System.out.println("Printing reg map");
System.out.println(((BasicRegisterMapper)mapper).toHuman());
}
ssaMeth.setBackMode();
ssaMeth.mapRegisters(mapper);
removePhiFunctions();
if (allocator.wantsParamsMovedHigh()) {
moveParametersToHighRegisters();
}
removeEmptyGotos();
RopMethod ropMethod = new RopMethod(convertBasicBlocks(),
ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex()));
ropMethod = new IdenticalBlockCombiner(ropMethod).process();
return ropMethod;
}
示例3
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
int oldRegCount = ssaMeth.getRegCount();
BasicRegisterMapper mapper = new BasicRegisterMapper(oldRegCount);
for (int i = 0; i < oldRegCount; i++) {
mapper.addMapping(i, i*2, 2);
}
return mapper;
}
示例4
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
analyzeInstructions();
if (DEBUG) {
printLocalVars();
}
if (DEBUG) System.out.println("--->Mapping local-associated params");
handleLocalAssociatedParams();
if (DEBUG) System.out.println("--->Mapping other params");
handleUnassociatedParameters();
if (DEBUG) System.out.println("--->Mapping invoke-range");
handleInvokeRangeInsns();
if (DEBUG) {
System.out.println("--->Mapping local-associated non-params");
}
handleLocalAssociatedOther();
if (DEBUG) System.out.println("--->Mapping check-cast results");
handleCheckCastResults();
if (DEBUG) System.out.println("--->Mapping phis");
handlePhiInsns();
if (DEBUG) System.out.println("--->Mapping others");
handleNormalUnassociated();
return mapper;
}
示例5
/**
* Performs the conversion.
*
* @return {@code non-null;} rop-form output
*/
private RopMethod convert() {
if (DEBUG) {
interference.dumpToStdout();
}
// These are other allocators for debugging or historical comparison:
// allocator = new NullRegisterAllocator(ssaMeth, interference);
// allocator = new FirstFitAllocator(ssaMeth, interference);
RegisterAllocator allocator =
new FirstFitLocalCombiningAllocator(ssaMeth, interference,
minimizeRegisters);
RegisterMapper mapper = allocator.allocateRegisters();
if (DEBUG) {
System.out.println("Printing reg map");
System.out.println(((BasicRegisterMapper)mapper).toHuman());
}
ssaMeth.setBackMode();
ssaMeth.mapRegisters(mapper);
removePhiFunctions();
if (allocator.wantsParamsMovedHigh()) {
moveParametersToHighRegisters();
}
removeEmptyGotos();
RopMethod ropMethod = new RopMethod(convertBasicBlocks(),
ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex()));
ropMethod = new IdenticalBlockCombiner(ropMethod).process();
return ropMethod;
}
示例6
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
int oldRegCount = ssaMeth.getRegCount();
BasicRegisterMapper mapper = new BasicRegisterMapper(oldRegCount);
for (int i = 0; i < oldRegCount; i++) {
mapper.addMapping(i, i*2, 2);
}
return mapper;
}
示例7
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
analyzeInstructions();
if (DEBUG) {
printLocalVars();
}
if (DEBUG) System.out.println("--->Mapping local-associated params");
handleLocalAssociatedParams();
if (DEBUG) System.out.println("--->Mapping other params");
handleUnassociatedParameters();
if (DEBUG) System.out.println("--->Mapping invoke-range");
handleInvokeRangeInsns();
if (DEBUG) {
System.out.println("--->Mapping local-associated non-params");
}
handleLocalAssociatedOther();
if (DEBUG) System.out.println("--->Mapping check-cast results");
handleCheckCastResults();
if (DEBUG) System.out.println("--->Mapping phis");
handlePhiInsns();
if (DEBUG) System.out.println("--->Mapping others");
handleNormalUnassociated();
return mapper;
}
示例8
/**
* Performs the conversion.
*
* @return {@code non-null;} rop-form output
*/
private RopMethod convert() {
if (DEBUG) {
interference.dumpToStdout();
}
// These are other allocators for debugging or historical comparison:
// allocator = new NullRegisterAllocator(ssaMeth, interference);
// allocator = new FirstFitAllocator(ssaMeth, interference);
RegisterAllocator allocator =
new FirstFitLocalCombiningAllocator(ssaMeth, interference,
minimizeRegisters);
RegisterMapper mapper = allocator.allocateRegisters();
if (DEBUG) {
System.out.println("Printing reg map");
System.out.println(((BasicRegisterMapper)mapper).toHuman());
}
ssaMeth.setBackMode();
ssaMeth.mapRegisters(mapper);
removePhiFunctions();
if (allocator.wantsParamsMovedHigh()) {
moveParametersToHighRegisters();
}
removeEmptyGotos();
RopMethod ropMethod = new RopMethod(convertBasicBlocks(),
ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex()));
ropMethod = new IdenticalBlockCombiner(ropMethod).process();
return ropMethod;
}
示例9
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
int oldRegCount = ssaMeth.getRegCount();
BasicRegisterMapper mapper = new BasicRegisterMapper(oldRegCount);
for (int i = 0; i < oldRegCount; i++) {
mapper.addMapping(i, i*2, 2);
}
return mapper;
}
示例10
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
analyzeInstructions();
if (DEBUG) {
printLocalVars();
}
if (DEBUG) System.out.println("--->Mapping local-associated params");
handleLocalAssociatedParams();
if (DEBUG) System.out.println("--->Mapping other params");
handleUnassociatedParameters();
if (DEBUG) System.out.println("--->Mapping invoke-range");
handleInvokeRangeInsns();
if (DEBUG) {
System.out.println("--->Mapping local-associated non-params");
}
handleLocalAssociatedOther();
if (DEBUG) System.out.println("--->Mapping check-cast results");
handleCheckCastResults();
if (DEBUG) System.out.println("--->Mapping phis");
handlePhiInsns();
if (DEBUG) System.out.println("--->Mapping others");
handleNormalUnassociated();
return mapper;
}
示例11
/**
* Performs the conversion.
*
* @return {@code non-null;} rop-form output
*/
private RopMethod convert() {
if (DEBUG) {
interference.dumpToStdout();
}
// These are other allocators for debugging or historical comparison:
// allocator = new NullRegisterAllocator(ssaMeth, interference);
// allocator = new FirstFitAllocator(ssaMeth, interference);
RegisterAllocator allocator =
new FirstFitLocalCombiningAllocator(ssaMeth, interference,
minimizeRegisters);
RegisterMapper mapper = allocator.allocateRegisters();
if (DEBUG) {
System.out.println("Printing reg map");
System.out.println(((BasicRegisterMapper)mapper).toHuman());
}
ssaMeth.setBackMode();
ssaMeth.mapRegisters(mapper);
removePhiFunctions();
if (allocator.wantsParamsMovedHigh()) {
moveParametersToHighRegisters();
}
removeEmptyGotos();
RopMethod ropMethod = new RopMethod(convertBasicBlocks(),
ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex()));
ropMethod = new IdenticalBlockCombiner(ropMethod).process();
return ropMethod;
}
示例12
/** {@inheritDoc} */
@Override
public RegisterMapper allocateRegisters() {
int oldRegCount = ssaMeth.getRegCount();
BasicRegisterMapper mapper = new BasicRegisterMapper(oldRegCount);
for (int i = 0; i < oldRegCount; i++) {
mapper.addMapping(i, i*2, 2);
}
return mapper;
}
示例13
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalSnapshot(getPosition(), mapper.map(locals));
}
示例14
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalStart(getPosition(), mapper.map(local));
}
示例15
/** {@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;
}
示例16
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalSnapshot(getPosition(), mapper.map(locals));
}
示例17
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalStart(getPosition(), mapper.map(local));
}
示例18
/** {@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;
}
示例19
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalSnapshot(getPosition(), mapper.map(locals));
}
示例20
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalStart(getPosition(), mapper.map(local));
}
示例21
/** {@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;
}
示例22
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalSnapshot(getPosition(), mapper.map(locals));
}
示例23
/** {@inheritDoc} */
@Override
public DalvInsn withMapper(RegisterMapper mapper) {
return new LocalStart(getPosition(), mapper.map(local));
}
示例24
/** {@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;
}
示例25
/**
* Returns an instance that is just like this one, except that the
* register list is mapped by using {@code mapper}.
*
* @param mapper {@code non-null;} used to map registers
* @return {@code non-null;} an appropriately-constructed instance
*/
public DalvInsn withMapper(RegisterMapper mapper) {
return withRegisters(mapper.map(getRegisters()));
}
示例26
/**
* Runs the algorithm.
*
* @return a register mapper to apply to the {@code SsaMethod}
*/
public abstract RegisterMapper allocateRegisters();
示例27
/**
* Returns an instance that is just like this one, except that the
* register list is mapped by using {@code mapper}.
*
* @param mapper {@code non-null;} used to map registers
* @return {@code non-null;} an appropriately-constructed instance
*/
public DalvInsn withMapper(RegisterMapper mapper) {
return withRegisters(mapper.map(getRegisters()));
}
示例28
/**
* Runs the algorithm.
*
* @return a register mapper to apply to the {@code SsaMethod}
*/
public abstract RegisterMapper allocateRegisters();
示例29
/**
* Returns an instance that is just like this one, except that the
* register list is mapped by using {@code mapper}.
*
* @param mapper {@code non-null;} used to map registers
* @return {@code non-null;} an appropriately-constructed instance
*/
public DalvInsn withMapper(RegisterMapper mapper) {
return withRegisters(mapper.map(getRegisters()));
}
示例30
/**
* Runs the algorithm.
*
* @return a register mapper to apply to the {@code SsaMethod}
*/
public abstract RegisterMapper allocateRegisters();