mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 00:04:10 -08:00
wasm gc: initialize class initializer globals in global section
This commit is contained in:
parent
638cc8ed15
commit
9b601ac002
|
@ -390,8 +390,10 @@ public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInit
|
|||
if (cls != null && cls.getMethod(CLINIT_METHOD_DESC) != null) {
|
||||
var clinitType = functionTypes.of(null);
|
||||
var wasmName = names.topLevel(names.suggestForClass(name) + "@initializer");
|
||||
classInfo.initializerPointer = new WasmGlobal(wasmName, clinitType.getReference(),
|
||||
new WasmNullConstant(clinitType.getReference()));
|
||||
var initFunction = functionProvider.forStaticMethod(new MethodReference(name, CLINIT_METHOD_DESC));
|
||||
initFunction.setReferenced(true);
|
||||
var ref = new WasmFunctionReference(initFunction);
|
||||
classInfo.initializerPointer = new WasmGlobal(wasmName, clinitType.getReference(), ref);
|
||||
module.globals.add(classInfo.initializerPointer);
|
||||
}
|
||||
}
|
||||
|
@ -418,12 +420,6 @@ public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInit
|
|||
if (virtualTable != null && virtualTable.isConcrete()) {
|
||||
fillVirtualTableMethods(target, classStructure, classInfo.pointer, virtualTable);
|
||||
}
|
||||
if (classInfo.initializerPointer != null) {
|
||||
var initFunction = functionProvider.forStaticMethod(new MethodReference(name,
|
||||
CLINIT_METHOD_DESC));
|
||||
initFunction.setReferenced(true);
|
||||
target.add(new WasmSetGlobal(classInfo.initializerPointer, new WasmFunctionReference(initFunction)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user