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);
}
}
}
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);
}
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.]");
}
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();
}
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();
}
Aggregations