Search in sources :

Example 11 with TIB

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;
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) CodeConstantOperand(org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) NullConstantOperand(org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) RVMMethod(org.jikesrvm.classloader.RVMMethod) NullConstantOperand(org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) ConditionOperand(org.jikesrvm.compilers.opt.ir.operand.ConditionOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) CodeConstantOperand(org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) NullConstantOperand(org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand) BranchProfileOperand(org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) TrapCodeOperand(org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) ConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) TIBConstantOperand(org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand) RVMType(org.jikesrvm.classloader.RVMType) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) TIB(org.jikesrvm.objectmodel.TIB) CodeConstantOperand(org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand)

Example 12 with TIB

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);
    }
}
Also used : RVMType(org.jikesrvm.classloader.RVMType) TIB(org.jikesrvm.objectmodel.TIB)

Example 13 with TIB

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()));
}
Also used : RVMType(org.jikesrvm.classloader.RVMType) TIB(org.jikesrvm.objectmodel.TIB)

Example 14 with TIB

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);
}
Also used : Address(org.vmmagic.unboxed.Address) RVMArray(org.jikesrvm.classloader.RVMArray) RVMType(org.jikesrvm.classloader.RVMType) TIB(org.jikesrvm.objectmodel.TIB) RVMClass(org.jikesrvm.classloader.RVMClass) Inline(org.vmmagic.pragma.Inline)

Example 15 with TIB

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;
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) OptMachineCodeMap(org.jikesrvm.compilers.opt.runtimesupport.OptMachineCodeMap) Address(org.vmmagic.unboxed.Address) RVMType(org.jikesrvm.classloader.RVMType) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) TIB(org.jikesrvm.objectmodel.TIB) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Offset(org.vmmagic.unboxed.Offset) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

TIB (org.jikesrvm.objectmodel.TIB)36 Entrypoint (org.vmmagic.pragma.Entrypoint)16 RVMArray (org.jikesrvm.classloader.RVMArray)14 RVMType (org.jikesrvm.classloader.RVMType)13 NoInline (org.vmmagic.pragma.NoInline)9 Interruptible (org.vmmagic.pragma.Interruptible)8 Address (org.vmmagic.unboxed.Address)7 Test (org.junit.Test)5 CodeArray (org.jikesrvm.compilers.common.CodeArray)4 ITable (org.jikesrvm.objectmodel.ITable)4 RVMClass (org.jikesrvm.classloader.RVMClass)3 RVMMethod (org.jikesrvm.classloader.RVMMethod)3 Offset (org.vmmagic.unboxed.Offset)3 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 IMT (org.jikesrvm.objectmodel.IMT)2 ITableArray (org.jikesrvm.objectmodel.ITableArray)2 Inline (org.vmmagic.pragma.Inline)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1