From 103affa3923c55ed341605d371706ae0d9817cae Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 24 Mar 2019 22:51:17 +0300 Subject: [PATCH] Partially revert previous commit. Generate calls to methods, since corresponding analyzer guarantees proper initialization order. --- .../org/teavm/backend/javascript/rendering/Renderer.java | 2 +- core/src/main/java/org/teavm/vm/TeaVM.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java b/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java index f1db7d080..6165a5369 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/Renderer.java @@ -379,7 +379,7 @@ public class Renderer implements RenderingManager { try { MethodReader clinit = classSource.get(cls.getName()).getMethod(CLINIT_METHOD); - if (clinit != null) { + if (clinit != null && context.isDynamicInitializer(cls.getName())) { renderCallClinit(clinit, cls); } if (!cls.getClassHolder().getModifiers().contains(ElementModifier.INTERFACE)) { diff --git a/core/src/main/java/org/teavm/vm/TeaVM.java b/core/src/main/java/org/teavm/vm/TeaVM.java index d748faa85..c55fb8aed 100644 --- a/core/src/main/java/org/teavm/vm/TeaVM.java +++ b/core/src/main/java/org/teavm/vm/TeaVM.java @@ -75,6 +75,7 @@ import org.teavm.model.ValueType; import org.teavm.model.analysis.ClassInitializerAnalysis; import org.teavm.model.analysis.ClassInitializerInfo; import org.teavm.model.instructions.InitClassInstruction; +import org.teavm.model.instructions.InvokeInstruction; import org.teavm.model.optimization.ArrayUnwrapMotion; import org.teavm.model.optimization.ClassInitElimination; import org.teavm.model.optimization.ConstantConditionElimination; @@ -522,9 +523,9 @@ public class TeaVM implements TeaVMHost, ServiceRepository { BasicBlock block = program.basicBlockAt(0); Instruction first = block.getFirstInstruction(); for (String className : classInitializerInfo.getInitializationOrder()) { - InitClassInstruction clinit = new InitClassInstruction(); - clinit.setClassName(className); - first.insertPrevious(clinit); + InvokeInstruction invoke = new InvokeInstruction(); + invoke.setMethod(new MethodReference(className, "", ValueType.VOID)); + first.insertPrevious(invoke); } }