use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class LoadElimination method appendMove.
/**
* Append a move instruction after a store instruction that caches
* value in register r.
*
* @param r move target
* @param src move source
* @param store the instruction after which the move will be inserted
*/
static void appendMove(Register r, Operand src, Instruction store) {
TypeReference type = src.getType();
RegisterOperand rop = new RegisterOperand(r, type);
store.insertAfter(Move.create(IRTools.getMoveOp(type), rop, src.copy()));
}
use of org.jikesrvm.classloader.TypeReference 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);
}
}
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class MultianewarrayHelper method newArrayArray.
/**
* Allocate something like {@code new Foo[cnt0][cnt1]...[cntN-1]},
* or {@code new int[cnt0][cnt1]...[cntN-1]}.
* @param methodId method id of caller
* @param numDimensions number of array dimensions
* @param typeId type id of type reference for array
* @param argOffset position of word *above* `cnt0' argument within
* caller's frame This is used to access the number of elements to
* be allocated for each dimension.
*
* See also: bytecode 0xc5 ("multianewarray") in BaselineCompilerImpl
*
* @return newly allocated multidimensional array
*/
@Entrypoint
static Object newArrayArray(int methodId, int numDimensions, int typeId, int argOffset) throws NoClassDefFoundError, NegativeArraySizeException, OutOfMemoryError {
if (numDimensions == 2) {
int dim0, dim1;
// fetch number of elements to be allocated for each array dimension
VM.disableGC();
Address argp = Magic.getFramePointer().plus(argOffset);
argp = argp.minus(BYTES_IN_WORD);
dim0 = argp.loadInt();
argp = argp.minus(BYTES_IN_WORD);
dim1 = argp.loadInt();
VM.enableGC();
// validate arguments
if ((dim0 < 0) || (dim1 < 0))
throw new NegativeArraySizeException();
// create array
TypeReference tRef = TypeReference.getTypeRef(typeId);
RVMArray array = tRef.resolve().asArray();
return RuntimeEntrypoints.buildTwoDimensionalArray(methodId, dim0, dim1, array);
} else {
// fetch number of elements to be allocated for each array dimension
int[] numElements = new int[numDimensions];
VM.disableGC();
Address argp = Magic.getFramePointer().plus(argOffset);
for (int i = 0; i < numDimensions; ++i) {
argp = argp.minus(BYTES_IN_WORD);
numElements[i] = argp.loadInt();
}
VM.enableGC();
// validate arguments
for (int elements : numElements) {
if (elements < 0)
throw new NegativeArraySizeException();
}
// create array
TypeReference tRef = TypeReference.getTypeRef(typeId);
RVMArray array = tRef.resolve().asArray();
return RuntimeEntrypoints.buildMultiDimensionalArray(methodId, numElements, array);
}
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class VMCommonLibrarySupport method getInt.
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1 })
static int getInt(Object object, RVMField field, Field jlrField, RVMClass accessingClass) throws IllegalAccessException, IllegalArgumentException {
checkReadAccess(object, field, jlrField, accessingClass);
TypeReference type = field.getType();
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;
}
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class VMCommonLibrarySupport method getDouble.
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1 })
static double getDouble(Object object, RVMField field, Field jlrField, RVMClass accessingClass) throws IllegalAccessException, IllegalArgumentException {
checkReadAccess(object, field, jlrField, accessingClass);
TypeReference type = field.getType();
if (type.isDoubleType()) {
return field.getDoubleValueUnchecked(object);
} else 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.0d;
}
}
Aggregations