Search in sources :

Example 16 with Word

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);
}
Also used : Word(org.vmmagic.unboxed.Word) Address(org.vmmagic.unboxed.Address) TestingTools.createNonMovableWordArray(org.jikesrvm.tests.util.TestingTools.createNonMovableWordArray) WordArray(org.vmmagic.unboxed.WordArray) TypeReference(org.jikesrvm.classloader.TypeReference) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 17 with Word

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
}
Also used : Word(org.vmmagic.unboxed.Word) Address(org.vmmagic.unboxed.Address) VariableElement(org.jikesrvm.osr.VariableElement) Offset(org.vmmagic.unboxed.Offset)

Example 18 with Word

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
}
Also used : Word(org.vmmagic.unboxed.Word) Address(org.vmmagic.unboxed.Address) VariableElement(org.jikesrvm.osr.VariableElement) Offset(org.vmmagic.unboxed.Offset)

Example 19 with Word

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);
}
Also used : Word(org.vmmagic.unboxed.Word) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) NoNullCheck(org.vmmagic.pragma.NoNullCheck) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 20 with Word

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;
}
Also used : Word(org.vmmagic.unboxed.Word) Entrypoint(org.vmmagic.pragma.Entrypoint) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

Word (org.vmmagic.unboxed.Word)62 Inline (org.vmmagic.pragma.Inline)15 Address (org.vmmagic.unboxed.Address)14 NoInline (org.vmmagic.pragma.NoInline)11 Offset (org.vmmagic.unboxed.Offset)10 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)8 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)8 CodeConstantOperand (org.jikesrvm.compilers.opt.ir.operand.CodeConstantOperand)8 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)8 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)8 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)8 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)8 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)8 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)8 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)8 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)8 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8