use of com.android.dx.rop.code.LocalItem in project J2ME-Loader by nikita36078.
the class OutputFinisher method addConstants.
/**
* Helper for {@link #getAllConstants} which adds all the info for
* a single {@code RegisterSpec}.
*
* @param result {@code non-null;} result set to add to
* @param spec {@code null-ok;} register spec to add
*/
private static void addConstants(HashSet<Constant> result, RegisterSpec spec) {
if (spec == null) {
return;
}
LocalItem local = spec.getLocalItem();
CstString name = local.getName();
CstString signature = local.getSignature();
Type type = spec.getType();
if (type != Type.KNOWN_NULL) {
result.add(CstType.intern(type));
} else {
/* If this a "known null", let's use "Object" because that's going to be the
* resulting type in {@link LocalList.MakeState#filterSpec} */
result.add(CstType.intern(Type.OBJECT));
}
if (name != null) {
result.add(name);
}
if (signature != null) {
result.add(signature);
}
}
use of com.android.dx.rop.code.LocalItem in project J2ME-Loader by nikita36078.
the class NormalSsaInsn method getLocalAssignment.
/**
* {@inheritDoc}
*/
@Override
public RegisterSpec getLocalAssignment() {
RegisterSpec assignment;
if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
assignment = insn.getSources().get(0);
} else {
assignment = getResult();
}
if (assignment == null) {
return null;
}
LocalItem local = assignment.getLocalItem();
if (local == null) {
return null;
}
return assignment;
}
use of com.android.dx.rop.code.LocalItem in project buck by facebook.
the class FirstFitLocalCombiningAllocator method printLocalVars.
/**
* Dumps local variable table to stdout for debugging.
*/
private void printLocalVars() {
System.out.println("Printing local vars");
for (Map.Entry<LocalItem, ArrayList<RegisterSpec>> e : localVariables.entrySet()) {
StringBuilder regs = new StringBuilder();
regs.append('{');
regs.append(' ');
for (RegisterSpec reg : e.getValue()) {
regs.append('v');
regs.append(reg.getReg());
regs.append(' ');
}
regs.append('}');
System.out.printf("Local: %s Registers: %s\n", e.getKey(), regs);
}
}
use of com.android.dx.rop.code.LocalItem in project buck by facebook.
the class ConstCollector method fixLocalAssignment.
/**
* Inserts mark-locals if necessary when changing a register. If
* the definition of {@code origReg} is associated with a local
* variable, then insert a mark-local for {@code newReg} just below
* it. We expect the definition of {@code origReg} to ultimately
* be removed by the dead code eliminator
*
* @param origReg {@code non-null;} original register
* @param newReg {@code non-null;} new register that will replace
* {@code origReg}
*/
private void fixLocalAssignment(RegisterSpec origReg, RegisterSpec newReg) {
for (SsaInsn use : ssaMeth.getUseListForRegister(origReg.getReg())) {
RegisterSpec localAssignment = use.getLocalAssignment();
if (localAssignment == null) {
continue;
}
if (use.getResult() == null) {
/*
* This is a mark-local. it will be updated when all uses
* are updated.
*/
continue;
}
LocalItem local = localAssignment.getLocalItem();
// Un-associate original use.
use.setResultLocal(null);
// Now add a mark-local to the new reg immediately after.
newReg = newReg.withLocalItem(local);
SsaInsn newInsn = SsaInsn.makeFromRop(new PlainInsn(Rops.opMarkLocal(newReg), SourcePosition.NO_INFO, null, RegisterSpecList.make(newReg)), use.getBlock());
ArrayList<SsaInsn> insns = use.getBlock().getInsns();
insns.add(insns.indexOf(use) + 1, newInsn);
}
}
use of com.android.dx.rop.code.LocalItem in project buck by facebook.
the class NormalSsaInsn method getLocalAssignment.
/** {@inheritDoc} */
@Override
public RegisterSpec getLocalAssignment() {
RegisterSpec assignment;
if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
assignment = insn.getSources().get(0);
} else {
assignment = getResult();
}
if (assignment == null) {
return null;
}
LocalItem local = assignment.getLocalItem();
if (local == null) {
return null;
}
return assignment;
}
Aggregations