use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class TraceInterface method skipOwnFramesAndDump.
@Override
@NoInline
// This can't be uninterruptible --- it is an IO routine
@Interruptible
public Address skipOwnFramesAndDump(ObjectReference typeRef) {
TIB tib = Magic.addressAsTIB(typeRef.toAddress());
RVMMethod m = null;
int bci = -1;
int compiledMethodID = 0;
Offset ipOffset = Offset.zero();
Address fp = Magic.getFramePointer();
Address ip = Magic.getReturnAddressUnchecked(fp);
fp = Magic.getCallerFramePointer(fp);
// This code borrows heavily from RVMThread.dumpStack
final Address STACKFRAME_SENTINEL_FP = StackFrameLayout.getStackFrameSentinelFP();
final int INVISIBLE_METHOD_ID = StackFrameLayout.getInvisibleMethodID();
while (Magic.getCallerFramePointer(fp).NE(STACKFRAME_SENTINEL_FP)) {
compiledMethodID = Magic.getCompiledMethodID(fp);
if (compiledMethodID != INVISIBLE_METHOD_ID) {
// normal java frame(s)
CompiledMethod compiledMethod = CompiledMethods.getCompiledMethod(compiledMethodID);
if (compiledMethod.getCompilerType() != CompiledMethod.TRAP) {
ipOffset = compiledMethod.getInstructionOffset(ip);
m = compiledMethod.getMethod();
if (VM.BuildForOptCompiler && compiledMethod.getCompilerType() == CompiledMethod.OPT) {
OptCompiledMethod optInfo = (OptCompiledMethod) compiledMethod;
/* Opt stack frames may contain multiple inlined methods. */
OptMachineCodeMap map = optInfo.getMCMap();
int iei = map.getInlineEncodingForMCOffset(ipOffset);
if (iei >= 0) {
int[] inlineEncoding = map.inlineEncoding;
boolean allocCall = true;
bci = map.getBytecodeIndexForMCOffset(ipOffset);
for (int j = iei; j >= 0 && allocCall; j = OptEncodedCallSiteTree.getParent(j, inlineEncoding)) {
int mid = OptEncodedCallSiteTree.getMethodID(j, inlineEncoding);
m = MemberReference.getMethodRef(mid).getResolvedMember();
if (!isAllocCall(m.getName().getBytes()))
allocCall = false;
if (j > 0)
bci = OptEncodedCallSiteTree.getByteCodeOffset(j, inlineEncoding);
}
if (!allocCall)
break;
}
} else {
if (!isAllocCall(m.getName().getBytes())) {
BaselineCompiledMethod baseInfo = (BaselineCompiledMethod) compiledMethod;
final int INSTRUCTION_WIDTH = ArchConstants.getInstructionWidth();
bci = baseInfo.findBytecodeIndexForInstruction(ipOffset.toWord().lsh(INSTRUCTION_WIDTH).toOffset());
break;
}
}
}
}
ip = Magic.getReturnAddressUnchecked(fp);
fp = Magic.getCallerFramePointer(fp);
}
if (m != null) {
int allocid = (((compiledMethodID & 0x0000ffff) << 15) ^ ((compiledMethodID & 0xffff0000) >> 16) ^ ipOffset.toInt()) & ~0x80000000;
/* Now print the location string. */
VM.sysWrite('\n');
VM.writeHex(allocid);
VM.sysWrite('-');
VM.sysWrite('>');
VM.sysWrite('[');
VM.writeHex(compiledMethodID);
VM.sysWrite(']');
m.getDeclaringClass().getDescriptor().sysWrite();
VM.sysWrite(':');
m.getName().sysWrite();
m.getDescriptor().sysWrite();
VM.sysWrite(':');
VM.writeHex(bci);
VM.sysWrite('\t');
RVMType type = tib.getType();
type.getDescriptor().sysWrite();
VM.sysWrite('\n');
}
return fp;
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class ServerInterpreter method init.
@Override
@Interruptible
public void init(String name, int port, boolean verbose) {
if (org.jikesrvm.VM.BuildWithGCSpy) {
if (VM.VERIFY_ASSERTIONS)
VM.assertions._assert(!initialised, "Tried to re-init server interpreter");
initialised = true;
if (DEBUG)
Log.writeln("-- Initialising main server on port ", port);
Address tmp = GCspy.util.getBytes(name);
server = sysCall.gcspyMainServerInit(port, MAX_LEN, tmp, verbose ? 1 : 0);
if (DEBUG) {
Log.writeln("gcspy_main_server_t address = ");
Log.writeln(server);
}
GCspy.util.free(tmp);
// Set up the list of ServerSpaces
spaces = new org.jikesrvm.mm.mmtk.gcspy.ServerSpace[MAX_SPACES];
}
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class Collection method spawnCollectorContext.
/**
**************************************************************************
*
* Class variables
*/
/**
* {@inheritDoc}
*/
@Override
@Interruptible
public void spawnCollectorContext(CollectorContext context) {
byte[] stack = MemoryManager.newStack(StackFrameLayout.getStackSizeCollector());
CollectorThread t = new CollectorThread(stack, context);
t.start();
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class VM method finishBooting.
/**
* Complete the task of booting Jikes RVM.
* Done in a secondary method mainly because this code
* doesn't have to be uninterruptible and this is the cleanest
* way to make that distinction.
*/
@Interruptible
private static void finishBooting() {
// get pthread_id from OS and store into vm_processor field
//
RVMThread.getCurrentThread().pthread_id = sysCall.sysGetThreadId();
RVMThread.getCurrentThread().priority_handle = sysCall.sysGetThreadPriorityHandle();
RVMThread.availableProcessors = SysCall.sysCall.sysNumProcessors();
// Set up buffer locks used by Thread for logging and status dumping.
// This can happen at any point before we start running
// multi-threaded.
Services.boot();
//
if (verboseBoot >= 1) {
VM.sysWriteln("Setting up memory manager: bootrecord = ", Magic.objectAsAddress(BootRecord.the_boot_record));
}
MemoryManager.boot(BootRecord.the_boot_record);
//
if (verboseBoot >= 1)
VM.sysWriteln("Initializing baseline compiler options to defaults");
BaselineCompiler.initOptions();
//
if (verboseBoot >= 1)
VM.sysWriteln("Fetching command-line arguments");
CommandLineArgs.fetchCommandLineArguments();
//
if (verboseBoot >= 1)
VM.sysWriteln("Early stage processing of command line");
CommandLineArgs.earlyProcessCommandLineArguments();
// Early initialization of TuningFork tracing engine.
TraceEngine.engine.earlyStageBooting();
//
if (verboseBoot >= 1)
VM.sysWriteln("Collector processing rest of boot options");
MemoryManager.postBoot();
// Initialize class loader.
//
String bootstrapClasses = CommandLineArgs.getBootstrapClasses();
if (verboseBoot >= 1)
VM.sysWriteln("Initializing bootstrap class loader: ", bootstrapClasses);
Callbacks.addClassLoadedMonitor(JMXSupport.CLASS_LOADING_JMX_SUPPORT);
// Wipe out cached application class loader
RVMClassLoader.boot();
BootstrapClassLoader.boot(bootstrapClasses);
//
if (verboseBoot >= 1)
VM.sysWriteln("Running various class initializers");
if (VM.BuildForGnuClasspath) {
// Need for ThreadLocal
runClassInitializer("java.util.WeakHashMap");
}
runClassInitializer("org.jikesrvm.classloader.Atom$InternedStrings");
if (VM.BuildForGnuClasspath) {
runClassInitializer("gnu.classpath.SystemProperties");
runClassInitializer("java.lang.Throwable$StaticData");
}
runClassInitializer("java.lang.Runtime");
runClassInitializer("java.lang.System");
runClassInitializer("sun.misc.Unsafe");
runClassInitializer("java.lang.Character");
runClassInitializer("org.jikesrvm.classloader.TypeReferenceVector");
runClassInitializer("org.jikesrvm.classloader.MethodVector");
runClassInitializer("org.jikesrvm.classloader.FieldVector");
// java.security.JikesRVMSupport.turnOffChecks();
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.lang.ThreadGroup");
}
/* We can safely allocate a java.lang.Thread now. The boot
thread (running right now, as a Thread) has to become a full-fledged
Thread, since we're about to encounter a security check:
EncodingManager checks a system property,
which means that the permissions checks have to be working,
which means that VMAccessController will be invoked,
which means that ThreadLocal.get() will be called,
which calls Thread.getCurrentThread().
So the boot Thread needs to be associated with a real Thread for
Thread.getCurrentThread() to return. */
VM.safeToAllocateJavaThread = true;
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.lang.ThreadLocal");
runClassInitializer("java.lang.ThreadLocalMap");
}
// Possibly fix VMAccessController's contexts and inGetContext fields
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.security.VMAccessController");
}
if (VM.BuildForHarmony) {
runClassInitializer("java.security.AccessController");
}
if (verboseBoot >= 1)
VM.sysWriteln("Booting Lock");
Lock.boot();
//
if (verboseBoot >= 1)
VM.sysWriteln("Booting scheduler");
RVMThread.boot();
DynamicLibrary.boot();
if (verboseBoot >= 1)
VM.sysWriteln("Enabling GC");
MemoryManager.enableCollection();
if (verboseBoot >= 1)
VM.sysWriteln("Setting up boot thread");
RVMThread.getCurrentThread().setupBootJavaThread();
// Create JNI Environment for boot thread.
// After this point the boot thread can invoke native methods.
org.jikesrvm.jni.JNIEnvironment.boot();
if (verboseBoot >= 1)
VM.sysWriteln("Initializing JNI for boot thread");
RVMThread.getCurrentThread().initializeJNIEnv();
if (verboseBoot >= 1)
VM.sysWriteln("JNI initialized for boot thread");
if (VM.BuildForHarmony) {
System.loadLibrary("hyluni");
System.loadLibrary("hythr");
System.loadLibrary("hyniochar");
}
// needed for when we initialize the
runClassInitializer("java.io.File");
// system/application class loader.
runClassInitializer("java.lang.String");
if (VM.BuildForGnuClasspath) {
runClassInitializer("gnu.java.security.provider.DefaultPolicy");
}
// needed for URLClassLoader
runClassInitializer("java.net.URL");
/* Needed for ApplicationClassLoader, which in turn is needed by
VMClassLoader.getSystemClassLoader() */
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.net.URLClassLoader");
}
/* Used if we start up Jikes RVM with the -jar argument; that argument
* means that we need a working -jar before we can return an
* Application Class Loader. */
runClassInitializer("java.net.URLConnection");
if (VM.BuildForGnuClasspath) {
runClassInitializer("gnu.java.net.protocol.jar.Connection$JarFileCache");
runClassInitializer("java.lang.ClassLoader$StaticData");
}
runClassInitializer("java.lang.Class$StaticData");
runClassInitializer("java.nio.charset.Charset");
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.nio.charset.CharsetEncoder");
}
runClassInitializer("java.nio.charset.CoderResult");
if (VM.BuildForHarmony) {
runClassInitializer("org.apache.harmony.niochar.CharsetProviderImpl");
}
// Uses System.getProperty
runClassInitializer("java.io.PrintWriter");
System.setProperty("line.separator", "\n");
// Uses System.getProperty
runClassInitializer("java.io.PrintStream");
runClassInitializer("java.util.Locale");
runClassInitializer("java.util.ResourceBundle");
runClassInitializer("java.util.zip.CRC32");
if (VM.BuildForHarmony) {
System.loadLibrary("hyarchive");
}
runClassInitializer("java.util.zip.Inflater");
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.util.zip.DeflaterHuffman");
runClassInitializer("java.util.zip.InflaterDynHeader");
runClassInitializer("java.util.zip.InflaterHuffmanTree");
}
// Run class initializers that require JNI
if (verboseBoot >= 1)
VM.sysWriteln("Running late class initializers");
if (VM.BuildForGnuClasspath) {
System.loadLibrary("javaio");
}
runClassInitializer("java.lang.Math");
runClassInitializer("java.util.TreeMap");
if (VM.BuildForGnuClasspath) {
runClassInitializer("gnu.java.nio.VMChannel");
runClassInitializer("gnu.java.nio.FileChannelImpl");
}
runClassInitializer("java.io.FileDescriptor");
runClassInitializer("java.io.FilePermission");
runClassInitializer("java.util.jar.JarFile");
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.util.zip.ZipFile$PartialInputStream");
}
runClassInitializer("java.util.zip.ZipFile");
if (VM.BuildForHarmony) {
runClassInitializer("java.util.Hashtable");
runClassInitializer("java.util.jar.Manifest");
runClassInitializer("java.util.jar.Attributes$Name");
runClassInitializer("java.util.BitSet");
runClassInitializer("java.util.regex.Matcher");
runClassInitializer("java.util.regex.Pattern");
runClassInitializer("org.apache.harmony.luni.internal.net.www.protocol.jar.JarURLConnection");
runClassInitializer("org.apache.harmony.luni.platform.OSMemory");
runClassInitializer("org.apache.harmony.luni.platform.Platform");
runClassInitializer("org.apache.harmony.luni.platform.AbstractMemorySpy");
runClassInitializer("org.apache.harmony.luni.platform.PlatformAddress");
runClassInitializer("org.apache.harmony.nio.internal.FileChannelImpl");
runClassInitializer("com.ibm.icu.util.ULocale");
runClassInitializer("java.io.ObjectStreamClass");
runClassInitializer("java.io.ObjectStreamClass$OSCThreadLocalCache");
runClassInitializer("java.io.ObjectInputStream");
runClassInitializer("java.security.MessageDigest");
}
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.lang.VMDouble");
}
runClassInitializer("java.util.PropertyPermission");
runClassInitializer("org.jikesrvm.classloader.RVMAnnotation");
runClassInitializer("java.lang.annotation.RetentionPolicy");
runClassInitializer("java.lang.annotation.ElementType");
runClassInitializer("java.lang.Thread$State");
if (VM.BuildForGnuClasspath) {
runClassInitializer("gnu.java.nio.charset.EncodingHelper");
runClassInitializer("java.lang.VMClassLoader");
}
if (verboseBoot >= 1)
VM.sysWriteln("initializing standard streams");
// Initialize java.lang.System.out, java.lang.System.err, java.lang.System.in
FileSystem.initializeStandardStreams();
// /////////////////////////////////////////////////////////////
if (verboseBoot >= 1)
VM.sysWriteln("VM is now fully booted");
// Inform interested subsystems that VM is fully booted.
VM.fullyBooted = true;
MemoryManager.fullyBootedVM();
org.jikesrvm.mm.mminterface.JMXSupport.fullyBootedVM();
BaselineCompiler.fullyBootedVM();
TraceEngine.engine.fullyBootedVM();
runClassInitializer("java.util.logging.Level");
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.lang.reflect.Proxy");
runClassInitializer("java.lang.reflect.Proxy$ProxySignature");
}
runClassInitializer("java.util.logging.Logger");
if (VM.BuildForHarmony) {
Entrypoints.luni1.setObjectValueUnchecked(null, null);
Entrypoints.luni2.setObjectValueUnchecked(null, null);
Entrypoints.luni3.setObjectValueUnchecked(null, null);
Entrypoints.luni4.setObjectValueUnchecked(null, null);
Entrypoints.luni5.setObjectValueUnchecked(null, null);
Entrypoints.luni6.setObjectValueUnchecked(null, null);
// runClassInitializer("java.lang.String$ConsolePrintStream");
runClassInitializer("org.apache.harmony.luni.util.Msg");
runClassInitializer("org.apache.harmony.archive.internal.nls.Messages");
runClassInitializer("org.apache.harmony.luni.internal.nls.Messages");
runClassInitializer("org.apache.harmony.nio.internal.nls.Messages");
runClassInitializer("org.apache.harmony.niochar.internal.nls.Messages");
runClassInitializer("java.util.logging.LogManager");
}
//
if (verboseBoot >= 1)
VM.sysWriteln("Initializing runtime compiler");
RuntimeCompiler.boot();
// Process remainder of the VM's command line arguments.
if (verboseBoot >= 1)
VM.sysWriteln("Late stage processing of command line");
String[] applicationArguments = CommandLineArgs.lateProcessCommandLineArguments();
if (VM.verboseClassLoading || verboseBoot >= 1)
VM.sysWriteln("[VM booted]");
if (VM.BuildForAdaptiveSystem) {
if (verboseBoot >= 1)
VM.sysWriteln("Initializing adaptive system");
Controller.boot();
}
// The first argument must be a class name.
if (verboseBoot >= 1)
VM.sysWriteln("Extracting name of class to execute");
if (applicationArguments.length == 0) {
pleaseSpecifyAClass();
}
if (applicationArguments.length > 0 && !TypeDescriptorParsing.isJavaClassName(applicationArguments[0])) {
VM.sysWrite("vm: \"");
VM.sysWrite(applicationArguments[0]);
VM.sysWriteln("\" is not a legal Java class name.");
pleaseSpecifyAClass();
}
if (applicationArguments.length > 0 && applicationArguments[0].startsWith("-X")) {
VM.sysWrite("vm: \"");
VM.sysWrite(applicationArguments[0]);
VM.sysWriteln("\" is not a recognized Jikes RVM command line argument.");
VM.sysExit(EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
}
if (verboseBoot >= 1)
VM.sysWriteln("Initializing Application Class Loader");
RVMClassLoader.getApplicationClassLoader();
RVMClassLoader.declareApplicationClassLoaderIsReady();
if (verboseBoot >= 1) {
VM.sysWriteln("Turning back on security checks. Letting people see the ApplicationClassLoader.");
}
if (VM.BuildForGnuClasspath) {
runClassInitializer("java.lang.ClassLoader$StaticData");
}
if (VM.BuildForAdaptiveSystem) {
CompilerAdvice.postBoot();
}
// enable alignment checking
if (VM.AlignmentChecking) {
SysCall.sysCall.sysEnableAlignmentChecking();
}
Time.boot();
// Set up properties for our custom JUnit test runner.
Configuration.setupPropertiesForUnitTesting();
// Schedule "main" thread for execution.
if (verboseBoot >= 2)
VM.sysWriteln("Creating main thread");
// Create main thread.
if (verboseBoot >= 1)
VM.sysWriteln("Constructing mainThread");
mainThread = new MainThread(applicationArguments);
// Schedule "main" thread for execution.
if (verboseBoot >= 1)
VM.sysWriteln("Starting main thread");
mainThread.start();
//
if (VM.TraceThreads)
RVMThread.trace("VM.boot", "completed - terminating");
if (verboseBoot >= 2) {
VM.sysWriteln("Boot sequence completed; finishing boot thread");
}
RVMThread.getCurrentThread().terminate();
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class OptCompiledMethod method isWithinUninterruptibleCode.
@Override
@Interruptible
public boolean isWithinUninterruptibleCode(Offset instructionOffset) {
NormalMethod realMethod = _mcMap.getMethodForMCOffset(instructionOffset);
// error message when no method is found.
if (realMethod == null) {
VM.sysWrite("Failing instruction offset: ");
VM.sysWrite(instructionOffset);
VM.sysWrite(" in method ");
RVMMethod thisMethod = this.getMethod();
VM.sysWrite(thisMethod.getName());
VM.sysWrite(" with descriptor ");
VM.sysWrite(thisMethod.getDescriptor());
VM.sysWrite(" declared by class with descriptor ");
VM.sysWriteln(thisMethod.getDeclaringClass().getDescriptor());
String msg = "Couldn't find a method for given instruction offset";
if (VM.VerifyAssertions) {
VM._assert(NOT_REACHED, msg);
} else {
VM.sysFail(msg);
}
}
return realMethod.isUninterruptible();
}
Aggregations