use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class ArchBridgeDataExtractorTest method longParametersInBridgeMethodsAreProcessedCorrectlyFor64BitAddressing.
@Test
@Category(Requires64BitAddressing.class)
public void longParametersInBridgeMethodsAreProcessedCorrectlyFor64BitAddressing() {
TypeReference[] types = { TypeReference.Long, TypeReference.JavaLangObject };
bridge.setBridgeParameterTypes(types);
Word expected = Word.fromIntSignExtend(11);
int length = 4;
WordArray stackFrame = createNonMovableWordArray(length);
int bridgeRegLocSlotIndex = stackFrame.length() - 1;
stackFrame.set(bridgeRegLocSlotIndex - 1, expected);
Address brideRegLoc = Magic.objectAsAddress(stackFrame).plus(bridgeRegLocSlotIndex * BYTES_IN_WORD);
bridge.setBridgeRegisterLocation(brideRegLoc);
Address bridgeParameterAddr = bridge.getNextBridgeParameterAddress();
Word bridgeParameter = bridgeParameterAddr.loadWord();
assertEquals(expected, bridgeParameter);
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class BaselineExecutionStateExtractor method getVariableValue.
/* go over local/stack array, and build VariableElement. */
private static void getVariableValue(byte[] stack, Offset offset, byte[] types, ArchBaselineCompiledMethod compiledMethod, boolean kind, ExecutionState state) {
int size = types.length;
Offset vOffset = offset;
for (int i = 0; i < size; i++) {
if (VM.TraceOnStackReplacement) {
Word content = Magic.getWordAtOffset(stack, vOffset.minus(BYTES_IN_ADDRESS));
VM.sysWrite("0x", vOffset.minus(BYTES_IN_ADDRESS), " 0x");
VM.sysWriteln(content);
if ((types[i] == LongTypeCode) || (types[i] == DoubleTypeCode)) {
content = Magic.getWordAtOffset(stack, vOffset.minus(2 * BYTES_IN_ADDRESS));
VM.sysWrite("0x", vOffset.minus(2 * BYTES_IN_ADDRESS), " 0x");
VM.sysWriteln(content);
}
}
switch(types[i]) {
case VoidTypeCode:
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
break;
case BooleanTypeCode:
case ByteTypeCode:
case ShortTypeCode:
case CharTypeCode:
case IntTypeCode:
case FloatTypeCode:
{
int value = Magic.getIntAtOffset(stack, vOffset.minus(BYTES_IN_STACKSLOT));
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
byte tcode = (types[i] == FloatTypeCode) ? FLOAT : INT;
state.add(new VariableElement(kind, i, tcode, value));
break;
}
case LongTypeCode:
case DoubleTypeCode:
{
// KV: this code would be nicer if VoidTypeCode would always follow a 64-bit value. Rigth now for LOCAL it follows, for STACK it proceeds
Offset memoff = (kind == LOCAL) ? vOffset.minus(2 * BYTES_IN_STACKSLOT) : vOffset.minus(BYTES_IN_STACKSLOT);
long value = Magic.getLongAtOffset(stack, memoff);
byte tcode = (types[i] == LongTypeCode) ? LONG : DOUBLE;
state.add(new VariableElement(kind, i, tcode, value));
if (kind == LOCAL) {
// KV:VoidTypeCode is next
vOffset = vOffset.minus(2 * BYTES_IN_STACKSLOT);
i++;
} else {
// KV:VoidTypeCode was already in front
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
}
break;
}
case ReturnAddressTypeCode:
{
VM.disableGC();
Address rowIP = Magic.objectAsAddress(stack).loadAddress(vOffset);
Offset ipOffset = compiledMethod.getInstructionOffset(rowIP);
VM.enableGC();
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
if (VM.TraceOnStackReplacement) {
Offset ipIndex = ipOffset.toWord().rsha(LG_INSTRUCTION_WIDTH).toOffset();
VM.sysWrite("baseline ret_addr ip ", ipIndex, " --> ");
}
int bcIndex = compiledMethod.findBytecodeIndexForInstruction(ipOffset.plus(INSTRUCTION_WIDTH));
if (VM.TraceOnStackReplacement) {
VM.sysWriteln(" bc " + bcIndex);
}
state.add(new VariableElement(kind, i, RET_ADDR, bcIndex));
break;
}
case ClassTypeCode:
case ArrayTypeCode:
{
VM.disableGC();
Object ref = Magic.getObjectAtOffset(stack, vOffset.minus(BYTES_IN_ADDRESS));
VM.enableGC();
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind, i, REF, ref));
break;
}
case WordTypeCode:
{
Word value = Magic.getWordAtOffset(stack, vOffset.minus(BYTES_IN_ADDRESS));
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind, i, WORD, value));
break;
}
default:
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
break;
}
// switch
}
// for loop
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class BaselineExecutionStateExtractor method getVariableValue.
/* go over local/stack array, and build VariableElement. */
private static void getVariableValue(byte[] stack, Offset offset, byte[] types, ArchBaselineCompiledMethod compiledMethod, boolean kind, ExecutionState state) {
int size = types.length;
Offset vOffset = offset;
for (int i = 0; i < size; i++) {
switch(types[i]) {
case VoidTypeCode:
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
break;
case BooleanTypeCode:
case ByteTypeCode:
case ShortTypeCode:
case CharTypeCode:
case IntTypeCode:
case FloatTypeCode:
{
int value = Magic.getIntAtOffset(stack, vOffset.minus(BYTES_IN_INT));
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
byte tcode = (types[i] == FloatTypeCode) ? FLOAT : INT;
state.add(new VariableElement(kind, i, tcode, value));
break;
}
case LongTypeCode:
case DoubleTypeCode:
{
// KV: this code would be nicer if VoidTypeCode would always follow a 64-bit value. Rigth now for LOCAL it follows, for STACK it proceeds
Offset memoff = (kind == LOCAL) ? vOffset.minus(BYTES_IN_DOUBLE) : VM.BuildFor64Addr ? vOffset : vOffset.minus(BYTES_IN_STACKSLOT);
long value = Magic.getLongAtOffset(stack, memoff);
byte tcode = (types[i] == LongTypeCode) ? LONG : DOUBLE;
state.add(new VariableElement(kind, i, tcode, value));
if (kind == LOCAL) {
// KV:VoidTypeCode is next
vOffset = vOffset.minus(2 * BYTES_IN_STACKSLOT);
// KV:skip VoidTypeCode
i++;
} else {
// KV:VoidTypeCode was already in front
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
}
break;
}
case ReturnAddressTypeCode:
{
VM.disableGC();
Address rowIP = Magic.objectAsAddress(stack).loadAddress(vOffset.minus(BYTES_IN_ADDRESS));
Offset ipOffset = compiledMethod.getInstructionOffset(rowIP);
VM.enableGC();
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
if (VM.TraceOnStackReplacement) {
Offset ipIndex = ipOffset.toWord().rsha(LG_INSTRUCTION_WIDTH).toOffset();
VM.sysWrite("baseline ret_addr ip ", ipIndex, " --> ");
}
int bcIndex = compiledMethod.findBytecodeIndexForInstruction(ipOffset.plus(INSTRUCTION_WIDTH));
if (VM.TraceOnStackReplacement) {
VM.sysWriteln(" bc " + bcIndex);
}
state.add(new VariableElement(kind, i, RET_ADDR, bcIndex));
break;
}
case ClassTypeCode:
case ArrayTypeCode:
{
VM.disableGC();
Object ref = Magic.getObjectAtOffset(stack, vOffset.minus(BYTES_IN_ADDRESS));
VM.enableGC();
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind, i, REF, ref));
break;
}
case WordTypeCode:
{
Word value = Magic.getWordAtOffset(stack, vOffset.minus(BYTES_IN_ADDRESS));
vOffset = vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind, i, WORD, value));
break;
}
default:
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
break;
}
// switch
}
// for loop
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class ThinLock method inlineLock.
@Inline
@NoNullCheck
@Unpreemptible
@Entrypoint
public static void inlineLock(Object o, Offset lockOffset) {
// FIXME: bad for PPC?
Word old = Magic.prepareWord(o, lockOffset);
Word id = old.and(TL_THREAD_ID_MASK.or(TL_STAT_MASK));
Word tid = Word.fromIntSignExtend(RVMThread.getCurrentThread().getLockingId());
if (id.EQ(tid)) {
Word changed = old.plus(TL_LOCK_COUNT_UNIT);
if (!changed.and(TL_LOCK_COUNT_MASK).isZero()) {
setDedicatedU16(o, lockOffset, changed);
Magic.combinedLoadBarrier();
return;
}
} else if (id.EQ(TL_STAT_THIN)) {
// lock is thin and not held by anyone
if (Magic.attemptWord(o, lockOffset, old, old.or(tid))) {
if (!VM.MagicAttemptImpliesStoreLoadBarrier)
Magic.fence();
return;
}
}
lock(o, lockOffset);
}
use of org.vmmagic.unboxed.Word in project JikesRVM by JikesRVM.
the class ThinLock method biasBitsToThinBits.
@Inline
@Uninterruptible
private static Word biasBitsToThinBits(Word bits) {
int lockOwner = getLockOwner(bits);
Word changed = bits.and(TL_UNLOCK_MASK).or(TL_STAT_THIN);
if (lockOwner != 0) {
int recCount = getRecCount(bits);
changed = changed.or(Word.fromIntZeroExtend(lockOwner)).or(Word.fromIntZeroExtend(recCount - 1).lsh(TL_LOCK_COUNT_SHIFT));
}
return changed;
}
Aggregations