mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix support for multi-dimensional arrays of degree 3 and more in dependency analyzer
This commit is contained in:
parent
18d63863c9
commit
24d672e820
|
@ -32,7 +32,6 @@ import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
public class DependencyNode implements ValueDependencyInfo {
|
public class DependencyNode implements ValueDependencyInfo {
|
||||||
private static final int DEGREE_THRESHOLD = 2;
|
|
||||||
DependencyAnalyzer dependencyAnalyzer;
|
DependencyAnalyzer dependencyAnalyzer;
|
||||||
List<DependencyConsumer> followers;
|
List<DependencyConsumer> followers;
|
||||||
TypeSet typeSet;
|
TypeSet typeSet;
|
||||||
|
@ -58,9 +57,6 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propagate(DependencyType type) {
|
public void propagate(DependencyType type) {
|
||||||
if (degree > DEGREE_THRESHOLD) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!hasType(type) && filter(type)) {
|
if (!hasType(type) && filter(type)) {
|
||||||
propagateCount++;
|
propagateCount++;
|
||||||
moveToSeparateDomain();
|
moveToSeparateDomain();
|
||||||
|
@ -96,10 +92,6 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propagate(DependencyType[] newTypes) {
|
public void propagate(DependencyType[] newTypes) {
|
||||||
if (degree > DEGREE_THRESHOLD) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newTypes.length == 0) {
|
if (newTypes.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -314,9 +306,6 @@ public class DependencyNode implements ValueDependencyInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectArrayItemNodes(DependencyNode node) {
|
private void connectArrayItemNodes(DependencyNode node) {
|
||||||
if (degree > DEGREE_THRESHOLD || node.degree > DEGREE_THRESHOLD) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isArray(typeFilter) || !isArray(node.typeFilter)) {
|
if (!isArray(typeFilter) || !isArray(node.typeFilter)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ import org.teavm.model.ReferenceCache;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
public class PreciseDependencyAnalyzer extends DependencyAnalyzer {
|
public class PreciseDependencyAnalyzer extends DependencyAnalyzer {
|
||||||
|
private DependencyNode allArrayItemsNode;
|
||||||
|
private static final int DEGREE_THRESHOLD = 2;
|
||||||
|
|
||||||
public PreciseDependencyAnalyzer(ClassReaderSource classSource, ClassLoader classLoader,
|
public PreciseDependencyAnalyzer(ClassReaderSource classSource, ClassLoader classLoader,
|
||||||
ServiceRepository services, Diagnostics diagnostics, ReferenceCache referenceCache,
|
ServiceRepository services, Diagnostics diagnostics, ReferenceCache referenceCache,
|
||||||
String[] platformTags) {
|
String[] platformTags) {
|
||||||
|
@ -80,11 +83,22 @@ public class PreciseDependencyAnalyzer extends DependencyAnalyzer {
|
||||||
ValueType itemTypeFilter = parent.typeFilter instanceof ValueType.Array
|
ValueType itemTypeFilter = parent.typeFilter instanceof ValueType.Array
|
||||||
? ((ValueType.Array) parent.typeFilter).getItemType()
|
? ((ValueType.Array) parent.typeFilter).getItemType()
|
||||||
: null;
|
: null;
|
||||||
DependencyNode node = createNode(itemTypeFilter);
|
DependencyNode node;
|
||||||
node.degree = parent.degree + 1;
|
if (parent.degree > DEGREE_THRESHOLD) {
|
||||||
node.method = parent.method;
|
if (allArrayItemsNode == null) {
|
||||||
if (DependencyAnalyzer.shouldTag) {
|
allArrayItemsNode = createNode(null);
|
||||||
node.tag = parent.tag + "[";
|
if (DependencyAnalyzer.shouldTag) {
|
||||||
|
allArrayItemsNode.tag = "<any array item>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node = allArrayItemsNode;
|
||||||
|
} else {
|
||||||
|
node = createNode(itemTypeFilter);
|
||||||
|
node.degree = parent.degree + 1;
|
||||||
|
node.method = parent.method;
|
||||||
|
if (DependencyAnalyzer.shouldTag) {
|
||||||
|
node.tag = parent.tag + "[";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user