Search in sources :

Example 6 with Word

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

the class JavaHeader method testAvailableBit.

/**
 * @param o the object whose bit will be tested
 * @param idx the index in the bits
 * @return {@code true} if argument bit is 1, {@code false} if it is 0
 */
public static boolean testAvailableBit(Object o, int idx) {
    Word mask = Word.fromIntSignExtend(1 << idx);
    Word status = Magic.getWordAtOffset(o, STATUS_OFFSET);
    return mask.and(status).NE(Word.zero());
}
Also used : Word(org.vmmagic.unboxed.Word)

Example 7 with Word

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

the class JavaHeader method getReferenceWhenCopiedTo.

@Inline
protected static Object getReferenceWhenCopiedTo(Object obj, Address to) {
    if (ADDRESS_BASED_HASHING && !DYNAMIC_HASH_OFFSET) {
        // Read the hash state (used below)
        Word statusWord = Magic.getWordAtOffset(obj, STATUS_OFFSET);
        Word hashState = statusWord.and(HASH_STATE_MASK);
        if (hashState.NE(HASH_STATE_UNHASHED)) {
            to = to.plus(HASHCODE_BYTES);
        }
    }
    return Magic.addressAsObject(to.plus(OBJECT_REF_OFFSET));
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 8 with Word

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

the class MachineReflection method packageParameters.

/**
 * Collects parameters into arrays of registers/spills, as required to
 * call specified method.
 *
 * @param method method whose parameters are to be packaged
 * @param thisArg the receiver argument
 * @param otherArgs all other arguments (primitives are boxed)
 * @param GPRs space for GPRs (empty array if none needed)
 * @param FPRs space for FPRs (empty array if none needed)
 * @param FPRmeta meta-data for FPRs ({@code null} if no SSE2)
 * @param Parameters more space for parameters. Refer to the source code
 *  to get all the details.
 *
 * @see #countParameters(RVMMethod) more machine-specific details
 */
@UnpreemptibleNoWarn("GC is disabled as Objects are turned into Words." + "avoid preemption but still allow calls to preemptible unboxing routines")
public static void packageParameters(RVMMethod method, Object thisArg, Object[] otherArgs, WordArray GPRs, double[] FPRs, byte[] FPRmeta, WordArray Parameters) {
    int GPR = 0;
    int FPR = SSE2_FULL ? 0 : FPRs.length;
    int parameter = 0;
    // 0, 1, 2
    int gp = NUM_PARAMETER_GPRS;
    // 0-8
    int fp = NUM_PARAMETER_FPRS;
    if (!method.isStatic()) {
        Word val = Magic.objectAsAddress(thisArg).toWord();
        if (gp > 0) {
            gp--;
            GPRs.set(GPR++, val);
        }
        Parameters.set(parameter++, val);
    }
    TypeReference[] types = method.getParameterTypes();
    for (int i = 0; i < types.length; i++) {
        TypeReference t = types[i];
        if (!t.isPrimitiveType()) {
            Word val = Magic.objectAsAddress(otherArgs[i]).toWord();
            if (gp > 0) {
                gp--;
                GPRs.set(GPR++, val);
            }
            Parameters.set(parameter++, val);
        } else if (t.isLongType()) {
            long l = (Long) otherArgs[i];
            if (VM.BuildFor32Addr) {
                if (gp > 0) {
                    gp--;
                    GPRs.set(GPR++, Word.fromIntZeroExtend((int) (l >>> 32)));
                    if (gp > 0) {
                        gp--;
                        GPRs.set(GPR++, Word.fromIntZeroExtend((int) (l)));
                    }
                }
                Parameters.set(parameter++, Word.fromIntZeroExtend((int) (l >>> 32)));
                Parameters.set(parameter++, Word.fromIntZeroExtend((int) l));
            } else {
                Word val = Word.fromLong(l);
                if (gp > 0) {
                    gp--;
                    GPRs.set(GPR++, val);
                }
                Parameters.set(parameter++, val);
                Parameters.set(parameter++, val);
            }
        } else if (t.isFloatType()) {
            if (fp > 0) {
                fp--;
                if (SSE2_FULL) {
                    FPRs[FPR] = (Float) otherArgs[i];
                    FPRmeta[FPR] = 0x0;
                    FPR++;
                } else {
                    FPRs[--FPR] = (Float) otherArgs[i];
                }
            }
            float f = (Float) otherArgs[i];
            Parameters.set(parameter++, Word.fromIntZeroExtend(Float.floatToIntBits(f)));
        } else if (t.isDoubleType()) {
            if (VM.BuildFor32Addr) {
                if (fp > 0) {
                    fp--;
                    if (SSE2_FULL) {
                        FPRs[FPR] = (Double) otherArgs[i];
                        FPRmeta[FPR] = 0x1;
                        FPR++;
                    } else {
                        FPRs[--FPR] = (Double) otherArgs[i];
                    }
                }
                double d = (Double) otherArgs[i];
                long l = Double.doubleToLongBits(d);
                Parameters.set(parameter++, Word.fromIntZeroExtend((int) (l >>> 32)));
                Parameters.set(parameter++, Word.fromIntZeroExtend((int) l));
            } else {
                if (fp > 0) {
                    fp--;
                    if (SSE2_FULL) {
                        FPRs[FPR] = (Double) otherArgs[i];
                        FPRmeta[FPR] = 0x1;
                        FPR++;
                    } else {
                        FPRs[--FPR] = (Double) otherArgs[i];
                    }
                }
                double d = (Double) otherArgs[i];
                long l = Double.doubleToLongBits(d);
                Word val = Word.fromLong(l);
                Parameters.set(parameter++, val);
                Parameters.set(parameter++, val);
            }
        } else if (t.isBooleanType()) {
            boolean b = (Boolean) otherArgs[i];
            Word val = Word.fromIntZeroExtend(b ? 1 : 0);
            if (gp > 0) {
                gp--;
                GPRs.set(GPR++, val);
            }
            Parameters.set(parameter++, val);
        } else if (t.isCharType()) {
            char c = (Character) otherArgs[i];
            Word val = Word.fromIntZeroExtend(c);
            if (gp > 0) {
                gp--;
                GPRs.set(GPR++, val);
            }
            Parameters.set(parameter++, val);
        } else {
            if (VM.VerifyAssertions)
                VM._assert(t.isByteType() || t.isShortType() || t.isIntType());
            int x = ((Number) otherArgs[i]).intValue();
            Word val = Word.fromIntZeroExtend(x);
            if (gp > 0) {
                gp--;
                GPRs.set(GPR++, val);
            }
            Parameters.set(parameter++, val);
        }
    }
}
Also used : Word(org.vmmagic.unboxed.Word) TypeReference(org.jikesrvm.classloader.TypeReference) UnpreemptibleNoWarn(org.vmmagic.pragma.UnpreemptibleNoWarn)

Example 9 with Word

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

the class RCHeader method makeUnlogged.

/**
 * Change <code>object</code>'s state to <code>UNLOGGED</code>.
 *
 * @param object The object whose state is to be changed.
 */
@Inline
@Uninterruptible
public static void makeUnlogged(ObjectReference object) {
    Word oldValue, newValue;
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (VM.VERIFY_ASSERTIONS)
            VM.assertions._assert(oldValue.and(LOGGING_MASK).EQ(LOGGED));
        newValue = oldValue.or(UNLOGGED);
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
}
Also used : Word(org.vmmagic.unboxed.Word) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Inline(org.vmmagic.pragma.Inline)

Example 10 with Word

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

the class RCHeader method testAndMark.

/**
 * Attempts to atomically mark this object.
 *
 * @param object the object to mark
 * @return {@code true} if the mark was performed, {@code false}
 *  otherwise
 */
@Inline
public static boolean testAndMark(ObjectReference object) {
    Word oldValue, newValue;
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (isHeaderMarked(oldValue)) {
            return false;
        }
        newValue = oldValue.or(MARK_BIT_MASK);
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
    return true;
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

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