Search in sources :

Example 91 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class Lock method unlockHeavy.

/**
 * Releases this heavy-weight lock on the indicated object.
 *
 * @param o the object to be unlocked
 */
@Unpreemptible
public void unlockHeavy(Object o) {
    boolean deflated = false;
    // Note: thread switching is not allowed while mutex is held.
    mutex.lock();
    RVMThread me = RVMThread.getCurrentThread();
    if (ownerId != me.getLockingId()) {
        // thread-switching benign
        mutex.unlock();
        raiseIllegalMonitorStateException("heavy unlocking", o);
    }
    recursionCount--;
    if (0 < recursionCount) {
        // thread-switching benign
        mutex.unlock();
        return;
    }
    if (STATS)
        unlockOperations++;
    ownerId = 0;
    RVMThread toAwaken = entering.dequeue();
    if (toAwaken == null && entering.isEmpty() && waiting.isEmpty()) {
        // heavy lock can be deflated
        // Possible project: decide on a heuristic to control when lock should be deflated
        Offset lockOffset = Magic.getObjectType(o).getThinLockOffset();
        if (!lockOffset.isMax()) {
            // deflate heavy lock
            deflate(o, lockOffset);
            deflated = true;
        }
    }
    // does a Magic.sync();  (thread-switching benign)
    mutex.unlock();
    if (toAwaken != null) {
        toAwaken.monitor().lockedBroadcastNoHandshake();
    }
}
Also used : Offset(org.vmmagic.unboxed.Offset) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 92 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_invoke_compiledmethod.

/**
 * Emit code to invoke a compiled method (with known jtoc offset).
 * Treat it like a resolved invoke static, but take care of
 * this object in the case.<p>
 *
 * I havenot thought about GCMaps for invoke_compiledmethod
 * TODO: Figure out what the above GCMaps comment means and fix it!
 */
@Override
protected void emit_invoke_compiledmethod(CompiledMethod cm) {
    Offset methOffset = cm.getOsrJTOCoffset();
    asm.emitLAddrToc(T0, methOffset);
    asm.emitMTCTR(T0);
    boolean takeThis = !cm.method.isStatic();
    MethodReference ref = cm.method.getMemberRef().asMethodReference();
    genMoveParametersToRegisters(takeThis, ref);
    asm.emitBCCTRL();
    genPopParametersAndPushReturnValue(takeThis, ref);
}
Also used : MethodReference(org.jikesrvm.classloader.MethodReference) Offset(org.vmmagic.unboxed.Offset)

Example 93 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_resolved_getfield.

