diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java index d44cc7fed..ce42896c1 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmGCTarget.java @@ -178,7 +178,8 @@ public class WasmGCTarget implements TeaVMTarget, TeaVMWasmGCHost { customGenerators, intrinsics, customTypeMapperFactories, - controller::isVirtual + controller::isVirtual, + strict ); declarationsGenerator.setFriendlyToDebugger(controller.isFriendlyToDebugger()); var moduleGenerator = new WasmGCModuleGenerator(declarationsGenerator); diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/gc/WasmGCDeclarationsGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/gc/WasmGCDeclarationsGenerator.java index b5883d192..dbd845a52 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/gc/WasmGCDeclarationsGenerator.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/gc/WasmGCDeclarationsGenerator.java @@ -57,7 +57,8 @@ public class WasmGCDeclarationsGenerator { WasmGCCustomGeneratorProvider customGenerators, WasmGCIntrinsicProvider intrinsics, List customTypeMapperFactories, - Predicate isVirtual + Predicate isVirtual, + boolean strict ) { this.module = module; hierarchy = new ClassHierarchy(classes); @@ -75,7 +76,8 @@ public class WasmGCDeclarationsGenerator { names, diagnostics, customGenerators, - intrinsics + intrinsics, + strict ); var tags = new TagRegistry(classes, hierarchy); var metadataRequirements = new ClassMetadataRequirements(dependencyInfo); diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationContext.java b/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationContext.java index 4845645b7..a84eb7fd6 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationContext.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationContext.java @@ -32,7 +32,6 @@ import org.teavm.backend.wasm.generate.gc.classes.WasmGCSupertypeFunctionProvide import org.teavm.backend.wasm.generate.gc.classes.WasmGCTypeMapper; import org.teavm.backend.wasm.generate.gc.strings.WasmGCStringProvider; import org.teavm.backend.wasm.model.WasmFunction; -import org.teavm.backend.wasm.model.WasmGlobal; import org.teavm.backend.wasm.model.WasmModule; import org.teavm.backend.wasm.model.WasmTag; import org.teavm.backend.wasm.runtime.WasmGCSupport; @@ -60,10 +59,10 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext { private WasmFunction npeMethod; private WasmFunction aaiobeMethod; private WasmFunction cceMethod; - private WasmGlobal exceptionGlobal; private WasmTag exceptionTag; private Map> interfaceImplementors; private WasmGCNameProvider names; + private boolean strict; public WasmGCGenerationContext(WasmModule module, WasmGCVirtualTableProvider virtualTables, WasmGCTypeMapper typeMapper, WasmFunctionTypes functionTypes, ListableClassReaderSource classes, @@ -71,7 +70,7 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext { WasmGCSupertypeFunctionProvider supertypeFunctions, WasmGCClassInfoProvider classInfoProvider, WasmGCStandardClasses standardClasses, WasmGCStringProvider strings, WasmGCCustomGeneratorProvider customGenerators, WasmGCIntrinsicProvider intrinsics, - WasmGCNameProvider names) { + WasmGCNameProvider names, boolean strict) { this.module = module; this.virtualTables = virtualTables; this.typeMapper = typeMapper; @@ -87,6 +86,7 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext { this.customGenerators = customGenerators; this.intrinsics = intrinsics; this.names = names; + this.strict = strict; } public WasmGCClassInfoProvider classInfoProvider() { @@ -143,6 +143,10 @@ public class WasmGCGenerationContext implements BaseWasmGenerationContext { return classes; } + public boolean isStrict() { + return strict; + } + public ClassLoader classLoader() { return classLoader; } diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationVisitor.java b/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationVisitor.java index 822391c0b..ef1ee968d 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCGenerationVisitor.java @@ -487,7 +487,7 @@ public class WasmGCGenerationVisitor extends BaseWasmGenerationVisitor { } } - if (!expr.isWeak()) { + if (!expr.isWeak() && context.isStrict()) { result.acceptVisitor(typeInference); var block = new WasmBlock(false); diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCMethodGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCMethodGenerator.java index fcbc4680a..f8f8c549e 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCMethodGenerator.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/gc/methods/WasmGCMethodGenerator.java @@ -83,6 +83,7 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository { private WasmGCClassInfoProvider classInfoProvider; private WasmGCStandardClasses standardClasses; private WasmGCStringProvider strings; + private boolean strict; public WasmGCMethodGenerator( WasmModule module, @@ -95,7 +96,8 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository { WasmGCNameProvider names, Diagnostics diagnostics, WasmGCCustomGeneratorProvider customGenerators, - WasmGCIntrinsicProvider intrinsics + WasmGCIntrinsicProvider intrinsics, + boolean strict ) { this.module = module; this.hierarchy = hierarchy; @@ -108,6 +110,7 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository { this.diagnostics = diagnostics; this.customGenerators = customGenerators; this.intrinsics = intrinsics; + this.strict = strict; } public void setTypeMapper(WasmGCTypeMapper typeMapper) { @@ -332,7 +335,8 @@ public class WasmGCMethodGenerator implements BaseWasmFunctionRepository { strings, customGenerators, intrinsics, - names + names, + strict ); } return context;