Search in sources :

Example 21 with Atom

use of org.jikesrvm.classloader.Atom in project JikesRVM by JikesRVM.

the class ObjectConstantOperand method getType.

@Override
public TypeReference getType() {
    if (VM.runningVM) {
        return java.lang.JikesRVMSupport.getTypeForClass(value.getClass()).getTypeRef();
    } else {
        Class<?> rc = value.getClass();
        String className = rc.getName();
        Atom classAtom = Atom.findOrCreateAsciiAtom(className.replace('.', '/'));
        if (className.startsWith("[")) {
            // an array
            return TypeReference.findOrCreate(BootstrapClassLoader.getBootstrapClassLoader(), classAtom);
        } else {
            // a class
            Atom classDescriptor = classAtom.descriptorFromClassName();
            return TypeReference.findOrCreate(BootstrapClassLoader.getBootstrapClassLoader(), classDescriptor);
        }
    }
}
Also used : Atom(org.jikesrvm.classloader.Atom)

Example 22 with Atom

use of org.jikesrvm.classloader.Atom in project JikesRVM by JikesRVM.

the class PrintLN method print.

/* Code related to Atom.classNameFromDescriptor() */
public void print(RVMClass class_) {
    // getDescriptor() does no allocation.
    Atom descriptor = class_.getDescriptor();
    printClassName(descriptor);
}
Also used : Atom(org.jikesrvm.classloader.Atom)

Example 23 with Atom

use of org.jikesrvm.classloader.Atom in project JikesRVM by JikesRVM.

the class GenerateMachineSpecificMagic method generateMagic.

/**
 * "Semantic inlining" of methods of the Magic class
 * Based on the methodName, generate a sequence of opt instructions
 * that implement the magic, updating the stack as necessary
 *
 * @param bc2ir the bc2ir object that is generating the
 *              ir containing this magic
 * @param gc == bc2ir.gc
 * @param meth the RVMMethod that is the magic method
 * @return {@code true} if and only if magic was generated
 */
public static boolean generateMagic(BC2IR bc2ir, GenerationContext gc, MethodReference meth) throws MagicNotImplementedException {
    Atom methodName = meth.getName();
    if (methodName == MagicNames.getFramePointer) {
        bc2ir.push(gc.getTemps().makeFPOp());
        gc.forceFrameAllocation();
    } else if (methodName == MagicNames.getTocPointer) {
        bc2ir.push(gc.getTemps().makeJTOCOp());
    } else if (methodName == MagicNames.getJTOC) {
        bc2ir.push(gc.getTemps().makeTocOp());
    } else if (methodName == MagicNames.getCallerFramePointer) {
        Operand fp = bc2ir.popAddress();
        RegisterOperand val = gc.getTemps().makeTemp(TypeReference.Address);
        bc2ir.appendInstruction(Load.create(REF_LOAD, val, fp, AC(STACKFRAME_FRAME_POINTER_OFFSET), null));
        bc2ir.push(val.copyD2U());
    } else if (methodName == MagicNames.setCallerFramePointer) {
        Operand val = bc2ir.popAddress();
        Operand fp = bc2ir.popAddress();
        bc2ir.appendInstruction(Store.create(REF_STORE, val, fp, AC(STACKFRAME_FRAME_POINTER_OFFSET), null));
    } else if (methodName == MagicNames.getCompiledMethodID) {
        Operand fp = bc2ir.popAddress();
        RegisterOperand val = gc.getTemps().makeTempInt();
        bc2ir.appendInstruction(Load.create(INT_LOAD, val, fp, AC(STACKFRAME_METHOD_ID_OFFSET), null));
        bc2ir.push(val.copyD2U());
    } else if (methodName == MagicNames.setCompiledMethodID) {
        Operand val = bc2ir.popInt();
        Operand fp = bc2ir.popAddress();
        bc2ir.appendInstruction(Store.create(INT_STORE, val, fp, AC(STACKFRAME_METHOD_ID_OFFSET), null));
    } else if (methodName == MagicNames.getNextInstructionAddress) {
        Operand fp = bc2ir.popAddress();
        RegisterOperand val = gc.getTemps().makeTemp(TypeReference.Address);
        bc2ir.appendInstruction(Load.create(REF_LOAD, val, fp, AC(STACKFRAME_RETURN_ADDRESS_OFFSET), null));
        bc2ir.push(val.copyD2U());
    } else if (methodName == MagicNames.getReturnAddressLocation) {
        Operand fp = bc2ir.popAddress();
        RegisterOperand callerFP = gc.getTemps().makeTemp(TypeReference.Address);
        bc2ir.appendInstruction(Load.create(REF_LOAD, callerFP, fp, AC(STACKFRAME_FRAME_POINTER_OFFSET), null));
        Instruction s = bc2ir._binaryHelper(REF_ADD, callerFP.copyRO(), offsetOperand(STACKFRAME_RETURN_ADDRESS_OFFSET), TypeReference.Address);
        bc2ir.appendInstruction(s);
    } else if (methodName == MagicNames.synchronizeInstructionCache) {
        bc2ir.appendInstruction(Empty.create(READ_CEILING));
    } else if (methodName == MagicNames.pause) {
    // IA-specific
    } else if (methodName == MagicNames.illegalInstruction) {
        bc2ir.appendInstruction(Empty.create(ILLEGAL_INSTRUCTION));
    } else if (methodName == MagicNames.dcbst) {
        bc2ir.appendInstruction(CacheOp.create(DCBST, bc2ir.popAddress()));
    } else if (methodName == MagicNames.dcbt || methodName == MagicNames.prefetch) {
        bc2ir.appendInstruction(CacheOp.create(DCBT, bc2ir.popAddress()));
    } else if (methodName == MagicNames.dcbtst) {
        bc2ir.appendInstruction(CacheOp.create(DCBTST, bc2ir.popAddress()));
    } else if (methodName == MagicNames.dcbz) {
        bc2ir.appendInstruction(CacheOp.create(DCBZ, bc2ir.popAddress()));
    } else if (methodName == MagicNames.dcbzl) {
        bc2ir.appendInstruction(CacheOp.create(DCBZL, bc2ir.popAddress()));
    } else if (methodName == MagicNames.icbi) {
        bc2ir.appendInstruction(CacheOp.create(ICBI, bc2ir.popAddress()));
    } else {
        // Distinguish between magics that we know we don't implement
        // (and never plan to implement) and those (usually new ones)
        // that we want to be warned that we don't implement.
        String msg = "Magic method not implemented: " + meth;
        if (methodName == MagicNames.returnToNewStack) {
            throw MagicNotImplementedException.EXPECTED(msg);
        } else {
            return false;
        // throw MagicNotImplementedException.UNEXPECTED(msg);
        }
    }
    return true;
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IRTools.offsetOperand(org.jikesrvm.compilers.opt.ir.IRTools.offsetOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) Atom(org.jikesrvm.classloader.Atom)

Example 24 with Atom

use of org.jikesrvm.classloader.Atom 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)

