*/
public EntryPoints(VmClassLoader loader, VmHeapManager heapManager, int magic) {
try {
this.magic = magic;
// VmMember class
final VmType vmMemberType = loader.loadClass(
"org.jnode.vm.classmgr.VmMember", true);
this.vmMemberDeclaringClassField = (VmInstanceField) testField(vmMemberType
.getField("declaringClass"));
// SoftByteCode
this.vmSoftByteCodesClass = loader.loadClass(
"org.jnode.vm.SoftByteCodes", true);
anewarrayMethod = testMethod(vmSoftByteCodesClass.getMethod(
"anewarray",
"(Lorg/jnode/vm/classmgr/VmType;I)Ljava/lang/Object;"));
allocArrayMethod = testMethod(vmSoftByteCodesClass.getMethod(
"allocArray",
"(Lorg/jnode/vm/classmgr/VmType;I)Ljava/lang/Object;"));
allocMultiArrayMethod = testMethod(vmSoftByteCodesClass.getMethod(
"allocMultiArray",
"(Lorg/jnode/vm/classmgr/VmType;[I)Ljava/lang/Object;"));
allocPrimitiveArrayMethod = testMethod(vmSoftByteCodesClass
.getMethod("allocPrimitiveArray", "(Lorg/jnode/vm/classmgr/VmType;II)Ljava/lang/Object;"));
resolveFieldMethod = testMethod(vmSoftByteCodesClass.getMethod("resolveField",
"(Lorg/jnode/vm/classmgr/VmMethod;Lorg/jnode/vm/classmgr/VmConstFieldRef;Z)" +
"Lorg/jnode/vm/classmgr/VmField;"));
resolveMethodMethod = testMethod(vmSoftByteCodesClass.getMethod("resolveMethod",
"(Lorg/jnode/vm/classmgr/VmMethod;Lorg/jnode/vm/classmgr/VmConstMethodRef;)" +
"Lorg/jnode/vm/classmgr/VmMethod;"));
resolveClassMethod = testMethod(vmSoftByteCodesClass.getMethod("resolveClass",
"(Lorg/jnode/vm/classmgr/VmConstClass;)Lorg/jnode/vm/classmgr/VmType;"));
allocObjectMethod = testMethod(vmSoftByteCodesClass.getMethod("allocObject",
"(Lorg/jnode/vm/classmgr/VmType;I)Ljava/lang/Object;"));
classCastFailedMethod = testMethod(vmSoftByteCodesClass.getMethod(
"classCastFailed", "(Ljava/lang/Object;Lorg/jnode/vm/classmgr/VmType;)V"));
throwArrayOutOfBounds = testMethod(vmSoftByteCodesClass.getMethod(
"throwArrayOutOfBounds", "(Ljava/lang/Object;I)V"));
getClassForVmTypeMethod = testMethod(vmSoftByteCodesClass.getMethod("getClassForVmType",
"(Lorg/jnode/vm/classmgr/VmType;)Ljava/lang/Class;"));
// Write barrier
writeBarrier = (heapManager != null) ? heapManager
.getWriteBarrier() : null;
if (writeBarrier != null) {
final VmType wbClass = loader.loadClass(writeBarrier.getClass().getName(), true);
arrayStoreWriteBarrier = testMethod(wbClass.getMethod(
"arrayStoreWriteBarrier",
"(Ljava/lang/Object;ILjava/lang/Object;)V"));
putfieldWriteBarrier = testMethod(wbClass.getMethod(
"putfieldWriteBarrier",
"(Ljava/lang/Object;ILjava/lang/Object;)V"));
putstaticWriteBarrier = testMethod(wbClass.getMethod(
"putstaticWriteBarrier", "(ILjava/lang/Object;)V"));
} else {
arrayStoreWriteBarrier = null;
putfieldWriteBarrier = null;
putstaticWriteBarrier = null;
}
// MonitorManager
this.vmMonitorManagerClass = loader.loadClass("org.jnode.vm.scheduler.MonitorManager", true);
monitorEnterMethod = testMethod(vmMonitorManagerClass.getMethod("monitorEnter", "(Ljava/lang/Object;)V"));
monitorExitMethod = testMethod(vmMonitorManagerClass.getMethod("monitorExit", "(Ljava/lang/Object;)V"));
// MathSupport
final VmType vmClass = loader.loadClass("org.jnode.vm.MathSupport", true);
ldivMethod = testMethod(vmClass.getMethod("ldiv", "(JJ)J"));
lremMethod = testMethod(vmClass.getMethod("lrem", "(JJ)J"));
// VmInstanceField
this.vmInstanceFieldClass = loader.loadClass("org.jnode.vm.classmgr.VmInstanceField", true);
vmFieldOffsetField = (VmInstanceField) testField(vmInstanceFieldClass.getField("offset"));
// VmStaticField
this.vmStaticFieldClass = loader.loadClass("org.jnode.vm.classmgr.VmStaticField", true);
vmFieldStaticsIndexField = (VmInstanceField) testField(vmStaticFieldClass.getField("staticsIndex"));
// VmInstanceMethod
this.vmInstanceMethodClass = loader.loadClass("org.jnode.vm.classmgr.VmInstanceMethod", true);
vmMethodTibOffsetField = (VmInstanceField) testField(vmInstanceMethodClass.getField("tibOffset"));
// VmMethodCode
this.vmMethodCodeClass = loader.loadClass("org.jnode.vm.classmgr.VmMethodCode", true);
vmMethodSelectorField = (VmInstanceField) testField(vmInstanceMethodClass.getField("selector"));
vmMethodNativeCodeField = (VmInstanceField) testField(vmInstanceMethodClass.getField("nativeCode"));
// VmConstIMethodRef
final VmType cimrClass = loader.loadClass("org.jnode.vm.classmgr.VmConstIMethodRef", true);
this.vmConstIMethodRefSelectorField = (VmInstanceField) testField(cimrClass.getField("selector"));
// VmProcessor
final VmType processorClass = loader.loadClass("org.jnode.vm.scheduler.VmProcessor", true);
vmThreadSwitchIndicatorOffset =
((VmInstanceField) testField(processorClass.getField("threadSwitchIndicator"))).getOffset();
vmProcessorMeField = (VmInstanceField) testField(processorClass.getField("me"));
vmProcessorStackEnd = (VmInstanceField) testField(processorClass.getField("stackEnd"));
vmProcessorSharedStaticsTable = (VmInstanceField) testField(processorClass.getField("staticsTable"));
vmProcessorIsolatedStaticsTable = (VmInstanceField) testField(processorClass
.getField("isolatedStaticsTable"));
// VmType
final VmType typeClass = loader.loadClass("org.jnode.vm.classmgr.VmType", true);
vmTypeInitialize = testMethod(typeClass.getMethod("initialize", "()V"));
vmTypeModifiers = (VmInstanceField) testField(typeClass.getField("modifiers"));
vmTypeState = (VmInstanceField) testField(typeClass.getField("state"));
vmTypeCp = (VmInstanceField) testField(typeClass.getField("cp"));
// VmCP
final VmType cpClass = loader.loadClass("org.jnode.vm.classmgr.VmCP", true);
vmCPCp = (VmInstanceField) testField(cpClass.getField("cp"));
// VmProcessor
// VmThread
final VmType vmThreadClass = loader.loadClass("org.jnode.vm.scheduler.VmThread", true);
systemExceptionMethod = testMethod(vmThreadClass.getMethod("systemException", "(II)Ljava/lang/Throwable;"));
// VmMethod
final VmType vmMethodClass = loader.loadClass("org.jnode.vm.classmgr.VmMethod", true);
recompileMethod = testMethod(vmMethodClass.getDeclaredMethod("recompileMethod", "(II)V"));
} catch (ClassNotFoundException ex) {
throw new NoClassDefFoundError(ex.getMessage());
}
}