mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 00:04:10 -08:00
Fix null checks on Address objects (Unmanaged annotation)
This commit is contained in:
parent
841e09cbd5
commit
daf3a1c192
|
@ -74,6 +74,8 @@ import org.teavm.model.ListableClassHolderSource;
|
||||||
import org.teavm.model.MethodReader;
|
import org.teavm.model.MethodReader;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
import org.teavm.model.lowlevel.Characteristics;
|
||||||
|
import org.teavm.model.lowlevel.LowLevelNullCheckFilter;
|
||||||
import org.teavm.model.transformation.BoundCheckInsertion;
|
import org.teavm.model.transformation.BoundCheckInsertion;
|
||||||
import org.teavm.model.transformation.NullCheckFilter;
|
import org.teavm.model.transformation.NullCheckFilter;
|
||||||
import org.teavm.model.transformation.NullCheckInsertion;
|
import org.teavm.model.transformation.NullCheckInsertion;
|
||||||
|
@ -86,7 +88,8 @@ import org.teavm.vm.spi.TeaVMHostExtension;
|
||||||
|
|
||||||
public class WasmGCTarget implements TeaVMTarget, TeaVMWasmGCHost {
|
public class WasmGCTarget implements TeaVMTarget, TeaVMWasmGCHost {
|
||||||
private TeaVMTargetController controller;
|
private TeaVMTargetController controller;
|
||||||
private NullCheckInsertion nullCheckInsertion = new NullCheckInsertion(NullCheckFilter.EMPTY);
|
private Characteristics characteristics;
|
||||||
|
private NullCheckInsertion nullCheckInsertion;
|
||||||
private BoundCheckInsertion boundCheckInsertion = new BoundCheckInsertion();
|
private BoundCheckInsertion boundCheckInsertion = new BoundCheckInsertion();
|
||||||
private boolean strict;
|
private boolean strict;
|
||||||
private boolean obfuscated;
|
private boolean obfuscated;
|
||||||
|
@ -179,6 +182,8 @@ public class WasmGCTarget implements TeaVMTarget, TeaVMWasmGCHost {
|
||||||
@Override
|
@Override
|
||||||
public void setController(TeaVMTargetController controller) {
|
public void setController(TeaVMTargetController controller) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
|
characteristics = new Characteristics(controller.getUnprocessedClassSource());
|
||||||
|
nullCheckInsertion = new NullCheckInsertion(new LowLevelNullCheckFilter(characteristics));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -267,6 +272,7 @@ public class WasmGCTarget implements TeaVMTarget, TeaVMWasmGCHost {
|
||||||
controller.getClassInitializerInfo(),
|
controller.getClassInitializerInfo(),
|
||||||
controller.getDependencyInfo(),
|
controller.getDependencyInfo(),
|
||||||
controller.getDiagnostics(),
|
controller.getDiagnostics(),
|
||||||
|
characteristics,
|
||||||
customGenerators,
|
customGenerators,
|
||||||
intrinsics,
|
intrinsics,
|
||||||
customTypeMapperFactories,
|
customTypeMapperFactories,
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.teavm.model.analysis.ClassInitializerInfo;
|
||||||
import org.teavm.model.analysis.ClassMetadataRequirements;
|
import org.teavm.model.analysis.ClassMetadataRequirements;
|
||||||
import org.teavm.model.classes.TagRegistry;
|
import org.teavm.model.classes.TagRegistry;
|
||||||
import org.teavm.model.classes.VirtualTableBuilder;
|
import org.teavm.model.classes.VirtualTableBuilder;
|
||||||
|
import org.teavm.model.lowlevel.Characteristics;
|
||||||
|
|
||||||
public class WasmGCDeclarationsGenerator {
|
public class WasmGCDeclarationsGenerator {
|
||||||
public final ClassHierarchy hierarchy;
|
public final ClassHierarchy hierarchy;
|
||||||
|
@ -61,6 +62,7 @@ public class WasmGCDeclarationsGenerator {
|
||||||
ClassInitializerInfo classInitializerInfo,
|
ClassInitializerInfo classInitializerInfo,
|
||||||
DependencyInfo dependencyInfo,
|
DependencyInfo dependencyInfo,
|
||||||
Diagnostics diagnostics,
|
Diagnostics diagnostics,
|
||||||
|
Characteristics characteristics,
|
||||||
WasmGCCustomGeneratorProvider customGenerators,
|
WasmGCCustomGeneratorProvider customGenerators,
|
||||||
WasmGCIntrinsicProvider intrinsics,
|
WasmGCIntrinsicProvider intrinsics,
|
||||||
List<WasmGCCustomTypeMapperFactory> customTypeMapperFactories,
|
List<WasmGCCustomTypeMapperFactory> customTypeMapperFactories,
|
||||||
|
@ -83,6 +85,7 @@ public class WasmGCDeclarationsGenerator {
|
||||||
functionTypes,
|
functionTypes,
|
||||||
names,
|
names,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
|
characteristics,
|
||||||
customGenerators,
|
customGenerators,
|
||||||
intrinsics,
|
intrinsics,
|
||||||
strict,
|
strict,
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.teavm.model.ClassReaderSource;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.ListableClassReaderSource;
|
import org.teavm.model.ListableClassReaderSource;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
import org.teavm.model.lowlevel.Characteristics;
|
||||||
|
|
||||||
public class WasmGCGenerationContext implements BaseWasmGenerationContext {
|
public class WasmGCGenerationContext implements BaseWasmGenerationContext {
|
||||||
private WasmModule module;
|
private WasmModule module;
|
||||||
|
@ -69,6 +70,7 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext {
|
||||||
private String entryPoint;
|
private String entryPoint;
|
||||||
private Consumer<WasmGCInitializerContributor> initializerContributors;
|
private Consumer<WasmGCInitializerContributor> initializerContributors;
|
||||||
private Diagnostics diagnostics;
|
private Diagnostics diagnostics;
|
||||||
|
private Characteristics characteristics;
|
||||||
|
|
||||||
public WasmGCGenerationContext(WasmModule module, WasmGCVirtualTableProvider virtualTables,
|
public WasmGCGenerationContext(WasmModule module, WasmGCVirtualTableProvider virtualTables,
|
||||||
WasmGCTypeMapper typeMapper, WasmFunctionTypes functionTypes, ListableClassReaderSource classes,
|
WasmGCTypeMapper typeMapper, WasmFunctionTypes functionTypes, ListableClassReaderSource classes,
|
||||||
|
@ -78,7 +80,7 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext {
|
||||||
WasmGCCustomGeneratorProvider customGenerators, WasmGCIntrinsicProvider intrinsics,
|
WasmGCCustomGeneratorProvider customGenerators, WasmGCIntrinsicProvider intrinsics,
|
||||||
WasmGCNameProvider names, boolean strict, String entryPoint,
|
WasmGCNameProvider names, boolean strict, String entryPoint,
|
||||||
Consumer<WasmGCInitializerContributor> initializerContributors,
|
Consumer<WasmGCInitializerContributor> initializerContributors,
|
||||||
Diagnostics diagnostics) {
|
Diagnostics diagnostics, Characteristics characteristics) {
|
||||||
this.module = module;
|
this.module = module;
|
||||||
this.virtualTables = virtualTables;
|
this.virtualTables = virtualTables;
|
||||||
this.typeMapper = typeMapper;
|
this.typeMapper = typeMapper;
|
||||||
|
@ -98,6 +100,7 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext {
|
||||||
this.entryPoint = entryPoint;
|
this.entryPoint = entryPoint;
|
||||||
this.initializerContributors = initializerContributors;
|
this.initializerContributors = initializerContributors;
|
||||||
this.diagnostics = diagnostics;
|
this.diagnostics = diagnostics;
|
||||||
|
this.characteristics = characteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WasmGCClassInfoProvider classInfoProvider() {
|
public WasmGCClassInfoProvider classInfoProvider() {
|
||||||
|
@ -210,6 +213,10 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext {
|
||||||
return diagnostics;
|
return diagnostics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Characteristics characteristics() {
|
||||||
|
return characteristics;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<String> getInterfaceImplementors(String className) {
|
public Collection<String> getInterfaceImplementors(String className) {
|
||||||
if (interfaceImplementors == null) {
|
if (interfaceImplementors == null) {
|
||||||
fillInterfaceImplementors();
|
fillInterfaceImplementors();
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.backend.wasm.generate.gc.methods;
|
package org.teavm.backend.wasm.generate.gc.methods;
|
||||||
|
|
||||||
|
import static org.teavm.model.lowlevel.ExceptionHandlingUtil.isManagedMethodCall;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -97,6 +99,7 @@ public class WasmGCGenerationVisitor extends BaseWasmGenerationVisitor {
|
||||||
private WasmGCGenerationUtil generationUtil;
|
private WasmGCGenerationUtil generationUtil;
|
||||||
private WasmType expectedType;
|
private WasmType expectedType;
|
||||||
private PreciseTypeInference types;
|
private PreciseTypeInference types;
|
||||||
|
private boolean managed;
|
||||||
|
|
||||||
public WasmGCGenerationVisitor(WasmGCGenerationContext context, MethodReference currentMethod,
|
public WasmGCGenerationVisitor(WasmGCGenerationContext context, MethodReference currentMethod,
|
||||||
WasmFunction function, int firstVariable, boolean async, PreciseTypeInference types) {
|
WasmFunction function, int firstVariable, boolean async, PreciseTypeInference types) {
|
||||||
|
@ -104,6 +107,7 @@ public class WasmGCGenerationVisitor extends BaseWasmGenerationVisitor {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
generationUtil = new WasmGCGenerationUtil(context.classInfoProvider());
|
generationUtil = new WasmGCGenerationUtil(context.classInfoProvider());
|
||||||
this.types = types;
|
this.types = types;
|
||||||
|
managed = context.characteristics().isManaged(currentMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,7 +129,7 @@ public class WasmGCGenerationVisitor extends BaseWasmGenerationVisitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isManaged() {
|
protected boolean isManaged() {
|
||||||
return true;
|
return managed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,7 +139,7 @@ public class WasmGCGenerationVisitor extends BaseWasmGenerationVisitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isManagedCall(MethodReference method) {
|
protected boolean isManagedCall(MethodReference method) {
|
||||||
return false;
|
return isManagedMethodCall(context.characteristics(), method);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,6 +61,7 @@ import org.teavm.model.MethodReader;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.analysis.ClassInitializerInfo;
|
import org.teavm.model.analysis.ClassInitializerInfo;
|
||||||
|
import org.teavm.model.lowlevel.Characteristics;
|
||||||
import org.teavm.model.util.RegisterAllocator;
|
import org.teavm.model.util.RegisterAllocator;
|
||||||
|
|
||||||
public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
||||||
|
@ -74,6 +75,7 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
||||||
private WasmGCSupertypeFunctionProvider supertypeFunctions;
|
private WasmGCSupertypeFunctionProvider supertypeFunctions;
|
||||||
public final WasmGCNameProvider names;
|
public final WasmGCNameProvider names;
|
||||||
private Diagnostics diagnostics;
|
private Diagnostics diagnostics;
|
||||||
|
private Characteristics characteristics;
|
||||||
private WasmGCTypeMapper typeMapper;
|
private WasmGCTypeMapper typeMapper;
|
||||||
private WasmGCCustomGeneratorProvider customGenerators;
|
private WasmGCCustomGeneratorProvider customGenerators;
|
||||||
private WasmGCIntrinsicProvider intrinsics;
|
private WasmGCIntrinsicProvider intrinsics;
|
||||||
|
@ -101,6 +103,7 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
||||||
WasmFunctionTypes functionTypes,
|
WasmFunctionTypes functionTypes,
|
||||||
WasmGCNameProvider names,
|
WasmGCNameProvider names,
|
||||||
Diagnostics diagnostics,
|
Diagnostics diagnostics,
|
||||||
|
Characteristics characteristics,
|
||||||
WasmGCCustomGeneratorProvider customGenerators,
|
WasmGCCustomGeneratorProvider customGenerators,
|
||||||
WasmGCIntrinsicProvider intrinsics,
|
WasmGCIntrinsicProvider intrinsics,
|
||||||
boolean strict,
|
boolean strict,
|
||||||
|
@ -116,6 +119,7 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
||||||
this.functionTypes = functionTypes;
|
this.functionTypes = functionTypes;
|
||||||
this.names = names;
|
this.names = names;
|
||||||
this.diagnostics = diagnostics;
|
this.diagnostics = diagnostics;
|
||||||
|
this.characteristics = characteristics;
|
||||||
this.customGenerators = customGenerators;
|
this.customGenerators = customGenerators;
|
||||||
this.intrinsics = intrinsics;
|
this.intrinsics = intrinsics;
|
||||||
this.strict = strict;
|
this.strict = strict;
|
||||||
|
@ -367,7 +371,8 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository {
|
||||||
strict,
|
strict,
|
||||||
entryPoint,
|
entryPoint,
|
||||||
initializerContributors,
|
initializerContributors,
|
||||||
diagnostics
|
diagnostics,
|
||||||
|
characteristics
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user