First correct local variable mapping

This commit is contained in:
konsoletyper 2014-08-06 20:56:33 +04:00
parent 36d76885a7
commit 8d0432dd5e
5 changed files with 38 additions and 1 deletions

View File

@ -65,4 +65,17 @@ public class Variable implements VariableReader {
public void setDebugName(String debugName) {
this.debugName = debugName;
}
public void mergeDebugName(String otherDebugName) {
if (otherDebugName == null) {
return;
}
String[] parts = debugName != null ? debugName.split("\\|") : new String[0];
for (String part : parts) {
if (otherDebugName.equals(part)) {
return;
}
}
debugName = debugName != null ? debugName + "|" + otherDebugName : otherDebugName;
}
}

View File

@ -214,6 +214,15 @@ public class RegisterAllocator {
varMap[tryCatch.getExceptionVariable().getIndex()]));
}
}
String[] originalNames = new String[program.variableCount()];
for (int i = 0; i < program.variableCount(); ++i) {
Variable var = program.variableAt(i);
originalNames[i] = var.getDebugName();
var.setDebugName(null);
}
for (int i = 0; i < program.variableCount(); ++i) {
program.variableAt(varMap[i]).mergeDebugName(originalNames[i]);
}
}
private void renameInterferenceGraph(List<MutableGraphNode> graph, DisjointSet classes, final int[] varMap) {

View File

@ -112,6 +112,9 @@ public class GlobalValueNumbering implements MethodOptimization {
for (int i = 0; i < map.length; ++i) {
if (map[i] != i) {
Variable var = program.variableAt(i);
Variable mapVar = program.variableAt(map[i]);
mapVar.mergeDebugName(var.getDebugName());
program.deleteVariable(i);
}
}

View File

@ -175,12 +175,14 @@ public class SSATransformer {
int[] phiIndexes = phiIndexMap[successor];
List<Phi> phis = program.basicBlockAt(successor).getPhis();
for (int j = 0; j < phis.size(); ++j) {
Phi phi = phis.get(j);
Variable var = variableMap[phiIndexes[j]];
if (var != null) {
Incoming incoming = new Incoming();
incoming.setSource(currentBlock);
incoming.setValue(var);
phis.get(j).getIncomings().add(incoming);
phi.getIncomings().add(incoming);
phi.getReceiver().mergeDebugName(var.getDebugName());
}
}
}

View File

@ -391,6 +391,16 @@ function $rt_s(index) {
return $rt_stringPool_instance[index];
}
function $dbg_repr(obj) {
return obj.toString();
}
function $dbg_class(obj) {
if (obj instanceof Long) {
return "long";
}
return obj.constructor.$meta.name;
}
Long = function(lo, hi) {
this.lo = lo | 0;
this.hi = hi | 0;