Search in sources :

Example 56 with RVMClass

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);
    }
}
Also used : CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) RVMClass(org.jikesrvm.classloader.RVMClass)

Example 57 with RVMClass

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);
}
Also used : Register(org.jikesrvm.compilers.opt.ir.Register) RVMClass(org.jikesrvm.classloader.RVMClass)

Example 58 with RVMClass

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;
}
Also used : RVMField(org.jikesrvm.classloader.RVMField) TypeReference(org.jikesrvm.classloader.TypeReference) Entrypoint(org.vmmagic.pragma.Entrypoint) RVMClass(org.jikesrvm.classloader.RVMClass) Offset(org.vmmagic.unboxed.Offset)

Example 59 with RVMClass

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);
}
Also used : RVMType(org.jikesrvm.classloader.RVMType) TypeReference(org.jikesrvm.classloader.TypeReference) Entrypoint(org.vmmagic.pragma.Entrypoint) RVMClass(org.jikesrvm.classloader.RVMClass) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 60 with RVMClass

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));
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) TypeReference(org.jikesrvm.classloader.TypeReference) Atom(org.jikesrvm.classloader.Atom) RVMClass(org.jikesrvm.classloader.RVMClass)

Aggregations

RVMClass (org.jikesrvm.classloader.RVMClass)69 RVMMethod (org.jikesrvm.classloader.RVMMethod)28 TypeReference (org.jikesrvm.classloader.TypeReference)22 RVMType (org.jikesrvm.classloader.RVMType)20 Atom (org.jikesrvm.classloader.Atom)14 RVMField (org.jikesrvm.classloader.RVMField)11 RVMArray (org.jikesrvm.classloader.RVMArray)8 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)8 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)8 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)8 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)7 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)7 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)7 Address (org.vmmagic.unboxed.Address)7 NormalMethod (org.jikesrvm.classloader.NormalMethod)6 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)6 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)6 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)5