src/share/vm/code/debugInfo.hpp

Tue, 15 Sep 2009 21:53:47 -0700

author
jrose
date
Tue, 15 Sep 2009 21:53:47 -0700
changeset 1424
148e5441d916
parent 1366
72088be4b386
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6863023: need non-perm oops in code cache for JSR 292
Summary: Make a special root-list for those few nmethods which might contain non-perm oops.
Reviewed-by: twisti, kvn, never, jmasa, ysr

duke@435 1 /*
cfang@1366 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // Classes used for serializing debugging information.
duke@435 26 // These abstractions are introducted to provide symmetric
duke@435 27 // read and write operations.
duke@435 28
duke@435 29 // ScopeValue describes the value of a variable/expression in a scope
duke@435 30 // - LocationValue describes a value in a given location (in frame or register)
duke@435 31 // - ConstantValue describes a constant
duke@435 32
duke@435 33 class ScopeValue: public ResourceObj {
duke@435 34 public:
duke@435 35 // Testers
duke@435 36 virtual bool is_location() const { return false; }
duke@435 37 virtual bool is_object() const { return false; }
duke@435 38 virtual bool is_constant_int() const { return false; }
duke@435 39 virtual bool is_constant_double() const { return false; }
duke@435 40 virtual bool is_constant_long() const { return false; }
duke@435 41 virtual bool is_constant_oop() const { return false; }
duke@435 42 virtual bool equals(ScopeValue* other) const { return false; }
duke@435 43
duke@435 44 // Serialization of debugging information
duke@435 45 virtual void write_on(DebugInfoWriteStream* stream) = 0;
duke@435 46 static ScopeValue* read_from(DebugInfoReadStream* stream);
duke@435 47 };
duke@435 48
duke@435 49
duke@435 50 // A Location value describes a value in a given location; i.e. the corresponding
duke@435 51 // logical entity (e.g., a method temporary) lives in this location.
duke@435 52
duke@435 53 class LocationValue: public ScopeValue {
duke@435 54 private:
duke@435 55 Location _location;
duke@435 56 public:
duke@435 57 LocationValue(Location location) { _location = location; }
duke@435 58 bool is_location() const { return true; }
duke@435 59 Location location() const { return _location; }
duke@435 60
duke@435 61 // Serialization of debugging information
duke@435 62 LocationValue(DebugInfoReadStream* stream);
duke@435 63 void write_on(DebugInfoWriteStream* stream);
duke@435 64
duke@435 65 // Printing
duke@435 66 void print_on(outputStream* st) const;
duke@435 67 };
duke@435 68
duke@435 69
duke@435 70 // An ObjectValue describes an object eliminated by escape analysis.
duke@435 71
duke@435 72 class ObjectValue: public ScopeValue {
duke@435 73 private:
duke@435 74 int _id;
duke@435 75 ScopeValue* _klass;
duke@435 76 GrowableArray<ScopeValue*> _field_values;
duke@435 77 Handle _value;
duke@435 78 bool _visited;
duke@435 79
duke@435 80 public:
duke@435 81 ObjectValue(int id, ScopeValue* klass)
duke@435 82 : _id(id)
duke@435 83 , _klass(klass)
duke@435 84 , _field_values()
duke@435 85 , _value()
duke@435 86 , _visited(false) {
duke@435 87 assert(klass->is_constant_oop(), "should be constant klass oop");
duke@435 88 }
duke@435 89
duke@435 90 ObjectValue(int id)
duke@435 91 : _id(id)
duke@435 92 , _klass(NULL)
duke@435 93 , _field_values()
duke@435 94 , _value()
duke@435 95 , _visited(false) {}
duke@435 96
duke@435 97 // Accessors
duke@435 98 bool is_object() const { return true; }
duke@435 99 int id() const { return _id; }
duke@435 100 ScopeValue* klass() const { return _klass; }
duke@435 101 GrowableArray<ScopeValue*>* field_values() { return &_field_values; }
duke@435 102 ScopeValue* field_at(int i) const { return _field_values.at(i); }
duke@435 103 int field_size() { return _field_values.length(); }
duke@435 104 Handle value() const { return _value; }
duke@435 105 bool is_visited() const { return _visited; }
duke@435 106
duke@435 107 void set_value(oop value) { _value = Handle(value); }
duke@435 108 void set_visited(bool visited) { _visited = false; }
duke@435 109
duke@435 110 // Serialization of debugging information
duke@435 111 void read_object(DebugInfoReadStream* stream);
duke@435 112 void write_on(DebugInfoWriteStream* stream);
duke@435 113
duke@435 114 // Printing
duke@435 115 void print_on(outputStream* st) const;
duke@435 116 void print_fields_on(outputStream* st) const;
duke@435 117 };
duke@435 118
duke@435 119
duke@435 120 // A ConstantIntValue describes a constant int; i.e., the corresponding logical entity
duke@435 121 // is either a source constant or its computation has been constant-folded.
duke@435 122
duke@435 123 class ConstantIntValue: public ScopeValue {
duke@435 124 private:
duke@435 125 jint _value;
duke@435 126 public:
duke@435 127 ConstantIntValue(jint value) { _value = value; }
duke@435 128 jint value() const { return _value; }
duke@435 129 bool is_constant_int() const { return true; }
duke@435 130 bool equals(ScopeValue* other) const { return false; }
duke@435 131
duke@435 132 // Serialization of debugging information
duke@435 133 ConstantIntValue(DebugInfoReadStream* stream);
duke@435 134 void write_on(DebugInfoWriteStream* stream);
duke@435 135
duke@435 136 // Printing
duke@435 137 void print_on(outputStream* st) const;
duke@435 138 };
duke@435 139
duke@435 140 class ConstantLongValue: public ScopeValue {
duke@435 141 private:
duke@435 142 jlong _value;
duke@435 143 public:
duke@435 144 ConstantLongValue(jlong value) { _value = value; }
duke@435 145 jlong value() const { return _value; }
duke@435 146 bool is_constant_long() const { return true; }
duke@435 147 bool equals(ScopeValue* other) const { return false; }
duke@435 148
duke@435 149 // Serialization of debugging information
duke@435 150 ConstantLongValue(DebugInfoReadStream* stream);
duke@435 151 void write_on(DebugInfoWriteStream* stream);
duke@435 152
duke@435 153 // Printing
duke@435 154 void print_on(outputStream* st) const;
duke@435 155 };
duke@435 156
duke@435 157 class ConstantDoubleValue: public ScopeValue {
duke@435 158 private:
duke@435 159 jdouble _value;
duke@435 160 public:
duke@435 161 ConstantDoubleValue(jdouble value) { _value = value; }
duke@435 162 jdouble value() const { return _value; }
duke@435 163 bool is_constant_double() const { return true; }
duke@435 164 bool equals(ScopeValue* other) const { return false; }
duke@435 165
duke@435 166 // Serialization of debugging information
duke@435 167 ConstantDoubleValue(DebugInfoReadStream* stream);
duke@435 168 void write_on(DebugInfoWriteStream* stream);
duke@435 169
duke@435 170 // Printing
duke@435 171 void print_on(outputStream* st) const;
duke@435 172 };
duke@435 173
duke@435 174 // A ConstantOopWriteValue is created by the compiler to
duke@435 175 // be written as debugging information.
duke@435 176
duke@435 177 class ConstantOopWriteValue: public ScopeValue {
duke@435 178 private:
duke@435 179 jobject _value;
duke@435 180 public:
duke@435 181 ConstantOopWriteValue(jobject value) { _value = value; }
duke@435 182 jobject value() const { return _value; }
duke@435 183 bool is_constant_oop() const { return true; }
duke@435 184 bool equals(ScopeValue* other) const { return false; }
duke@435 185
duke@435 186 // Serialization of debugging information
duke@435 187 void write_on(DebugInfoWriteStream* stream);
duke@435 188
duke@435 189 // Printing
duke@435 190 void print_on(outputStream* st) const;
duke@435 191 };
duke@435 192
duke@435 193 // A ConstantOopReadValue is created by the VM when reading
duke@435 194 // debug information
duke@435 195
duke@435 196 class ConstantOopReadValue: public ScopeValue {
duke@435 197 private:
duke@435 198 Handle _value;
duke@435 199 public:
duke@435 200 Handle value() const { return _value; }
duke@435 201 bool is_constant_oop() const { return true; }
duke@435 202 bool equals(ScopeValue* other) const { return false; }
duke@435 203
duke@435 204 // Serialization of debugging information
duke@435 205 ConstantOopReadValue(DebugInfoReadStream* stream);
duke@435 206 void write_on(DebugInfoWriteStream* stream);
duke@435 207
duke@435 208 // Printing
duke@435 209 void print_on(outputStream* st) const;
duke@435 210 };
duke@435 211
duke@435 212 // MonitorValue describes the pair used for monitor_enter and monitor_exit.
duke@435 213
duke@435 214 class MonitorValue: public ResourceObj {
duke@435 215 private:
duke@435 216 ScopeValue* _owner;
duke@435 217 Location _basic_lock;
duke@435 218 bool _eliminated;
duke@435 219 public:
duke@435 220 // Constructor
duke@435 221 MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false);
duke@435 222
duke@435 223 // Accessors
duke@435 224 ScopeValue* owner() const { return _owner; }
duke@435 225 Location basic_lock() const { return _basic_lock; }
duke@435 226 bool eliminated() const { return _eliminated; }
duke@435 227
duke@435 228 // Serialization of debugging information
duke@435 229 MonitorValue(DebugInfoReadStream* stream);
duke@435 230 void write_on(DebugInfoWriteStream* stream);
duke@435 231
duke@435 232 // Printing
duke@435 233 void print_on(outputStream* st) const;
duke@435 234 };
duke@435 235
duke@435 236 // DebugInfoReadStream specializes CompressedReadStream for reading
duke@435 237 // debugging information. Used by ScopeDesc.
duke@435 238
duke@435 239 class DebugInfoReadStream : public CompressedReadStream {
duke@435 240 private:
duke@435 241 const nmethod* _code;
duke@435 242 const nmethod* code() const { return _code; }
duke@435 243 GrowableArray<ScopeValue*>* _obj_pool;
duke@435 244 public:
duke@435 245 DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) :
duke@435 246 CompressedReadStream(code->scopes_data_begin(), offset) {
duke@435 247 _code = code;
duke@435 248 _obj_pool = obj_pool;
duke@435 249
duke@435 250 } ;
duke@435 251
duke@435 252 oop read_oop() {
duke@435 253 return code()->oop_at(read_int());
duke@435 254 }
duke@435 255 ScopeValue* read_object_value();
duke@435 256 ScopeValue* get_cached_object();
duke@435 257 // BCI encoding is mostly unsigned, but -1 is a distinguished value
cfang@1366 258 int read_bci() { return read_int() + InvocationEntryBci; }
duke@435 259 };
duke@435 260
duke@435 261 // DebugInfoWriteStream specializes CompressedWriteStream for
duke@435 262 // writing debugging information. Used by ScopeDescRecorder.
duke@435 263
duke@435 264 class DebugInfoWriteStream : public CompressedWriteStream {
duke@435 265 private:
duke@435 266 DebugInformationRecorder* _recorder;
duke@435 267 DebugInformationRecorder* recorder() const { return _recorder; }
duke@435 268 public:
duke@435 269 DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size);
duke@435 270 void write_handle(jobject h);
cfang@1366 271 void write_bci(int bci) { write_int(bci - InvocationEntryBci); }
duke@435 272 };

mercurial