use of org.jikesrvm.classloader.RVMClass in project JikesRVM by JikesRVM.
the class ClassLoadingDependencyManager method handleSubclassing.
private void handleSubclassing(RVMClass c) {
// nothing to do
if (c.isJavaLangObjectType() || c.isInterface())
return;
RVMClass sc = c.getSuperClass();
Iterator<Integer> invalidatedMethods = db.invalidatedBySubclass(sc);
if (invalidatedMethods != null) {
while (invalidatedMethods.hasNext()) {
int cmid = invalidatedMethods.next();
CompiledMethod im = CompiledMethods.getCompiledMethod(cmid);
if (im != null) {
// im == null implies that the code has been GCed already
invalidate(im);
}
}
db.removeNoSubclassDependency(sc);
}
}
use of org.jikesrvm.classloader.RVMClass in project JikesRVM by JikesRVM.
the class ObjectReplacer method getReplacer.
/**
* Return an object representing this transformation for a given
* allocation site
*
* @param inst the allocation site
* @param ir the governing IR
* @return the object, or null if illegal
*/
public static ObjectReplacer getReplacer(Instruction inst, IR ir) {
Register r = New.getResult(inst).getRegister();
RVMClass klass = New.getType(inst).getVMType().asClass();
// TODO :handle these cases
if (klass.hasFinalizer() || containsUnsupportedUse(ir, r, klass, null)) {
return null;
}
return new ObjectReplacer(r, klass, ir);
}
use of org.jikesrvm.classloader.RVMClass 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.RVMClass in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method unresolvedNewScalar.
// ---------------------------------------------------------------//
// Object Allocation. //
// ---------------------------------------------------------------//
/**
* Allocate something like "new Foo()".
* @param id id of type reference of class to create
* @param site the site id of the calling allocation site
* @return object with header installed and all fields set to zero/null
* (ready for initializer to be run on it)
* See also: bytecode 0xbb ("new")
*/
@Entrypoint
static Object unresolvedNewScalar(int id, int site) throws NoClassDefFoundError, OutOfMemoryError {
TypeReference tRef = TypeReference.getTypeRef(id);
RVMType t = tRef.peekType();
if (t == null) {
t = tRef.resolve();
}
RVMClass cls = t.asClass();
if (!cls.isInitialized()) {
initializeClassForDynamicLink(cls);
}
int allocator = MemoryManager.pickAllocator(cls);
int align = ObjectModel.getAlignment(cls);
int offset = ObjectModel.getOffsetForAlignment(cls, false);
return resolvedNewScalar(cls.getInstanceSize(), cls.getTypeInformationBlock(), cls.hasFinalizer(), allocator, align, offset, site);
}
use of org.jikesrvm.classloader.RVMClass in project JikesRVM by JikesRVM.
the class EntrypointHelper method getMethod.
public static RVMMethod getMethod(Class<?> klass, Atom member, Class<?>... argTypes) {
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 descriptor = Atom.findOrCreateAsciiAtom(makeDescriptor(argTypes));
RVMMethod method = cls.findDeclaredMethod(member, descriptor);
if (method != null) {
verifyPresenceOfEntrypointAnnotation(method);
return method;
}
} catch (Throwable t) {
throw new Error("Entrypoints.getMethod: can't resolve class=" + klass + " member=" + member + " desc=" + makeDescriptor(argTypes), t);
}
}
throw new Error("Entrypoints.getMethod: can't resolve class=" + klass + " member=" + member + " desc=" + makeDescriptor(argTypes));
}
Aggregations