Search in sources :

Example 36 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class EntrypointHelper method verifyPresenceOfEntrypointAnnotation.

private static void verifyPresenceOfEntrypointAnnotation(RVMMember member) {
    if (VM.VerifyAssertions && !(member.isAnnotationPresent(Entrypoint.class))) {
        // For certain methods, it's clear that they're accessed by the
        // compiler, so an annotation is not required:
        boolean annotationRequired = true;
        if (member instanceof RVMMethod) {
            RVMMethod m = (RVMMethod) member;
            RVMClass declClass = m.getDeclaringClass();
            if (declClass.getTypeRef().isMagicType() || declClass.getTypeRef().isUnboxedType() || // it's the VM's job to handle those correctly
            declClass.getPackageName().startsWith("java.lang")) {
                annotationRequired = false;
            }
        }
        // Don't require annotations on fields for the class library.
        if (member instanceof RVMField) {
            RVMField field = (RVMField) member;
            RVMClass declClass = field.getDeclaringClass();
            if (declClass.getPackageName().startsWith("java.lang")) {
                annotationRequired = false;
            }
        }
        if (annotationRequired) {
            String msg = "WARNING: MISSING @Entrypoint ANNOTATION: " + member + " is missing an @Entrypoint annotation!";
            throw new Error(msg);
        }
    }
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) Entrypoint(org.vmmagic.pragma.Entrypoint) RVMField(org.jikesrvm.classloader.RVMField) RVMClass(org.jikesrvm.classloader.RVMClass)

Example 37 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class RVMThread method yieldpointFromEpilogue.

/**
 * Yieldpoint taken in epilogue.
 */
