use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class ConvertToLowLevelIR method expandSysCallTarget.
/**
* Expand symbolic SysCall target into a chain of loads from the bootrecord to
* the desired target address.
*
* @param s the call instruction
* @param ir the governing IR
*/
public static void expandSysCallTarget(Instruction s, IR ir) {
MethodOperand sysM = Call.getMethod(s);
if (sysM.getMemberRef().isFieldReference()) {
RegisterOperand t1 = getStatic(s, ir, Entrypoints.the_boot_recordField);
RVMField target = sysM.getMemberRef().asFieldReference().resolve();
Operand ip = getField(s, ir, t1, target);
Call.setAddress(s, ip);
}
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method cloneClass2.
/**
* Clone an object implementing a class - the actual clone
*
* @param obj the object to clone
* @param type the type information for the class
* @return the cloned object
*/
private static Object cloneClass2(Object obj, RVMType type) throws OutOfMemoryError {
RVMClass cls = type.asClass();
Object newObj = resolvedNewScalar(cls);
for (RVMField f : cls.getInstanceFields()) {
if (f.isReferenceType()) {
// Writing a reference
// Do via slower "VM-internal reflection" to enable
// collectors to do the right thing wrt reference counting
// and write barriers.
f.setObjectValueUnchecked(newObj, f.getObjectValueUnchecked(obj));
} else {
// Primitive type
// Check if we need to go via the slower barried path
TypeReference fieldType = f.getType();
if (Barriers.NEEDS_BOOLEAN_PUTFIELD_BARRIER && fieldType.isBooleanType()) {
f.setBooleanValueUnchecked(newObj, f.getBooleanValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_BYTE_PUTFIELD_BARRIER && fieldType.isByteType()) {
f.setByteValueUnchecked(newObj, f.getByteValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_CHAR_PUTFIELD_BARRIER && fieldType.isCharType()) {
f.setCharValueUnchecked(newObj, f.getCharValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_DOUBLE_PUTFIELD_BARRIER && fieldType.isDoubleType()) {
f.setDoubleValueUnchecked(newObj, f.getDoubleValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_FLOAT_PUTFIELD_BARRIER && fieldType.isFloatType()) {
f.setFloatValueUnchecked(newObj, f.getFloatValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_INT_PUTFIELD_BARRIER && fieldType.isIntType()) {
f.setIntValueUnchecked(newObj, f.getIntValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_LONG_PUTFIELD_BARRIER && fieldType.isLongType()) {
f.setLongValueUnchecked(newObj, f.getLongValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_SHORT_PUTFIELD_BARRIER && fieldType.isShortType()) {
f.setShortValueUnchecked(newObj, f.getShortValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_WORD_PUTFIELD_BARRIER && fieldType.isWordType()) {
f.setWordValueUnchecked(newObj, f.getWordValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_ADDRESS_PUTFIELD_BARRIER && fieldType.isAddressType()) {
f.setAddressValueUnchecked(newObj, f.getAddressValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_EXTENT_PUTFIELD_BARRIER && fieldType.isExtentType()) {
f.setExtentValueUnchecked(newObj, f.getExtentValueUnchecked(obj));
continue;
} else if (Barriers.NEEDS_OFFSET_PUTFIELD_BARRIER && fieldType.isOffsetType()) {
f.setOffsetValueUnchecked(newObj, f.getOffsetValueUnchecked(obj));
continue;
} else {
// Can perform raw copy of field
int size = f.getSize();
Offset offset = f.getOffset();
if (VM.BuildFor32Addr) {
// case first
if (size == BYTES_IN_INT) {
int bits = Magic.getIntAtOffset(obj, offset);
Magic.setIntAtOffset(newObj, offset, bits);
continue;
} else if (size == BYTES_IN_LONG) {
long bits = Magic.getLongAtOffset(obj, offset);
Magic.setLongAtOffset(newObj, offset, bits);
continue;
}
} else {
// case first
if (size == BYTES_IN_LONG) {
long bits = Magic.getLongAtOffset(obj, offset);
Magic.setLongAtOffset(newObj, offset, bits);
continue;
} else if (size == BYTES_IN_INT) {
int bits = Magic.getIntAtOffset(obj, offset);
Magic.setIntAtOffset(newObj, offset, bits);
continue;
}
}
if (size == BYTES_IN_CHAR) {
char bits = Magic.getCharAtOffset(obj, offset);
Magic.setCharAtOffset(newObj, offset, bits);
} else {
if (VM.VerifyAssertions)
VM._assert(size == BYTES_IN_BYTE);
byte bits = Magic.getByteAtOffset(obj, offset);
Magic.setByteAtOffset(newObj, offset, bits);
}
}
}
}
return newObj;
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class EntrypointHelper method getField.
/**
* Get description of virtual machine field.
* @param klass class containing field
* @param member member name - something like "invokestatic"
* @param type of field
* @return corresponding RVMField
*/
static RVMField getField(String klass, String member, Class<?> type) {
if (!VM.runningVM) {
// avoid compiling this code into the boot image
try {
TypeReference tRef = TypeReference.findOrCreate(klass);
RVMClass cls = tRef.resolve().asClass();
cls.resolve();
Atom memName = Atom.findOrCreateAsciiAtom(member);
Atom typeName = TypeReference.findOrCreate(type).getName();
RVMField field = cls.findDeclaredField(memName, typeName);
if (field != null) {
verifyPresenceOfEntrypointAnnotation(field);
verifyThatFieldIsNotFinal(field);
return field;
}
} catch (Throwable t) {
throw new Error("Entrypoints.getField: can't resolve class=" + klass + " member=" + member + " desc=" + type, t);
}
}
throw new Error("Entrypoints.getField: can't resolve class=" + klass + " member=" + member + " desc=" + type);
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class JNIFunctions method GetShortField.
/**
* GetShortField: read an instance field of type short
* @param env A JREF index for the JNI environment object
* @param objJREF a JREF index for the target object
* @param fieldID the id for the RVMField that describes this field
* @return the value of the short field, or 0 if the fieldID is incorrect
*/
private static int GetShortField(JNIEnvironment env, int objJREF, int fieldID) {
if (traceJNI)
VM.sysWriteln("JNI called: GetShortField");
RuntimeEntrypoints.checkJNICountDownToGC();
try {
Object obj = env.getJNIRef(objJREF);
RVMField field = MemberReference.getFieldRef(fieldID).resolve();
return field.getShortValueUnchecked(obj);
} catch (Throwable unexpected) {
if (traceJNI)
unexpected.printStackTrace(System.err);
env.recordException(unexpected);
return 0;
}
}
use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.
the class JNIFunctions method GetDoubleField.
/**
* GetDoubleField: read an instance field of type double
* @param env A JREF index for the JNI environment object
* @param objJREF a JREF index for the target object
* @param fieldID the id for the RVMField that describes this field
* @return the value of the double field or 0 if the fieldID is incorrect
*/
private static double GetDoubleField(JNIEnvironment env, int objJREF, int fieldID) {
if (traceJNI)
VM.sysWriteln("JNI called: GetDoubleField");
RuntimeEntrypoints.checkJNICountDownToGC();
try {
Object obj = env.getJNIRef(objJREF);
RVMField field = MemberReference.getFieldRef(fieldID).resolve();
return field.getDoubleValueUnchecked(obj);
} catch (Throwable unexpected) {
if (traceJNI)
unexpected.printStackTrace(System.err);
env.recordException(unexpected);
return 0.0;
}
}
Aggregations