Partially revert previous <clinit> commit.

Generate calls to <clinit> methods, since corresponding analyzer
guarantees proper initialization order.
This commit is contained in:
Alexey Andreev 2019-03-24 22:51:17 +03:00
parent cd008f8a52
commit 103affa392
2 changed files with 5 additions and 4 deletions

View File

@ -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)) {

View File

@ -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, "<clinit>", ValueType.VOID));
first.insertPrevious(invoke);
}
}