org.jikesrvm.runtime
Class StackTrace

java.lang.Object
  extended by org.jikesrvm.runtime.StackTrace

public class StackTrace
extends Object

A list of compiled method and instructionOffset pairs that describe the state of the call stack at a particular instant.


Nested Class Summary
static class StackTrace.Element
          Class to wrap up a stack frame element
 
Field Summary
private  int[] compiledMethods
          The compiled method ids of the stack trace.
private  int[] instructionOffsets
          The offset of the instruction within the compiled method
private static int lastTraceIndex
          Index of the last stack trace; only used to support VM.VerboseStackTracePeriod
 
Constructor Summary
StackTrace()
          Create a trace for the call stack of RVMThread.getThreadForStackTrace (normally the current thread unless we're in GC)
 
Method Summary
private  int countFrames(int first, int last)
          Count number of stack frames including those inlined by the opt compiler
private  int countFramesUninterruptible(RVMThread stackTraceThread)
          Walk the stack counting the number of stack frames encountered.
private  int firstRealMethod(Throwable cause)
          Find the first non-VM method/exception initializer method in the stack trace.
private  CompiledMethod getCompiledMethod(int element)
          Get the compiled method at element
 StackTrace.Element[] getStackTrace(Throwable cause)
          Return the stack trace for use by the Throwable API
private  int lastRealMethod(int first)
          Find the first non-VM method at the end of the stack trace
private  void recordFramesUninterruptible(RVMThread stackTraceThread)
          Walk the stack recording the stack frames encountered The stack being walked is our stack, so code is Uninterrupible to stop the stack moving.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compiledMethods

private final int[] compiledMethods
The compiled method ids of the stack trace. Ordered with the top of the stack at 0 and the bottom of the stack at the end of the array


instructionOffsets

private final int[] instructionOffsets
The offset of the instruction within the compiled method


lastTraceIndex

private static int lastTraceIndex
Index of the last stack trace; only used to support VM.VerboseStackTracePeriod

Constructor Detail

StackTrace

public StackTrace()
Create a trace for the call stack of RVMThread.getThreadForStackTrace (normally the current thread unless we're in GC)

Method Detail

countFramesUninterruptible

private int countFramesUninterruptible(RVMThread stackTraceThread)
Walk the stack counting the number of stack frames encountered. The stack being walked is our stack, so code is Uninterruptible to stop the stack moving.

Returns:
number of stack frames encountered

recordFramesUninterruptible

private void recordFramesUninterruptible(RVMThread stackTraceThread)
Walk the stack recording the stack frames encountered The stack being walked is our stack, so code is Uninterrupible to stop the stack moving.


getCompiledMethod

private CompiledMethod getCompiledMethod(int element)
Get the compiled method at element


getStackTrace

public StackTrace.Element[] getStackTrace(Throwable cause)
Return the stack trace for use by the Throwable API


countFrames

private int countFrames(int first,
                        int last)
Count number of stack frames including those inlined by the opt compiler

Parameters:
first - the first compiled method to look from
last - the last compiled method to look to

firstRealMethod

private int firstRealMethod(Throwable cause)
Find the first non-VM method/exception initializer method in the stack trace. As we're working with the compiled methods we're assuming the constructor of the exception won't have been inlined into the throwing method.

Parameters:
cause - the cause of generating the stack trace marking the end of the frames to elide
Returns:
the index of the method throwing the exception or else 0

lastRealMethod

private int lastRealMethod(int first)
Find the first non-VM method at the end of the stack trace

Parameters:
first - the first real method of the stack trace
Returns:
compiledMethods.length-1 if no non-VM methods found else the index of the method