com.android.dx.ssa.BasicRegisterMapper Java Examples
The following examples show how to use
com.android.dx.ssa.BasicRegisterMapper.
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: OutputFinisher.java From Box with Apache License 2.0 | 6 votes |
private void shiftParameters(int delta) { int insnSize = insns.size(); int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount; int firstParameter = lastParameter - paramSize; BasicRegisterMapper mapper = new BasicRegisterMapper(lastParameter); for (int i = 0; i < lastParameter; i++) { if (i >= firstParameter) { mapper.addMapping(i, i + delta, 1); } else { mapper.addMapping(i, i, 1); } } for (int i = 0; i < insnSize; i++) { DalvInsn insn = insns.get(i); // Since there is no need to replace CodeAddress since it does not use registers, skips it to // avoid to update all TargetInsn that contain a reference to CodeAddress if (!(insn instanceof CodeAddress)) { insns.set(i, insn.withMapper(mapper)); } } }
Example #2
Source File: SsaToRop.java From Box with Apache License 2.0 | 6 votes |
/** * Moves the parameter registers, which allocateRegisters() places * at the bottom of the frame, up to the top of the frame to match * Dalvik calling convention. */ private void moveParametersToHighRegisters() { int paramWidth = ssaMeth.getParamWidth(); BasicRegisterMapper mapper = new BasicRegisterMapper(ssaMeth.getRegCount()); int regCount = ssaMeth.getRegCount(); for (int i = 0; i < regCount; i++) { if (i < paramWidth) { mapper.addMapping(i, regCount - paramWidth + i, 1); } else { mapper.addMapping(i, i - paramWidth, 1); } } if (DEBUG) { System.out.printf("Moving %d registers from 0 to %d\n", paramWidth, regCount - paramWidth); } ssaMeth.mapRegisters(mapper); }
Example #3
Source File: SsaToRop.java From buck with Apache License 2.0 | 6 votes |
/** * Moves the parameter registers, which allocateRegisters() places * at the bottom of the frame, up to the top of the frame to match * Dalvik calling convention. */ private void moveParametersToHighRegisters() { int paramWidth = ssaMeth.getParamWidth(); BasicRegisterMapper mapper = new BasicRegisterMapper(ssaMeth.getRegCount()); int regCount = ssaMeth.getRegCount(); for (int i = 0; i < regCount; i++) { if (i < paramWidth) { mapper.addMapping(i, regCount - paramWidth + i, 1); } else { mapper.addMapping(i, i - paramWidth, 1); } } if (DEBUG) { System.out.printf("Moving %d registers from 0 to %d\n", paramWidth, regCount - paramWidth); } ssaMeth.mapRegisters(mapper); }
Example #4
Source File: OutputFinisher.java From Box with Apache License 2.0 | 6 votes |
private void shiftParameters(int delta) { int insnSize = insns.size(); int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount; int firstParameter = lastParameter - paramSize; BasicRegisterMapper mapper = new BasicRegisterMapper(lastParameter); for (int i = 0; i < lastParameter; i++) { if (i >= firstParameter) { mapper.addMapping(i, i + delta, 1); } else { mapper.addMapping(i, i, 1); } } for (int i = 0; i < insnSize; i++) { DalvInsn insn = insns.get(i); // Since there is no need to replace CodeAddress since it does not use registers, skips it to // avoid to update all TargetInsn that contain a reference to CodeAddress if (!(insn instanceof CodeAddress)) { insns.set(i, insn.withMapper(mapper)); } } }
Example #5
Source File: SsaToRop.java From Box with Apache License 2.0 | 6 votes |
/** * Moves the parameter registers, which allocateRegisters() places * at the bottom of the frame, up to the top of the frame to match * Dalvik calling convention. */ private void moveParametersToHighRegisters() { int paramWidth = ssaMeth.getParamWidth(); BasicRegisterMapper mapper = new BasicRegisterMapper(ssaMeth.getRegCount()); int regCount = ssaMeth.getRegCount(); for (int i = 0; i < regCount; i++) { if (i < paramWidth) { mapper.addMapping(i, regCount - paramWidth + i, 1); } else { mapper.addMapping(i, i - paramWidth, 1); } } if (DEBUG) { System.out.printf("Moving %d registers from 0 to %d\n", paramWidth, regCount - paramWidth); } ssaMeth.mapRegisters(mapper); }
Example #6
Source File: OutputFinisher.java From buck with Apache License 2.0 | 6 votes |
private void shiftParameters(int delta) { int insnSize = insns.size(); int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount; int firstParameter = lastParameter - paramSize; BasicRegisterMapper mapper = new BasicRegisterMapper(lastParameter); for (int i = 0; i < lastParameter; i++) { if (i >= firstParameter) { mapper.addMapping(i, i + delta, 1); } else { mapper.addMapping(i, i, 1); } } for (int i = 0; i < insnSize; i++) { DalvInsn insn = insns.get(i); // Since there is no need to replace CodeAddress since it does not use registers, skips it to // avoid to update all TargetInsn that contain a reference to CodeAddress if (!(insn instanceof CodeAddress)) { insns.set(i, insn.withMapper(mapper)); } } }
Example #7
Source File: OutputFinisher.java From J2ME-Loader with Apache License 2.0 | 6 votes |
private void shiftParameters(int delta) { int insnSize = insns.size(); int lastParameter = unreservedRegCount + reservedCount + reservedParameterCount; int firstParameter = lastParameter - paramSize; BasicRegisterMapper mapper = new BasicRegisterMapper(lastParameter); for (int i = 0; i < lastParameter; i++) { if (i >= firstParameter) { mapper.addMapping(i, i + delta, 1); } else { mapper.addMapping(i, i, 1); } } for (int i = 0; i < insnSize; i++) { DalvInsn insn = insns.get(i); // Since there is no need to replace CodeAddress since it does not use registers, skips it to // avoid to update all TargetInsn that contain a reference to CodeAddress if (!(insn instanceof CodeAddress)) { insns.set(i, insn.withMapper(mapper)); } } }
Example #8
Source File: SsaToRop.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Moves the parameter registers, which allocateRegisters() places * at the bottom of the frame, up to the top of the frame to match * Dalvik calling convention. */ private void moveParametersToHighRegisters() { int paramWidth = ssaMeth.getParamWidth(); BasicRegisterMapper mapper = new BasicRegisterMapper(ssaMeth.getRegCount()); int regCount = ssaMeth.getRegCount(); for (int i = 0; i < regCount; i++) { if (i < paramWidth) { mapper.addMapping(i, regCount - paramWidth + i, 1); } else { mapper.addMapping(i, i - paramWidth, 1); } } if (DEBUG) { System.out.printf("Moving %d registers from 0 to %d\n", paramWidth, regCount - paramWidth); } ssaMeth.mapRegisters(mapper); }
Example #9
Source File: SsaToRop.java From Box with Apache License 2.0 | 5 votes |
/** * 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; }
Example #10
Source File: NullRegisterAllocator.java From buck with Apache License 2.0 | 5 votes |
/** {@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; }
Example #11
Source File: SsaToRop.java From buck with Apache License 2.0 | 5 votes |
/** * 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; }
Example #12
Source File: NullRegisterAllocator.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** {@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; }
Example #13
Source File: SsaToRop.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * 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; }
Example #14
Source File: NullRegisterAllocator.java From Box with Apache License 2.0 | 5 votes |
/** {@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; }
Example #15
Source File: SsaToRop.java From Box with Apache License 2.0 | 5 votes |
/** * 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; }
Example #16
Source File: NullRegisterAllocator.java From Box with Apache License 2.0 | 5 votes |
/** {@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; }
Example #17
Source File: FirstFitAllocator.java From Box with Apache License 2.0 | 4 votes |
/** {@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 #18
Source File: FirstFitAllocator.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** {@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 #19
Source File: FirstFitAllocator.java From Box with Apache License 2.0 | 4 votes |
/** {@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 #20
Source File: FirstFitAllocator.java From buck with Apache License 2.0 | 4 votes |
/** {@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; }