@Override
protected void emit_resolved_getfield(FieldReference fieldRef) {
    RVMField field = fieldRef.peekResolvedField();
    TypeReference fieldType = fieldRef.getFieldContentsType();
    Offset fieldOffset = field.getOffset();
    if (NEEDS_OBJECT_GETFIELD_BARRIER && fieldType.isReferenceType() && !field.isUntraced()) {
        Barriers.compileGetfieldBarrierImm(this, fieldOffset, fieldRef.getId());
        discardSlots(1);
        pushAddr(T0);
    } else {
        // T1 = object reference
        popAddr(T1);
        if (fieldType.isReferenceType() || fieldType.isWordLikeType()) {
            // 32/64bit reference/word load
            asm.emitLAddrOffset(T0, T1, fieldOffset);
            pushAddr(T0);
        } else if (fieldType.isBooleanType()) {
            // 8bit unsigned load
            asm.emitLBZoffset(T0, T1, fieldOffset);
            pushInt(T0);
        } else if (fieldType.isByteType()) {
            // 8bit signed load
            asm.emitLBZoffset(T0, T1, fieldOffset);
            // sign extend
            asm.emitEXTSB(T0, T0);
            pushInt(T0);
        } else if (fieldType.isShortType()) {
            // 16bit signed load
            asm.emitLHAoffset(T0, T1, fieldOffset);
            pushInt(T0);
        } else if (fieldType.isCharType()) {
            // 16bit unsigned load
            asm.emitLHZoffset(T0, T1, fieldOffset);
            pushInt(T0);
        } else if (fieldType.isIntType() || fieldType.isFloatType()) {
            // 32bit load
            asm.emitLIntOffset(T0, T1, fieldOffset);
            pushInt(T0);
        } else {
            // 64bit load
            if (VM.VerifyAssertions)
                VM._assert(fieldType.isLongType() || fieldType.isDoubleType());
            asm.emitLFDoffset(F0, T1, fieldOffset);
            pushDouble(F0);
        }
    }
    if (field.isVolatile()) {
        // JMM: post-barrier when first operation
        // LoadLoad and LoadStore barriers.
        asm.emitHWSYNC();
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField) TypeReference(org.jikesrvm.classloader.TypeReference) Offset(org.vmmagic.unboxed.Offset)

Example 94 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_resolved_new.

/*
   * other object model functions
   */
@Override
protected void emit_resolved_new(RVMClass typeRef) {
    int instanceSize = typeRef.getInstanceSize();
    Offset tibOffset = typeRef.getTibOffset();
    int whichAllocator = MemoryManager.pickAllocator(typeRef, method);
    int align = ObjectModel.getAlignment(typeRef);
    int offset = ObjectModel.getOffsetForAlignment(typeRef, false);
    int site = MemoryManager.getAllocationSite(true);
    asm.emitLAddrToc(T0, Entrypoints.resolvedNewScalarMethod.getOffset());
    asm.emitMTCTR(T0);
    asm.emitLVAL(T0, instanceSize);
    asm.emitLAddrToc(T1, tibOffset);
    asm.emitLVAL(T2, typeRef.hasFinalizer() ? 1 : 0);
    asm.emitLVAL(T3, whichAllocator);
    asm.emitLVAL(T4, align);
    asm.emitLVAL(T5, offset);
    asm.emitLVAL(T6, site);
    asm.emitBCCTRL();
    pushAddr(T0);
}
Also used : Offset(org.vmmagic.unboxed.Offset)

Example 95 with Offset

use of org.vmmagic.unboxed.Offset in project JikesRVM by JikesRVM.

the class BaselineCompilerImpl method emit_resolved_getstatic.

@Override
protected void emit_resolved_getstatic(FieldReference fieldRef) {
    RVMField field = fieldRef.peekResolvedField();
    Offset fieldOffset = field.getOffset();
    TypeReference fieldType = fieldRef.getFieldContentsType();
    if (NEEDS_OBJECT_GETSTATIC_BARRIER && fieldType.isReferenceType() && !field.isUntraced()) {
        Barriers.compileGetstaticBarrierImm(this, fieldOffset, fieldRef.getId());
        pushAddr(T0);
    } else if (fieldRef.getSize() <= BYTES_IN_INT) {
        // field is one word
        asm.emitLIntToc(T0, fieldOffset);
        pushInt(T0);
    } else {
        // field is two words (double or long ( or address on PPC64))
        if (VM.VerifyAssertions)
            VM._assert(fieldRef.getSize() == BYTES_IN_LONG);
        if (VM.BuildFor64Addr && fieldRef.getNumberOfStackSlots() == 1) {
            // address only 1 stackslot!!!
            asm.emitLAddrToc(T0, fieldOffset);
            pushAddr(T0);
        } else {
            asm.emitLFDtoc(F0, fieldOffset, T0);
            pushDouble(F0);
        }
    }
    if (field.isVolatile()) {
        // JMM: post-barrier when first operation
        // LoadLoad and LoadStore barriers.
        asm.emitHWSYNC();
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField) TypeReference(org.jikesrvm.classloader.TypeReference) Offset(org.vmmagic.unboxed.Offset)

Aggregations

Offset (org.vmmagic.unboxed.Offset)215 Address (org.vmmagic.unboxed.Address)48 Inline (org.vmmagic.pragma.Inline)38 Entrypoint (org.vmmagic.pragma.Entrypoint)32 ObjectReference (org.vmmagic.unboxed.ObjectReference)21 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)20 TypeReference (org.jikesrvm.classloader.TypeReference)17 RVMField (org.jikesrvm.classloader.RVMField)14 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)13 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)13 NoInline (org.vmmagic.pragma.NoInline)13 RVMMethod (org.jikesrvm.classloader.RVMMethod)11 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)10 Word (org.vmmagic.unboxed.Word)10 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)9 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)9 RVMType (org.jikesrvm.classloader.RVMType)8 Register (org.jikesrvm.compilers.opt.ir.Register)8 RVMClass (org.jikesrvm.classloader.RVMClass)7 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)7