protected void emitStaticInitializerCalls(NativeStream nativeOs,
VmType<?>[] bootClasses, Object clInitCaller)
throws ClassNotFoundException {
final X86BinaryAssembler os = (X86BinaryAssembler) nativeOs;
X86BinaryAssembler.ObjectInfo initCallerObject = os
.startObject(loadClass(VmMethodCode.class));
os.setObjectRef(clInitCaller);
// Call VmClass.loadFromBootClassArray
final VmType<?> vmClassClass = loadClass(VmType.class);
final VmMethod lfbcaMethod = vmClassClass.getMethod(
"loadFromBootClassArray", "([Lorg/jnode/vm/classmgr/VmType;)V");
final VmType<?> vmMethodClass = loadClass(VmMethod.class);
final VmInstanceField nativeCodeField = (VmInstanceField) vmMethodClass
.getField("nativeCode");
final GPR aax = os.isCode32() ? (GPR) X86Register.EAX : X86Register.RAX;
final GPR abx = os.isCode32() ? (GPR) X86Register.EBX : X86Register.RBX;
os.writeMOV_Const(aax, bootClasses);
os.writePUSH(aax);
os.writeMOV_Const(aax, lfbcaMethod);
os.writeMOV(abx.getSize(), abx, aax, nativeCodeField.getOffset());
os.writeCALL(abx);
// Now call all static initializers
for (int i = 0; (i < bootClasses.length); i++) {
VmType<?> vmClass = bootClasses[i];
if ((vmClass instanceof VmClassType)
&& (((VmClassType<?>) vmClass).getInstanceCount() > 0)) {
VmMethod clInit = vmClass.getMethod("<clinit>", "()V");
if (clInit != null) {
// os.setObjectRef(clInitCaller + "$$" + vmClass.getName());
log("Missing static initializer in class "
+ vmClass.getName(), Project.MSG_WARN);
}
}
}
os.writeRET(); // RET
os.align(4096);
initCallerObject.markEnd();
}