mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Remove performance optimization that causes bug when modifying class hierarchy within class transformers
This commit is contained in:
parent
4b3a8e757b
commit
e147a998e5
|
@ -81,7 +81,6 @@ public abstract class DependencyAnalyzer implements DependencyInfo {
|
|||
|| shouldLog;
|
||||
static final boolean dependencyReport = System.getProperty("org.teavm.dependencyReport", "false").equals("true");
|
||||
private int classNameSuffix;
|
||||
private ClassReaderSource unprocessedClassSource;
|
||||
private DependencyClassSource classSource;
|
||||
ClassReaderSource agentClassSource;
|
||||
private ClassLoader classLoader;
|
||||
|
@ -118,7 +117,6 @@ public abstract class DependencyAnalyzer implements DependencyInfo {
|
|||
|
||||
DependencyAnalyzer(ClassReaderSource classSource, ClassLoader classLoader, ServiceRepository services,
|
||||
Diagnostics diagnostics, ReferenceCache referenceCache) {
|
||||
unprocessedClassSource = classSource;
|
||||
this.diagnostics = diagnostics;
|
||||
this.referenceCache = referenceCache;
|
||||
this.classSource = new DependencyClassSource(classSource, diagnostics, incrementalCache);
|
||||
|
@ -170,32 +168,10 @@ public abstract class DependencyAnalyzer implements DependencyInfo {
|
|||
type = new DependencyType(this, name, types.size());
|
||||
types.add(type);
|
||||
typeMap.put(name, type);
|
||||
|
||||
if (!name.startsWith("[") && !name.startsWith("~")) {
|
||||
markSupertypesAsHavingSubtypes(name);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private void markSupertypesAsHavingSubtypes(String name) {
|
||||
ClassReader cls = unprocessedClassSource.get(name);
|
||||
if (cls == null) {
|
||||
cls = classSource.get(name);
|
||||
if (cls == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cls.getParent() != null) {
|
||||
getType(cls.getParent()).subtypeExists = true;
|
||||
}
|
||||
|
||||
for (String itf : cls.getInterfaces()) {
|
||||
getType(itf).subtypeExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
public DependencyNode createNode() {
|
||||
return createNode(null);
|
||||
}
|
||||
|
@ -773,7 +749,6 @@ public abstract class DependencyAnalyzer implements DependencyInfo {
|
|||
classSource.cleanup();
|
||||
agent.cleanup();
|
||||
listeners.clear();
|
||||
unprocessedClassSource = null;
|
||||
classSource.innerHierarchy = null;
|
||||
|
||||
agentClassSource = classSourcePacker.pack(classSource,
|
||||
|
@ -869,7 +844,7 @@ public abstract class DependencyAnalyzer implements DependencyInfo {
|
|||
ValueType.Object itemType = (ValueType.Object) ValueType.parse(superClass.substring(1));
|
||||
result = new SuperArrayFilter(this, getSuperClassFilter(itemType.getClassName()));
|
||||
} else {
|
||||
result = new ExactTypeFilter(superClass);
|
||||
result = new ExactTypeFilter(getType(superClass));
|
||||
}
|
||||
} else {
|
||||
if (superClass.equals("java.lang.Object")) {
|
||||
|
|
|
@ -19,7 +19,6 @@ public class DependencyType {
|
|||
private DependencyAnalyzer dependencyAnalyzer;
|
||||
private String name;
|
||||
int index;
|
||||
boolean subtypeExists;
|
||||
|
||||
DependencyType(DependencyAnalyzer dependencyAnalyzer, String name, int index) {
|
||||
this.dependencyAnalyzer = dependencyAnalyzer;
|
||||
|
|
|
@ -15,12 +15,17 @@
|
|||
*/
|
||||
package org.teavm.dependency;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
class ExactTypeFilter implements DependencyTypeFilter {
|
||||
private static final int[] EMPTY = new int[0];
|
||||
String typeName;
|
||||
int cache = -1;
|
||||
int index;
|
||||
|
||||
ExactTypeFilter(String typeName) {
|
||||
this.typeName = typeName;
|
||||
ExactTypeFilter(DependencyType dependencyType) {
|
||||
this.typeName = dependencyType.getName();
|
||||
index = dependencyType.index;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,4 +39,9 @@ class ExactTypeFilter implements DependencyTypeFilter {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] tryExtract(BitSet types) {
|
||||
return types.get(index) ? new int[] { index } : EMPTY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,22 +19,16 @@ import java.util.BitSet;
|
|||
import org.teavm.common.OptionalPredicate;
|
||||
|
||||
class SuperClassFilter implements DependencyTypeFilter {
|
||||
private static final int[] EMPTY_ARRAY = new int[0];
|
||||
private DependencyType superType;
|
||||
private OptionalPredicate<String> predicate;
|
||||
private BitSet knownTypes = new BitSet();
|
||||
private BitSet cache = new BitSet();
|
||||
|
||||
SuperClassFilter(DependencyAnalyzer dependencyAnalyzer, DependencyType superType) {
|
||||
this.superType = superType;
|
||||
predicate = dependencyAnalyzer.getClassHierarchy().getSuperclassPredicate(superType.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(DependencyType type) {
|
||||
if (!superType.subtypeExists) {
|
||||
return superType.index == type.index;
|
||||
}
|
||||
if (knownTypes.get(type.index)) {
|
||||
return cache.get(type.index);
|
||||
}
|
||||
|
@ -43,12 +37,4 @@ class SuperClassFilter implements DependencyTypeFilter {
|
|||
cache.set(type.index, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] tryExtract(BitSet types) {
|
||||
if (superType.subtypeExists) {
|
||||
return null;
|
||||
}
|
||||
return types.get(superType.index) ? new int[] { superType.index } : EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user