@BaselineSaveLSRegisters
// Save all non-volatile registers in prologue
@NoOptCompile
@NoInline
// TODO fix this -- related to SaveVolatile
@Entrypoint
@Unpreemptible("Becoming another thread interrupts the current thread, avoid preemption in the process")
public static void yieldpointFromEpilogue() {
    Address fp = Magic.getFramePointer();
    yieldpoint(EPILOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) BaselineSaveLSRegisters(org.vmmagic.pragma.BaselineSaveLSRegisters) NoInline(org.vmmagic.pragma.NoInline) NoOptCompile(org.vmmagic.pragma.NoOptCompile)

Example 38 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class MainThread method run.

/**
 * Run "main" thread.
 * <p>
 * This code could be made a little shorter by relying on Reflection
 * to do the classloading and compilation.  We intentionally do it here
 * to give us a chance to provide error messages that are specific to
 * not being able to find the main class the user wants to run.
 * This may be a little silly, since it results in code duplication
 * just to provide debug messages in a place where very little is actually
 * likely to go wrong, but there you have it....
 */
@Override
@Entrypoint
public void run() {
    launched = true;
    if (dbg)
        VM.sysWriteln("MainThread.run() starting ");
    // Set up application class loader
    ClassLoader cl = RVMClassLoader.getApplicationClassLoader();
    setContextClassLoader(cl);
    runAgents(cl);
    if (dbg)
        VM.sysWrite("[MainThread.run() loading class to run... ");
    // find method to run
    // load class specified by args[0]
    RVMClass cls = null;
    try {
        Atom mainAtom = Atom.findOrCreateUnicodeAtom(args[0]);
        TypeReference mainClass = TypeReference.findOrCreate(cl, mainAtom.descriptorFromClassName());
        cls = mainClass.resolve().asClass();
        cls.prepareForFirstUse();
    } catch (NoClassDefFoundError e) {
        if (dbg)
            VM.sysWrite("failed.]");
        // no such class
        VM.sysWriteln(e.toString());
        return;
    }
    if (dbg)
        VM.sysWriteln("loaded.]");
    // find "main" method
    // 
    mainMethod = cls.findMainMethod();
    if (mainMethod == null) {
        // no such method
        VM.sysWriteln(cls + " doesn't have a \"public static void main(String[])\" method to execute");
        return;
    }
    if (dbg)
        VM.sysWrite("[MainThread.run() making arg list... ");
    // create "main" argument list
    // 
    String[] mainArgs = new String[args.length - 1];
    for (int i = 0, n = mainArgs.length; i < n; ++i) {
        mainArgs[i] = args[i + 1];
    }
    if (dbg)
        VM.sysWriteln("made.]");
    if (dbg)
        VM.sysWrite("[MainThread.run() compiling main(String[])... ");
    mainMethod.compile();
    if (dbg)
        VM.sysWriteln("compiled.]");
    // Notify other clients that the startup is complete.
    // 
    Callbacks.notifyStartup();
    if (dbg)
        VM.sysWriteln("[MainThread.run() invoking \"main\" method... ");
    // invoke "main" method with argument list
    Reflection.invoke(mainMethod, null, null, new Object[] { mainArgs }, true);
    if (dbg)
        VM.sysWriteln("  MainThread.run(): \"main\" method completed.]");
}
Also used : RVMClassLoader(org.jikesrvm.classloader.RVMClassLoader) TypeReference(org.jikesrvm.classloader.TypeReference) Atom(org.jikesrvm.classloader.Atom) Entrypoint(org.vmmagic.pragma.Entrypoint) RVMClass(org.jikesrvm.classloader.RVMClass) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 39 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class RVMClass method getClassFromStackFrame.

/**
 * Used for accessibility checks in reflection code.
 * Find the class of the method that corresponds to the requested frame.
 *
 * @param skip   Specifies the number of frames back from the
 *               caller to the method whose class is required
 *
 * @return the class that declares the method at the desired frame
 */
@Entrypoint
public static RVMClass getClassFromStackFrame(int skip) {
    // account for stack frame of this function
    skip++;
    StackBrowser browser = new StackBrowser();
    VM.disableGC();
    browser.init();
    while (skip-- > 0) browser.up();
    VM.enableGC();
    return browser.getCurrentClass();
}
Also used : StackBrowser(org.jikesrvm.runtime.StackBrowser) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 40 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class InvocationCounts method counterTripped.

/**
 * Called from baseline compiled code when a method's invocation counter
 * becomes negative and thus must be handled
 *
 * @param id the compiled method id
 */
@Entrypoint
static synchronized void counterTripped(int id) {
    // set counter to max int to avoid lots of redundant calls.
    counts[id] = 0x7fffffff;
    if (processed[id])
        return;
    processed[id] = true;
    CompiledMethod cm = CompiledMethods.getCompiledMethod(id);
    if (cm == null)
        return;
    if (VM.VerifyAssertions)
        VM._assert(cm.getCompilerType() == CompiledMethod.BASELINE);
    NormalMethod m = (NormalMethod) cm.getMethod();
    CompilationPlan compPlan = new CompilationPlan(m, _optPlan, null, _options);
    ControllerPlan cp = // 2.0 is a bogus number....
    new ControllerPlan(compPlan, Controller.controllerClock, id, 2.0, 2.0, 2.0);
    cp.execute();
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) ControllerPlan(org.jikesrvm.adaptive.controller.ControllerPlan) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Entrypoint(org.vmmagic.pragma.Entrypoint)

Aggregations

Entrypoint (org.vmmagic.pragma.Entrypoint)69 Inline (org.vmmagic.pragma.Inline)35 ObjectReference (org.vmmagic.unboxed.ObjectReference)33 Offset (org.vmmagic.unboxed.Offset)22 Address (org.vmmagic.unboxed.Address)12 TypeReference (org.jikesrvm.classloader.TypeReference)7 NoInline (org.vmmagic.pragma.NoInline)7 RVMType (org.jikesrvm.classloader.RVMType)6 Unpreemptible (org.vmmagic.pragma.Unpreemptible)6 RVMMethod (org.jikesrvm.classloader.RVMMethod)5 RVMArray (org.jikesrvm.classloader.RVMArray)3 RVMClass (org.jikesrvm.classloader.RVMClass)3 RVMThread (org.jikesrvm.scheduler.RVMThread)3 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 NoOptCompile (org.vmmagic.pragma.NoOptCompile)3 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 ITable (org.jikesrvm.objectmodel.ITable)2 TIB (org.jikesrvm.objectmodel.TIB)2