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