use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.
the class InterfaceInvocation method buildITable.
private static ITable buildITable(RVMClass C, RVMClass I) {
RVMMethod[] interfaceMethods = I.getDeclaredMethods();
TIB tib = C.getTypeInformationBlock();
ITable iTable = MemoryManager.newITable(interfaceMethods.length + 1);
iTable.set(0, I);
for (RVMMethod im : interfaceMethods) {
if (im.isClassInitializer())
continue;
if (VM.VerifyAssertions)
VM._assert(im.isPublic() && im.isAbstract());
RVMMethod vm = C.findVirtualMethod(im.getName(), im.getDescriptor());
// Since the methods in question take no arguments, we can get away with this.
if (vm == null || vm.isAbstract()) {
vm = Entrypoints.raiseAbstractMethodError;
} else if (!vm.isPublic()) {
vm = Entrypoints.raiseIllegalAccessError;
}
if (vm.isStatic()) {
vm.compile();
iTable.set(getITableIndex(I, im.getName(), im.getDescriptor()), vm.getCurrentEntryCodeArray());
} else {
iTable.set(getITableIndex(I, im.getName(), im.getDescriptor()), tib.getVirtualMethod(vm.getOffset()));
}
}
return iTable;
}
use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.
the class InterfaceInvocation method invokeInterface.
/*
* PART I: runtime routines to implement the invokeinterface bytecode.
* these routines are called from the generated code
* as part of the interface invocation sequence.
*/
/**
* Resolve an interface method call.
* This routine is never called by the IMT-based dispatching code.
* It is only called for directly indexed ITables when the table
* index was unknown at compile time (i.e. the target Interface was not loaded).
*
* @param target object to which interface method is to be applied
* @param mid id of the MemberReference for the target interface method.
* @return machine code corresponding to desired interface method
*/
@Entrypoint
public static CodeArray invokeInterface(Object target, int mid) throws IncompatibleClassChangeError {
MethodReference mref = MemberReference.getMemberRef(mid).asMethodReference();
RVMMethod sought = mref.resolveInterfaceMethod();
RVMClass I = sought.getDeclaringClass();
RVMClass C = Magic.getObjectType(target).asClass();
if (VM.BuildForITableInterfaceInvocation) {
TIB tib = C.getTypeInformationBlock();
ITable iTable = findITable(tib, I.getInterfaceId());
return iTable.getCode(getITableIndex(I, mref.getName(), mref.getDescriptor()));
} else {
if (!RuntimeEntrypoints.isAssignableWith(I, C))
throw new IncompatibleClassChangeError();
RVMMethod found = C.findVirtualMethod(sought.getName(), sought.getDescriptor());
if (found == null)
throw new IncompatibleClassChangeError();
return found.getCurrentEntryCodeArray();
}
}
use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.
the class DebugUtil method validRef.
@Uninterruptible
public static boolean validRef(ObjectReference ref) {
if (ref.isNull())
return true;
if (!Space.isMappedObject(ref)) {
VM.sysWrite("validRef: REF outside heap, ref = ");
VM.sysWrite(ref);
VM.sysWriteln();
Space.printVMMap();
return false;
}
if (MOVES_OBJECTS) {
/*
TODO: Work out how to check if forwarded
if (Plan.isForwardedOrBeingForwarded(ref)) {
// TODO: actually follow forwarding pointer
// (need to bound recursion when things are broken!!)
return true;
}
*/
}
TIB tib = ObjectModel.getTIB(ref);
Address tibAddr = Magic.objectAsAddress(tib);
if (!Space.isMappedObject(ObjectReference.fromObject(tib))) {
VM.sysWrite("validRef: TIB outside heap, ref = ");
VM.sysWrite(ref);
VM.sysWrite(" tib = ");
VM.sysWrite(tibAddr);
VM.sysWriteln();
ObjectModel.dumpHeader(ref);
return false;
}
if (tibAddr.isZero()) {
VM.sysWrite("validRef: TIB is Zero! ");
VM.sysWrite(ref);
VM.sysWriteln();
ObjectModel.dumpHeader(ref);
return false;
}
if (tib.length() == 0) {
VM.sysWrite("validRef: TIB length zero, ref = ");
VM.sysWrite(ref);
VM.sysWrite(" tib = ");
VM.sysWrite(tibAddr);
VM.sysWriteln();
ObjectModel.dumpHeader(ref);
return false;
}
ObjectReference type = ObjectReference.fromObject(tib.getType());
if (!validType(type)) {
VM.sysWrite("validRef: invalid TYPE, ref = ");
VM.sysWrite(ref);
VM.sysWrite(" tib = ");
VM.sysWrite(Magic.objectAsAddress(tib));
VM.sysWrite(" type = ");
VM.sysWrite(type);
VM.sysWriteln();
ObjectModel.dumpHeader(ref);
return false;
}
return true;
}
use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.
the class MemoryManager method newNonMovingShortArray.
/**
* Allocates a non moving short array.
*
* @param size The size of the array
* @return the new non moving short array
*/
@NoInline
@Interruptible
public static short[] newNonMovingShortArray(int size) {
if (!VM.runningVM) {
return new short[size];
}
RVMArray arrayType = RVMArray.ShortArray;
int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
int align = ObjectModel.getAlignment(arrayType);
int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
int width = arrayType.getLogElementSize();
TIB arrayTib = arrayType.getTypeInformationBlock();
return (short[]) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.
the class MemoryManager method allocateCode.
/**
* Allocate a CodeArray into a code space.
* Currently the interface is fairly primitive;
* just the number of instructions in the code array and a boolean
* to indicate hot or cold code.
* @param numInstrs number of instructions
* @param isHot is this a request for hot code space allocation?
* @return The array
*/
@NoInline
@Interruptible
public static CodeArray allocateCode(int numInstrs, boolean isHot) {
RVMArray type = RVMType.CodeArrayType;
int headerSize = ObjectModel.computeArrayHeaderSize(type);
int align = ObjectModel.getAlignment(type);
int offset = ObjectModel.getOffsetForAlignment(type, false);
int width = type.getLogElementSize();
TIB tib = type.getTypeInformationBlock();
int allocator = isHot ? Plan.ALLOC_HOT_CODE : Plan.ALLOC_COLD_CODE;
return (CodeArray) allocateArray(numInstrs, width, headerSize, tib, allocator, align, offset, Plan.DEFAULT_SITE);
}
Aggregations