Example 25 with Atom

use of org.jikesrvm.classloader.Atom in project JikesRVM by JikesRVM.

the class EntrypointHelper method getMember.

/**
 * Get description of virtual machine component (field or method).
 * <p>
 * Note: This is method is intended for use only by VM classes that need
 * to address their own fields and methods in the runtime virtual machine
 * image.  It should not be used for general purpose class loading.
 * @param classDescriptor  class  descriptor - something like "Lorg/jikesrvm/RuntimeEntrypoints;"
 * @param memberName       member name       - something like "invokestatic"
 * @param memberDescriptor member descriptor - something like "()V"
 * @return corresponding RVMMember object
 */
private static RVMMember getMember(String classDescriptor, String memberName, String memberDescriptor) {
    Atom clsDescriptor = Atom.findOrCreateAsciiAtom(classDescriptor);
    Atom memName = Atom.findOrCreateAsciiAtom(memberName);
    Atom memDescriptor = Atom.findOrCreateAsciiAtom(memberDescriptor);
    try {
        TypeReference tRef = TypeReference.findOrCreate(BootstrapClassLoader.getBootstrapClassLoader(), clsDescriptor);
        RVMClass cls = (RVMClass) tRef.resolve();
        cls.resolve();
        RVMMember member;
        if ((member = cls.findDeclaredField(memName, memDescriptor)) != null) {
            verifyThatFieldIsNotFinal((RVMField) member);
            verifyPresenceOfEntrypointAnnotation(member);
            return member;
        }
        if ((member = cls.findDeclaredMethod(memName, memDescriptor)) != null) {
            verifyPresenceOfEntrypointAnnotation(member);
            return member;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    // The usual causes for getMember() to fail are:
    // 1. you mispelled the class name, member name, or member signature
    // 2. the class containing the specified member didn't get compiled
    // 
    VM.sysWriteln("Entrypoints.getMember: can't resolve class=" + classDescriptor + " member=" + memberName + " desc=" + memberDescriptor);
    if (VM.VerifyAssertions)
        VM._assert(VM.NOT_REACHED);
    return null;
}
Also used : RVMMember(org.jikesrvm.classloader.RVMMember) TypeReference(org.jikesrvm.classloader.TypeReference) Atom(org.jikesrvm.classloader.Atom) RVMClass(org.jikesrvm.classloader.RVMClass)

Aggregations

Atom (org.jikesrvm.classloader.Atom)29 RVMClass (org.jikesrvm.classloader.RVMClass)14 RVMMethod (org.jikesrvm.classloader.RVMMethod)11 TypeReference (org.jikesrvm.classloader.TypeReference)10 RVMField (org.jikesrvm.classloader.RVMField)7 RVMType (org.jikesrvm.classloader.RVMType)5 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)3 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)3 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)3 IRTools.offsetOperand (org.jikesrvm.compilers.opt.ir.IRTools.offsetOperand)2 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)2 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)2 Method (java.lang.reflect.Method)1 TypeVariable (java.lang.reflect.TypeVariable)1 HashSet (java.util.HashSet)1 NoSuchElementException (java.util.NoSuchElementException)1 ApplicationClassLoader (org.jikesrvm.classloader.ApplicationClassLoader)1 NativeMethod (org.jikesrvm.classloader.NativeMethod)1 NormalMethod (org.jikesrvm.classloader.NormalMethod)1 RVMArray (org.jikesrvm.classloader.RVMArray)1