use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.
the class Simplifier method refLoad.
private static DefUseEffect refLoad(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_TIB_OPS) {
Operand base = Load.getAddress(s);
if (base.isTIBConstant()) {
TIBConstantOperand tib = base.asTIBConstant();
Operand offset = Load.getOffset(s);
if (tib.value.isInstantiated() && offset.isConstant()) {
// Reading from a fixed offset from an effectively
// constant array
int intOffset;
if (offset.isIntConstant()) {
intOffset = offset.asIntConstant().value;
} else {
intOffset = offset.asAddressConstant().value.toInt();
}
int intSlot = intOffset >> LOG_BYTES_IN_ADDRESS;
// Create appropriate constant operand for TIB slot
ConstantOperand result;
TIB tibArray = tib.value.getTypeInformationBlock();
if (tibArray.slotContainsTib(intSlot)) {
RVMType typeOfTIB = ((TIB) tibArray.get(intSlot)).getType();
result = new TIBConstantOperand(typeOfTIB);
} else if (tibArray.slotContainsCode(intSlot)) {
// some virtual calls go via the JTOC
if (opts.H2L_CALL_VIA_JTOC) {
RVMMethod method = tib.value.getTIBMethodAtSlot(intSlot);
result = new CodeConstantOperand(method);
} else {
return DefUseEffect.UNCHANGED;
}
} else {
if (tibArray.get(intSlot) == null) {
result = new NullConstantOperand();
} else {
result = new ObjectConstantOperand(tibArray.get(intSlot), Offset.zero());
}
}
Move.mutate(s, REF_MOVE, Load.getClearResult(s), result);
return DefUseEffect.MOVE_FOLDED;
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.jikesrvm.objectmodel.TIB 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.objectmodel.TIB 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.objectmodel.TIB 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.objectmodel.TIB 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;
}
Aggregations