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<ScopeValue> */ 95 public List getLocals() { 96 return decodeScopeValues(localsDecodeOffset); 97 } 98 99 /** Returns a List<ScopeValue> */ 100 public List getExpressions() { 101 return decodeScopeValues(expressionsDecodeOffset); 102 } 103 104 /** Returns a List<MonitorValue> */ 105 public List getMonitors() { 106 return decodeMonitorValues(monitorsDecodeOffset); 107 } 108 109 /** Returns a List<MonitorValue> */ 110 public List getObjects() { 111 return objects; 112 } 113 114 /** Stack walking. Returns null if this is the outermost scope. */ 115 public ScopeDesc sender() { 116 if (isTop()) { 117 return null; 118 } 119 120 return new ScopeDesc(code, senderDecodeOffset); 121 } 122 123 /** Returns where the scope was decoded */ 124 public int getDecodeOffset() { 125 return decodeOffset; 126 } 127 128 /** Tells whether sender() returns null */ 129 public boolean isTop() { 130 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); 131 } 132 133 public boolean equals(Object arg) { 134 if (arg == null) { 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<ScopeValue> 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<MonitorValue> or null if no values were present */ 188 private List decodeMonitorValues(int decodeOffset) { | 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, boolean reexecute) { 56 this.code = code; 57 this.decodeOffset = decodeOffset; 58 this.objects = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL); 59 this.reexecute = reexecute; 60 61 // Decode header 62 DebugInfoReadStream stream = streamAt(decodeOffset); 63 64 senderDecodeOffset = stream.readInt(); 65 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); 66 bci = stream.readBCI(); 67 // Decode offsets for body and sender 68 localsDecodeOffset = stream.readInt(); 69 expressionsDecodeOffset = stream.readInt(); 70 monitorsDecodeOffset = stream.readInt(); 71 } 72 73 public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset, boolean reexecute) { 74 this.code = code; 75 this.decodeOffset = decodeOffset; 76 this.objects = decodeObjectValues(objectDecodeOffset); 77 this.reexecute = reexecute; 78 79 // Decode header 80 DebugInfoReadStream stream = streamAt(decodeOffset); 81 82 senderDecodeOffset = stream.readInt(); 83 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); 84 bci = stream.readBCI(); 85 // Decode offsets for body and sender 86 localsDecodeOffset = stream.readInt(); 87 expressionsDecodeOffset = stream.readInt(); 88 monitorsDecodeOffset = stream.readInt(); 89 } 90 91 public NMethod getNMethod() { return code; } 92 public Method getMethod() { return method; } 93 public int getBCI() { return bci; } 94 public boolean getReexecute() { return reexecute;} 95 96 /** Returns a List<ScopeValue> */ 97 public List getLocals() { 98 return decodeScopeValues(localsDecodeOffset); 99 } 100 101 /** Returns a List<ScopeValue> */ 102 public List getExpressions() { 103 return decodeScopeValues(expressionsDecodeOffset); 104 } 105 106 /** Returns a List<MonitorValue> */ 107 public List getMonitors() { 108 return decodeMonitorValues(monitorsDecodeOffset); 109 } 110 111 /** Returns a List<MonitorValue> */ 112 public List getObjects() { 113 return objects; 114 } 115 116 /** Stack walking. Returns null if this is the outermost scope. */ 117 public ScopeDesc sender() { 118 if (isTop()) { 119 return null; 120 } 121 122 return new ScopeDesc(code, senderDecodeOffset, false); 123 } 124 125 /** Returns where the scope was decoded */ 126 public int getDecodeOffset() { 127 return decodeOffset; 128 } 129 130 /** Tells whether sender() returns null */ 131 public boolean isTop() { 132 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); 133 } 134 135 public boolean equals(Object arg) { 136 if (arg == null) { 137 return false; 138 } 139 140 if (!(arg instanceof ScopeDesc)) { 141 return false; 142 } 143 144 ScopeDesc sd = (ScopeDesc) arg; 145 146 return (sd.method.equals(method) && (sd.bci == bci)); 147 } 148 149 public void printValue() { 150 printValueOn(System.out); 151 } 152 153 public void printValueOn(PrintStream tty) { 154 tty.print("ScopeDesc for "); 155 method.printValueOn(tty); 156 tty.print(" @bci " + bci); 157 tty.println(" reexecute=" + reexecute); 158 } 159 160 // FIXME: add more accessors 161 162 //-------------------------------------------------------------------------------- 163 // Internals only below this point 164 // 165 private DebugInfoReadStream streamAt(int decodeOffset) { 166 return new DebugInfoReadStream(code, decodeOffset, objects); 167 } 168 169 /** Returns a List<ScopeValue> or null if no values were present */ 170 private List decodeScopeValues(int decodeOffset) { 171 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { 172 return null; 173 } 174 DebugInfoReadStream stream = streamAt(decodeOffset); 175 int length = stream.readInt(); 176 List res = new ArrayList(length); 177 for (int i = 0; i < length; i++) { 178 res.add(ScopeValue.readFrom(stream)); 179 } 180 return res; 181 } 182 183 /** Returns a List<MonitorValue> or null if no values were present */ 184 private List decodeMonitorValues(int decodeOffset) { |