diff --git a/teavm-core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java b/teavm-core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java index 882000dfc..8999690e4 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DataFlowGraphBuilder.java @@ -299,11 +299,13 @@ public class DataFlowGraphBuilder implements InstructionReader { @Override public void getElement(VariableReader receiver, VariableReader array, VariableReader index) { + important(array.getIndex()); builder.addEdge(getArrayElementNode(array.getIndex()), receiver.getIndex()); } @Override public void putElement(VariableReader array, VariableReader index, VariableReader value) { + important(array.getIndex()); builder.addEdge(value.getIndex(), getArrayElementNode(array.getIndex())); } diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java index 159d30425..ed38a3f88 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java @@ -48,10 +48,6 @@ class DependencyGraphBuilder { return; } program = method.getProgram(); - if (DependencyChecker.shouldLog) { - System.out.println("Method reached: " + method.getReference()); - System.out.println(new ListingBuilder().buildListing(program, " ")); - } resultNode = dep.getResult(); DataFlowGraphBuilder dfgBuilder = new DataFlowGraphBuilder(); @@ -60,6 +56,17 @@ class DependencyGraphBuilder { } int[] nodeMapping = dfgBuilder.buildMapping(program, dep.getParameterCount(), !(method.getResultType() instanceof ValueType.Primitive) && method.getResultType() != ValueType.VOID); + + if (DependencyChecker.shouldLog) { + System.out.println("Method reached: " + method.getReference()); + System.out.print(new ListingBuilder().buildListing(program, " ")); + for (int i = 0; i < nodeMapping.length; ++i) { + System.out.print(i + ":" + nodeMapping[i] + " "); + } + System.out.println(); + System.out.println(); + } + int nodeClassCount = 0; for (int i = 0; i < nodeMapping.length; ++i) { nodeClassCount = Math.max(nodeClassCount, nodeMapping[i] + 1); @@ -67,6 +74,9 @@ class DependencyGraphBuilder { DependencyNode[] nodeClasses = Arrays.copyOf(dep.getVariables(), nodeClassCount); for (int i = dep.getVariableCount(); i < nodeClasses.length; ++i) { nodeClasses[i] = dependencyChecker.createNode(); + if (DependencyChecker.shouldLog) { + nodeClasses[i].setTag(dep.getMethod().getReference() + ":" + i); + } } nodes = new DependencyNode[dep.getMethod().getProgram().variableCount()]; for (int i = 0; i < nodes.length; ++i) { @@ -415,9 +425,9 @@ class DependencyGraphBuilder { @Override public void getField(VariableReader receiver, VariableReader instance, FieldReference field, ValueType fieldType) { + FieldDependency fieldDep = dependencyChecker.linkField(field, + new CallLocation(caller.getMethod(), currentLocation)); if (!(fieldType instanceof ValueType.Primitive)) { - FieldDependency fieldDep = dependencyChecker.linkField(field, - new CallLocation(caller.getMethod(), currentLocation)); DependencyNode receiverNode = nodes[receiver.getIndex()]; if (receiverNode != null) { fieldDep.getValue().connect(receiverNode); @@ -429,9 +439,9 @@ class DependencyGraphBuilder { @Override public void putField(VariableReader instance, FieldReference field, VariableReader value, ValueType fieldType) { + FieldDependency fieldDep = dependencyChecker.linkField(field, + new CallLocation(caller.getMethod(), currentLocation)); if (!(fieldType instanceof ValueType.Primitive)) { - FieldDependency fieldDep = dependencyChecker.linkField(field, - new CallLocation(caller.getMethod(), currentLocation)); DependencyNode valueNode = nodes[value.getIndex()]; if (valueNode != null) { valueNode.connect(fieldDep.getValue());