mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
С/wasm: don't include references metadata resource into GC stack roots and into class layout for GC.
This commit is contained in:
parent
2c1bf6e270
commit
6c6d440ebb
|
@ -374,7 +374,6 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
|||
TagRegistry tagRegistry = !incremental ? new TagRegistry(classes, hierarchy) : null;
|
||||
|
||||
Decompiler decompiler = new Decompiler(classes, new HashSet<>(), controller.isFriendlyToDebugger());
|
||||
Characteristics characteristics = new Characteristics(controller.getUnprocessedClassSource());
|
||||
|
||||
NameProvider nameProvider = new NameProviderWithSpecialNames(rawNameProvider,
|
||||
controller.getUnprocessedClassSource());
|
||||
|
|
|
@ -1131,6 +1131,7 @@ public class ClassGenerator {
|
|||
String className = ((ValueType.Object) type).getClassName();
|
||||
return !context.getCharacteristics().isStructure(className)
|
||||
&& !context.getCharacteristics().isFunction(className)
|
||||
&& !context.getCharacteristics().isResource(className)
|
||||
&& !className.equals(Address.class.getName());
|
||||
} else {
|
||||
return type instanceof ValueType.Array;
|
||||
|
|
|
@ -32,6 +32,7 @@ public class Characteristics {
|
|||
private ObjectByteMap<String> isStructure = new ObjectByteHashMap<>();
|
||||
private ObjectByteMap<String> isStaticInit = new ObjectByteHashMap<>();
|
||||
private ObjectByteMap<String> isFunction = new ObjectByteHashMap<>();
|
||||
private ObjectByteMap<String> isResource = new ObjectByteHashMap<>();
|
||||
private ObjectByteMap<MethodReference> isManaged = new ObjectByteHashMap<>();
|
||||
|
||||
public Characteristics(ClassReaderSource classSource) {
|
||||
|
@ -56,6 +57,34 @@ public class Characteristics {
|
|||
return result != 0;
|
||||
}
|
||||
|
||||
public boolean isResource(String className) {
|
||||
byte result = isResource.getOrDefault(className, (byte) -1);
|
||||
if (result < 0) {
|
||||
if (className.equals("org/teavm/platform/metadata/Resource")) {
|
||||
result = 1;
|
||||
} else {
|
||||
ClassReader cls = classSource.get(className);
|
||||
if (cls != null) {
|
||||
if (cls.getParent() != null) {
|
||||
result = isResource(cls.getParent()) ? (byte) 1 : 0;
|
||||
}
|
||||
if (result == 0) {
|
||||
for (String itf : cls.getInterfaces()) {
|
||||
if (isResource(itf)) {
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
isResource.put(className, result);
|
||||
}
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
public boolean isStaticInit(String className) {
|
||||
byte result = isStaticInit.getOrDefault(className, (byte) -1);
|
||||
if (result < 0) {
|
||||
|
|
|
@ -28,11 +28,14 @@ public class LowLevelNullCheckFilter implements NullCheckFilter {
|
|||
|
||||
@Override
|
||||
public boolean apply(FieldReference field) {
|
||||
return !characteristics.isStructure(field.getClassName());
|
||||
return !characteristics.isStructure(field.getClassName())
|
||||
&& !characteristics.isStructure(field.getClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(MethodReference method) {
|
||||
return characteristics.isManaged(method.getClassName()) && characteristics.isManaged(method);
|
||||
return characteristics.isManaged(method.getClassName())
|
||||
&& characteristics.isManaged(method)
|
||||
&& !characteristics.isResource(method.getClassName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,6 @@ public class NativePointerFinder {
|
|||
}
|
||||
String className = ((ValueType.Object) type).getClassName();
|
||||
return characteristics.isStructure(className) || className.equals(Address.class.getName())
|
||||
|| characteristics.isFunction(className);
|
||||
|| characteristics.isFunction(className) || characteristics.isResource(className);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user