Search in sources :

Example 61 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class VMCommonLibrarySupport method getFloat.

@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1 })
static float getFloat(Object object, RVMField field, Field jlrField, RVMClass accessingClass) throws IllegalAccessException, IllegalArgumentException {
    checkReadAccess(object, field, jlrField, accessingClass);
    TypeReference type = field.getType();
    if (type.isFloatType()) {
        return field.getFloatValueUnchecked(object);
    } else if (type.isLongType()) {
        return field.getLongValueUnchecked(object);
    } else if (type.isIntType()) {
        return field.getIntValueUnchecked(object);
    } else if (type.isShortType()) {
        return field.getShortValueUnchecked(object);
    } else if (type.isCharType()) {
        return field.getCharValueUnchecked(object);
    } else if (type.isByteType()) {
        return field.getByteValueUnchecked(object);
    } else {
        throwNewIllegalArgumentException("field type mismatch");
        return 0.0f;
    }
}
Also used : TypeReference(org.jikesrvm.classloader.TypeReference) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 62 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class VMCommonLibrarySupport method setIntInternal.

@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 2 })
private static void setIntInternal(Object object, int value, RVMField field) throws IllegalArgumentException {
    TypeReference type = field.getType();
    if (type.isIntType())
        field.setIntValueUnchecked(object, value);
    else if (type.isLongType())
        field.setLongValueUnchecked(object, value);
    else if (type.isDoubleType())
        field.setDoubleValueUnchecked(object, value);
    else if (type.isFloatType())
        field.setFloatValueUnchecked(object, value);
    else
        throwNewIllegalArgumentException("field type mismatch");
}
Also used : TypeReference(org.jikesrvm.classloader.TypeReference) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 63 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class VMCommonLibrarySupport method construct.

/* ---- Constructor Support ---- */
/**
 * Construct an object from the given constructor args, called from the accessing class
 */
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 0 })
static Object construct(RVMMethod constructor, Constructor<?> cons, Object[] args, RVMClass accessingClass, ReflectionBase invoker) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    // Check accessibility
    if (!constructor.isPublic() && !cons.isAccessible()) {
        checkAccess(constructor, accessingClass);
    }
    // validate number and types of arguments to constructor
    if (Reflection.needsCheckArgs(invoker) && !checkArguments(args, constructor)) {
        args = makeArgumentsCompatible(args, constructor);
    }
    RVMClass cls = constructor.getDeclaringClass();
    if (cls.isAbstract()) {
        throwNewInstantiationException("Abstract class");
    }
    // Ensure that the class is initialized
    if (!cls.isInitialized()) {
        runClassInitializer(cls);
    }
    // Allocate an uninitialized instance;
    Object obj = RuntimeEntrypoints.resolvedNewScalar(cls);
    // Run the constructor on the instance.
    try {
        Reflection.invoke(constructor, invoker, obj, args, true);
    } catch (Throwable e) {
        throw new InvocationTargetException(e);
    }
    return obj;
}
Also used : RVMClass(org.jikesrvm.classloader.RVMClass) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 64 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class VMCommonLibrarySupport method get.

/**
 * Read a field from an object
 * @param object to read from
 * @param field to be read
 * @param jlrField API version of field
 * @param accessingClass class performing access
 * @return the field's value
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1 })
static Object get(Object object, RVMField field, Field jlrField, RVMClass accessingClass) throws IllegalAccessException, IllegalArgumentException {
    checkReadAccess(object, field, jlrField, accessingClass);
    if (field.isReferenceType()) {
        return field.getObjectValueUnchecked(object);
    }
    TypeReference type = field.getType();
    if (type.isIntType()) {
        return field.getIntValueUnchecked(object);
    } else if (type.isCharType()) {
        return field.getCharValueUnchecked(object);
    } else if (type.isShortType()) {
        return field.getShortValueUnchecked(object);
    } else if (type.isLongType()) {
        return field.getLongValueUnchecked(object);
    } else if (type.isByteType()) {
        return field.getByteValueUnchecked(object);
    } else if (type.isBooleanType()) {
        return field.getBooleanValueUnchecked(object);
    } else if (type.isDoubleType()) {
        return field.getDoubleValueUnchecked(object);
    } else {
        if (VM.VerifyAssertions)
            VM._assert(type.isFloatType());
        return field.getFloatValueUnchecked(object);
    }
}
Also used : TypeReference(org.jikesrvm.classloader.TypeReference) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 65 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class VMCommonLibrarySupport method getByte.

@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1 })
static byte getByte(Object object, RVMField field, Field jlrField, RVMClass accessingClass) throws IllegalAccessException, IllegalArgumentException {
    checkReadAccess(object, field, jlrField, accessingClass);
    TypeReference type = field.getType();
    if (!type.isByteType())
        throwNewIllegalArgumentException("field type mismatch");
    return field.getByteValueUnchecked(object);
}
Also used : TypeReference(org.jikesrvm.classloader.TypeReference) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

Inline (org.vmmagic.pragma.Inline)110 NoInline (org.vmmagic.pragma.NoInline)42 Entrypoint (org.vmmagic.pragma.Entrypoint)40 Offset (org.vmmagic.unboxed.Offset)38 ObjectReference (org.vmmagic.unboxed.ObjectReference)35 Address (org.vmmagic.unboxed.Address)15 Word (org.vmmagic.unboxed.Word)15 TypeReference (org.jikesrvm.classloader.TypeReference)12 Uninterruptible (org.vmmagic.pragma.Uninterruptible)6 RVMType (org.jikesrvm.classloader.RVMType)5 RVMClass (org.jikesrvm.classloader.RVMClass)4 Unpreemptible (org.vmmagic.pragma.Unpreemptible)4 RVMClassLoader (org.jikesrvm.classloader.RVMClassLoader)3 TIB (org.jikesrvm.objectmodel.TIB)3 Extent (org.vmmagic.unboxed.Extent)3 MethodReference (org.jikesrvm.classloader.MethodReference)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2 CollectorContext (org.mmtk.plan.CollectorContext)2 NoNullCheck (org.vmmagic.pragma.NoNullCheck)2