agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6833129 Sdiff agent/src/share/classes/sun/jvm/hotspot/code

agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java

Print this page




  24 
  25 package sun.jvm.hotspot.code;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.oops.*;
  32 import sun.jvm.hotspot.runtime.*;
  33 import sun.jvm.hotspot.utilities.*;
  34 
  35 /** ScopeDescs contain the information that makes source-level
  36     debugging of nmethods possible; each scopeDesc describes a method
  37     activation */
  38 
  39 public class ScopeDesc {
  40   /** NMethod information */
  41   private NMethod code;
  42   private Method  method;
  43   private int     bci;

  44   /** Decoding offsets */
  45   private int     decodeOffset;
  46   private int     senderDecodeOffset;
  47   private int     localsDecodeOffset;
  48   private int     expressionsDecodeOffset;
  49   private int     monitorsDecodeOffset;
  50   /** Scalar replaced bjects pool */
  51   private List    objects; // ArrayList<ScopeValue>
  52 
  53 
  54   public ScopeDesc(NMethod code, int decodeOffset) {
  55     this.code = code;
  56     this.decodeOffset = decodeOffset;
  57     this.objects      = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL);
  58 
  59     // Decode header
  60     DebugInfoReadStream stream  = streamAt(decodeOffset);
  61 
  62     senderDecodeOffset = stream.readInt();
  63     method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
  64     bci    = stream.readBCI();
  65     // Decode offsets for body and sender
  66     localsDecodeOffset      = stream.readInt();
  67     expressionsDecodeOffset = stream.readInt();
  68     monitorsDecodeOffset    = stream.readInt();
  69   }
  70 
  71   public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset) {
  72     this.code = code;
  73     this.decodeOffset = decodeOffset;
  74     this.objects      = decodeObjectValues(objectDecodeOffset);
  75 
  76     // Decode header
  77     DebugInfoReadStream stream  = streamAt(decodeOffset);
  78 
  79     senderDecodeOffset = stream.readInt();
  80     method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
  81     bci    = stream.readBCI();
  82     // Decode offsets for body and sender
  83     localsDecodeOffset      = stream.readInt();
  84     expressionsDecodeOffset = stream.readInt();
  85     monitorsDecodeOffset    = stream.readInt();
  86   }
  87 
  88   public NMethod getNMethod() { return code; }
  89   public Method getMethod() { return method; }
  90   public int    getBCI()    { return bci;    }

  91 
  92   /** Returns a List&lt;ScopeValue&gt; */
  93   public List getLocals() {
  94     return decodeScopeValues(localsDecodeOffset);
  95   }
  96 
  97   /** Returns a List&lt;ScopeValue&gt; */
  98   public List getExpressions() {
  99     return decodeScopeValues(expressionsDecodeOffset);
 100   }
 101 
 102   /** Returns a List&lt;MonitorValue&gt; */
 103   public List getMonitors() {
 104     return decodeMonitorValues(monitorsDecodeOffset);
 105   }
 106 
 107   /** Returns a List&lt;MonitorValue&gt; */
 108   public List getObjects() {
 109     return objects;
 110   }


 133       return false;
 134     }
 135 
 136     if (!(arg instanceof ScopeDesc)) {
 137       return false;
 138     }
 139 
 140     ScopeDesc sd = (ScopeDesc) arg;
 141 
 142     return (sd.method.equals(method) && (sd.bci == bci));
 143   }
 144 
 145   public void printValue() {
 146     printValueOn(System.out);
 147   }
 148 
 149   public void printValueOn(PrintStream tty) {
 150     tty.print("ScopeDesc for ");
 151     method.printValueOn(tty);
 152     tty.println(" @bci " + bci);

 153   }
 154 
 155   // FIXME: add more accessors
 156 
 157   //--------------------------------------------------------------------------------
 158   // Internals only below this point
 159   //





 160 
 161   private DebugInfoReadStream streamAt(int decodeOffset) {
 162     return new DebugInfoReadStream(code, decodeOffset, objects);
 163   }
 164 
 165   /** Returns a List&lt;ScopeValue&gt; or null if no values were present */
 166   private List decodeScopeValues(int decodeOffset) {
 167     if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) {
 168       return null;
 169     }
 170     DebugInfoReadStream stream = streamAt(decodeOffset);
 171     int length = stream.readInt();
 172     List res = new ArrayList(length);
 173     for (int i = 0; i < length; i++) {
 174       res.add(ScopeValue.readFrom(stream));
 175     }
 176     return res;
 177   }
 178 
 179   /** Returns a List&lt;MonitorValue&gt; or null if no values were present */




  24 
  25 package sun.jvm.hotspot.code;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.oops.*;
  32 import sun.jvm.hotspot.runtime.*;
  33 import sun.jvm.hotspot.utilities.*;
  34 
  35 /** ScopeDescs contain the information that makes source-level
  36     debugging of nmethods possible; each scopeDesc describes a method
  37     activation */
  38 
  39 public class ScopeDesc {
  40   /** NMethod information */
  41   private NMethod code;
  42   private Method  method;
  43   private int     bci;
  44   private boolean reexecute;
  45   /** Decoding offsets */
  46   private int     decodeOffset;
  47   private int     senderDecodeOffset;
  48   private int     localsDecodeOffset;
  49   private int     expressionsDecodeOffset;
  50   private int     monitorsDecodeOffset;
  51   /** Scalar replaced bjects pool */
  52   private List    objects; // ArrayList<ScopeValue>
  53 
  54 
  55   public ScopeDesc(NMethod code, int decodeOffset) {
  56     this.code = code;
  57     this.decodeOffset = decodeOffset;
  58     this.objects      = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL);
  59 
  60     // Decode header
  61     DebugInfoReadStream stream  = streamAt(decodeOffset);
  62 
  63     senderDecodeOffset = stream.readInt();
  64     method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
  65     setBCIAndReexecute(stream.readInt());
  66     // Decode offsets for body and sender
  67     localsDecodeOffset      = stream.readInt();
  68     expressionsDecodeOffset = stream.readInt();
  69     monitorsDecodeOffset    = stream.readInt();
  70   }
  71 
  72   public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset) {
  73     this.code = code;
  74     this.decodeOffset = decodeOffset;
  75     this.objects      = decodeObjectValues(objectDecodeOffset);
  76 
  77     // Decode header
  78     DebugInfoReadStream stream  = streamAt(decodeOffset);
  79 
  80     senderDecodeOffset = stream.readInt();
  81     method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
  82     setBCIAndReexecute(stream.readInt());
  83     // Decode offsets for body and sender
  84     localsDecodeOffset      = stream.readInt();
  85     expressionsDecodeOffset = stream.readInt();
  86     monitorsDecodeOffset    = stream.readInt();
  87   }
  88 
  89   public NMethod getNMethod() { return code; }
  90   public Method getMethod() { return method; }
  91   public int    getBCI()    { return bci;    }
  92   public boolean getReexecute() {return reexecute;}
  93 
  94   /** Returns a List&lt;ScopeValue&gt; */
  95   public List getLocals() {
  96     return decodeScopeValues(localsDecodeOffset);
  97   }
  98 
  99   /** Returns a List&lt;ScopeValue&gt; */
 100   public List getExpressions() {
 101     return decodeScopeValues(expressionsDecodeOffset);
 102   }
 103 
 104   /** Returns a List&lt;MonitorValue&gt; */
 105   public List getMonitors() {
 106     return decodeMonitorValues(monitorsDecodeOffset);
 107   }
 108 
 109   /** Returns a List&lt;MonitorValue&gt; */
 110   public List getObjects() {
 111     return objects;
 112   }


 135       return false;
 136     }
 137 
 138     if (!(arg instanceof ScopeDesc)) {
 139       return false;
 140     }
 141 
 142     ScopeDesc sd = (ScopeDesc) arg;
 143 
 144     return (sd.method.equals(method) && (sd.bci == bci));
 145   }
 146 
 147   public void printValue() {
 148     printValueOn(System.out);
 149   }
 150 
 151   public void printValueOn(PrintStream tty) {
 152     tty.print("ScopeDesc for ");
 153     method.printValueOn(tty);
 154     tty.println(" @bci " + bci);
 155     tty.println(" reexecute: " + reexecute);  
 156   }
 157 
 158   // FIXME: add more accessors
 159 
 160   //--------------------------------------------------------------------------------
 161   // Internals only below this point
 162   //
 163   private void setBCIAndReexecute(int combination) {
 164     int InvocationEntryBci = VM.getVM().getInvocationEntryBCI();
 165     bci = (combination >> 1) + InvocationEntryBci;
 166     reexecute = (combination & 1)==1 ? true : false;
 167   }
 168 
 169   private DebugInfoReadStream streamAt(int decodeOffset) {
 170     return new DebugInfoReadStream(code, decodeOffset, objects);
 171   }
 172 
 173   /** Returns a List&lt;ScopeValue&gt; or null if no values were present */
 174   private List decodeScopeValues(int decodeOffset) {
 175     if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) {
 176       return null;
 177     }
 178     DebugInfoReadStream stream = streamAt(decodeOffset);
 179     int length = stream.readInt();
 180     List res = new ArrayList(length);
 181     for (int i = 0; i < length; i++) {
 182       res.add(ScopeValue.readFrom(stream));
 183     }
 184     return res;
 185   }
 186 
 187   /** Returns a List&lt;MonitorValue&gt; or null if no values were present */


agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File