Skip to content

Commit

Permalink
wasm gc: initialize class initializer globals in global section
Browse files Browse the repository at this point in the history
  • Loading branch information
konsoletyper committed Aug 30, 2024
1 parent 638cc8e commit 9b601ac
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,10 @@ private void initRegularClass(WasmGCClassInfo classInfo, WasmGCVirtualTable virt
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);
}
}
Expand All @@ -418,12 +420,6 @@ private void initRegularClass(WasmGCClassInfo classInfo, WasmGCVirtualTable virt
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)));
}
};
}

Expand Down

0 comments on commit 9b601ac

Please sign in to comment.