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();
}
}
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);
}
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();
}
}
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);
}
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();
}
}
Aggregations