use of org.jikesrvm.classloader.RVMType in project JikesRVM by JikesRVM.
the class ObjectModel method getAlignOffsetWhenCopied.
@Override
public int getAlignOffsetWhenCopied(ObjectReference object) {
TIB tib = org.jikesrvm.objectmodel.ObjectModel.getTIB(object);
RVMType type = tib.getType();
if (type.isArrayType()) {
return org.jikesrvm.objectmodel.ObjectModel.getOffsetForAlignment(type.asArray(), object);
} else {
return org.jikesrvm.objectmodel.ObjectModel.getOffsetForAlignment(type.asClass(), object);
}
}
use of org.jikesrvm.classloader.RVMType in project JikesRVM by JikesRVM.
the class ObjectModel method getObjectSize.
/**
* Return the size of a given object, in bytes
*
* @param object The object whose size is being queried
* @return The size (in bytes) of the given object.
*/
static int getObjectSize(ObjectReference object) {
TIB tib = org.jikesrvm.objectmodel.ObjectModel.getTIB(object);
RVMType type = Magic.objectAsType(tib.getType());
if (type.isClassType())
return org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(object.toObject(), type.asClass());
else
return org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(object.toObject(), type.asArray(), Magic.getArrayLength(object.toObject()));
}
use of org.jikesrvm.classloader.RVMType in project JikesRVM by JikesRVM.
the class ObjectModel method copyTo.
/**
* @param region The start (or an address less than) the region that was reserved for this object.
*/
@Override
@Inline
public Address copyTo(ObjectReference from, ObjectReference to, Address region) {
TIB tib = org.jikesrvm.objectmodel.ObjectModel.getTIB(from);
RVMType type = tib.getType();
int bytes;
boolean copy = (from != to);
if (copy) {
if (type.isClassType()) {
RVMClass classType = type.asClass();
bytes = org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(from.toObject(), classType);
org.jikesrvm.objectmodel.ObjectModel.moveObject(from.toObject(), to.toObject(), bytes, classType);
} else {
RVMArray arrayType = type.asArray();
int elements = Magic.getArrayLength(from.toObject());
bytes = org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(from.toObject(), arrayType, elements);
org.jikesrvm.objectmodel.ObjectModel.moveObject(from.toObject(), to.toObject(), bytes, arrayType);
}
} else {
bytes = getCurrentSize(to);
}
Address start = org.jikesrvm.objectmodel.ObjectModel.objectStartRef(to);
Allocator.fillAlignmentGap(region, start);
return start.plus(bytes);
}
use of org.jikesrvm.classloader.RVMType in project JikesRVM by JikesRVM.
the class TraceInterface method skipOwnFramesAndDump.
@Override
@NoInline
// This can't be uninterruptible --- it is an IO routine
@Interruptible
public Address skipOwnFramesAndDump(ObjectReference typeRef) {
TIB tib = Magic.addressAsTIB(typeRef.toAddress());
RVMMethod m = null;
int bci = -1;
int compiledMethodID = 0;
Offset ipOffset = Offset.zero();
Address fp = Magic.getFramePointer();
Address ip = Magic.getReturnAddressUnchecked(fp);
fp = Magic.getCallerFramePointer(fp);
// This code borrows heavily from RVMThread.dumpStack
final Address STACKFRAME_SENTINEL_FP = StackFrameLayout.getStackFrameSentinelFP();
final int INVISIBLE_METHOD_ID = StackFrameLayout.getInvisibleMethodID();
while (Magic.getCallerFramePointer(fp).NE(STACKFRAME_SENTINEL_FP)) {
compiledMethodID = Magic.getCompiledMethodID(fp);
if (compiledMethodID != INVISIBLE_METHOD_ID) {
// normal java frame(s)
CompiledMethod compiledMethod = CompiledMethods.getCompiledMethod(compiledMethodID);
if (compiledMethod.getCompilerType() != CompiledMethod.TRAP) {
ipOffset = compiledMethod.getInstructionOffset(ip);
m = compiledMethod.getMethod();
if (VM.BuildForOptCompiler && compiledMethod.getCompilerType() == CompiledMethod.OPT) {
OptCompiledMethod optInfo = (OptCompiledMethod) compiledMethod;
/* Opt stack frames may contain multiple inlined methods. */
OptMachineCodeMap map = optInfo.getMCMap();
int iei = map.getInlineEncodingForMCOffset(ipOffset);
if (iei >= 0) {
int[] inlineEncoding = map.inlineEncoding;
boolean allocCall = true;
bci = map.getBytecodeIndexForMCOffset(ipOffset);
for (int j = iei; j >= 0 && allocCall; j = OptEncodedCallSiteTree.getParent(j, inlineEncoding)) {
int mid = OptEncodedCallSiteTree.getMethodID(j, inlineEncoding);
m = MemberReference.getMethodRef(mid).getResolvedMember();
if (!isAllocCall(m.getName().getBytes()))
allocCall = false;
if (j > 0)
bci = OptEncodedCallSiteTree.getByteCodeOffset(j, inlineEncoding);
}
if (!allocCall)
break;
}
} else {
if (!isAllocCall(m.getName().getBytes())) {
BaselineCompiledMethod baseInfo = (BaselineCompiledMethod) compiledMethod;
final int INSTRUCTION_WIDTH = ArchConstants.getInstructionWidth();
bci = baseInfo.findBytecodeIndexForInstruction(ipOffset.toWord().lsh(INSTRUCTION_WIDTH).toOffset());
break;
}
}
}
}
ip = Magic.getReturnAddressUnchecked(fp);
fp = Magic.getCallerFramePointer(fp);
}
if (m != null) {
int allocid = (((compiledMethodID & 0x0000ffff) << 15) ^ ((compiledMethodID & 0xffff0000) >> 16) ^ ipOffset.toInt()) & ~0x80000000;
/* Now print the location string. */
VM.sysWrite('\n');
VM.writeHex(allocid);
VM.sysWrite('-');
VM.sysWrite('>');
VM.sysWrite('[');
VM.writeHex(compiledMethodID);
VM.sysWrite(']');
m.getDeclaringClass().getDescriptor().sysWrite();
VM.sysWrite(':');
m.getName().sysWrite();
m.getDescriptor().sysWrite();
VM.sysWrite(':');
VM.writeHex(bci);
VM.sysWrite('\t');
RVMType type = tib.getType();
type.getDescriptor().sysWrite();
VM.sysWrite('\n');
}
return fp;
}
use of org.jikesrvm.classloader.RVMType in project JikesRVM by JikesRVM.
the class Barriers method initializeObjectReferenceFields.
/**
* Initializes the reference fields of a given object reference. Most collectors
* won't need to use this method.
* <p>
* The Poisoned collector uses this method. Without using this method,
* all reference fields would be initialized to {@code Word.zero()}. However,
* the value for {@code null} in the Poisoned collector is actually
* {@code Poisoned.poison(ObjectReference.fromObject(null))}, which is
* {@code Word.one()} at the time of this writing. Not initializing the value
* to the real value of {@code null} leads to problems when the value isn't
* explicitly initialized before it is read (i.e. when the programmer relies
* on the JVM to initialize the value to {@code null}). This can occur when
* using intrinsics such as compare-and-swap.
*
* @param ref the object that has the reference field(s)
* @param tibAddr the object's type TIB
*/
@Override
public final void initializeObjectReferenceFields(ObjectReference ref, ObjectReference tibAddr) {
ObjectReference nullValue = Word.zero().toAddress().toObjectReference();
// location is actually unknown. I suppose we could try mapping the
// reference offsets to field offsets if we really needed it.
Word location = Word.zero();
TIB tib = Magic.addressAsTIB(tibAddr.toAddress());
RVMType type = tib.getType();
int[] referenceOffsets = type.getReferenceOffsets();
if (referenceOffsets == RVMType.REFARRAY_OFFSET_ARRAY) {
if (VM.VERIFY_ASSERTIONS)
VM.assertions._assert(type.isArrayType() && type.asArray().getElementType().isReferenceType());
int arrayLength = ObjectModel.getArrayLength(ref.toObject());
for (int i = 0; i < arrayLength; i++) {
Word offset = Offset.fromIntSignExtend(i << LOG_BYTES_IN_ADDRESS).toWord();
Address slotAddress = ref.toAddress().plus(i << LOG_BYTES_IN_ADDRESS);
VM.activePlan.mutator().objectReferenceWrite(ref, slotAddress, nullValue, offset, location, ARRAY_ELEMENT);
}
} else {
if (VM.VERIFY_ASSERTIONS)
VM.assertions._assert(type.isClassType() || (type.isArrayType() && !type.asArray().getElementType().isReferenceType()));
for (int i = 0; i < referenceOffsets.length; i++) {
Word offset = Offset.fromIntSignExtend(referenceOffsets[i]).toWord();
Address slotAddress = ref.toAddress().plus(referenceOffsets[i]);
VM.activePlan.mutator().objectReferenceWrite(ref, slotAddress, nullValue, offset, location, INSTANCE_FIELD);
}
}
}
Aggregations