Fix WASM backend

This commit is contained in:
Alexey Andreev 2019-10-23 18:30:16 +03:00
parent 3b4cc43e79
commit 4f9567561c

View File

@ -145,6 +145,7 @@ import org.teavm.runtime.ExceptionHandling;
import org.teavm.runtime.RuntimeArray; import org.teavm.runtime.RuntimeArray;
import org.teavm.runtime.RuntimeClass; import org.teavm.runtime.RuntimeClass;
import org.teavm.runtime.RuntimeObject; import org.teavm.runtime.RuntimeObject;
import org.teavm.runtime.ShadowStack;
import org.teavm.vm.BuildTarget; import org.teavm.vm.BuildTarget;
import org.teavm.vm.TeaVMEntryPoint; import org.teavm.vm.TeaVMEntryPoint;
import org.teavm.vm.TeaVMTarget; import org.teavm.vm.TeaVMTarget;
@ -605,7 +606,7 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost {
if (methodGenerator != null) { if (methodGenerator != null) {
WasmFunction function = context.getFunction(context.names.forMethod(method.getReference())); WasmFunction function = context.getFunction(context.names.forMethod(method.getReference()));
methodGenerator.apply(method.getReference(), function, methodGeneratorContext); methodGenerator.apply(method.getReference(), function, methodGeneratorContext);
} else { } else if (!isShadowStackMethod(method.getReference())) {
if (context.getImportedMethod(method.getReference()) == null) { if (context.getImportedMethod(method.getReference()) == null) {
CallLocation location = new CallLocation(method.getReference()); CallLocation location = new CallLocation(method.getReference());
controller.getDiagnostics().error(location, "Method {{m0}} is native but " controller.getDiagnostics().error(location, "Method {{m0}} is native but "
@ -629,6 +630,21 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost {
} }
} }
private boolean isShadowStackMethod(MethodReference method) {
if (!method.getClassName().equals(ShadowStack.class.getName())) {
return false;
}
switch (method.getName()) {
case "allocStack":
case "registerGCRoot":
case "removeGCRoot":
case "releaseStack":
return true;
default:
return false;
}
}
private void generateIsSupertypeFunctions(TagRegistry tagRegistry, WasmModule module, private void generateIsSupertypeFunctions(TagRegistry tagRegistry, WasmModule module,
WasmClassGenerator classGenerator) { WasmClassGenerator classGenerator) {
for (ValueType type : classGenerator.getRegisteredClasses()) { for (ValueType type : classGenerator.getRegisteredClasses()) {