1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/code/debugInfo.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,272 @@ 1.4 +/* 1.5 + * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// Classes used for serializing debugging information. 1.29 +// These abstractions are introducted to provide symmetric 1.30 +// read and write operations. 1.31 + 1.32 +// ScopeValue describes the value of a variable/expression in a scope 1.33 +// - LocationValue describes a value in a given location (in frame or register) 1.34 +// - ConstantValue describes a constant 1.35 + 1.36 +class ScopeValue: public ResourceObj { 1.37 + public: 1.38 + // Testers 1.39 + virtual bool is_location() const { return false; } 1.40 + virtual bool is_object() const { return false; } 1.41 + virtual bool is_constant_int() const { return false; } 1.42 + virtual bool is_constant_double() const { return false; } 1.43 + virtual bool is_constant_long() const { return false; } 1.44 + virtual bool is_constant_oop() const { return false; } 1.45 + virtual bool equals(ScopeValue* other) const { return false; } 1.46 + 1.47 + // Serialization of debugging information 1.48 + virtual void write_on(DebugInfoWriteStream* stream) = 0; 1.49 + static ScopeValue* read_from(DebugInfoReadStream* stream); 1.50 +}; 1.51 + 1.52 + 1.53 +// A Location value describes a value in a given location; i.e. the corresponding 1.54 +// logical entity (e.g., a method temporary) lives in this location. 1.55 + 1.56 +class LocationValue: public ScopeValue { 1.57 + private: 1.58 + Location _location; 1.59 + public: 1.60 + LocationValue(Location location) { _location = location; } 1.61 + bool is_location() const { return true; } 1.62 + Location location() const { return _location; } 1.63 + 1.64 + // Serialization of debugging information 1.65 + LocationValue(DebugInfoReadStream* stream); 1.66 + void write_on(DebugInfoWriteStream* stream); 1.67 + 1.68 + // Printing 1.69 + void print_on(outputStream* st) const; 1.70 +}; 1.71 + 1.72 + 1.73 +// An ObjectValue describes an object eliminated by escape analysis. 1.74 + 1.75 +class ObjectValue: public ScopeValue { 1.76 + private: 1.77 + int _id; 1.78 + ScopeValue* _klass; 1.79 + GrowableArray<ScopeValue*> _field_values; 1.80 + Handle _value; 1.81 + bool _visited; 1.82 + 1.83 + public: 1.84 + ObjectValue(int id, ScopeValue* klass) 1.85 + : _id(id) 1.86 + , _klass(klass) 1.87 + , _field_values() 1.88 + , _value() 1.89 + , _visited(false) { 1.90 + assert(klass->is_constant_oop(), "should be constant klass oop"); 1.91 + } 1.92 + 1.93 + ObjectValue(int id) 1.94 + : _id(id) 1.95 + , _klass(NULL) 1.96 + , _field_values() 1.97 + , _value() 1.98 + , _visited(false) {} 1.99 + 1.100 + // Accessors 1.101 + bool is_object() const { return true; } 1.102 + int id() const { return _id; } 1.103 + ScopeValue* klass() const { return _klass; } 1.104 + GrowableArray<ScopeValue*>* field_values() { return &_field_values; } 1.105 + ScopeValue* field_at(int i) const { return _field_values.at(i); } 1.106 + int field_size() { return _field_values.length(); } 1.107 + Handle value() const { return _value; } 1.108 + bool is_visited() const { return _visited; } 1.109 + 1.110 + void set_value(oop value) { _value = Handle(value); } 1.111 + void set_visited(bool visited) { _visited = false; } 1.112 + 1.113 + // Serialization of debugging information 1.114 + void read_object(DebugInfoReadStream* stream); 1.115 + void write_on(DebugInfoWriteStream* stream); 1.116 + 1.117 + // Printing 1.118 + void print_on(outputStream* st) const; 1.119 + void print_fields_on(outputStream* st) const; 1.120 +}; 1.121 + 1.122 + 1.123 +// A ConstantIntValue describes a constant int; i.e., the corresponding logical entity 1.124 +// is either a source constant or its computation has been constant-folded. 1.125 + 1.126 +class ConstantIntValue: public ScopeValue { 1.127 + private: 1.128 + jint _value; 1.129 + public: 1.130 + ConstantIntValue(jint value) { _value = value; } 1.131 + jint value() const { return _value; } 1.132 + bool is_constant_int() const { return true; } 1.133 + bool equals(ScopeValue* other) const { return false; } 1.134 + 1.135 + // Serialization of debugging information 1.136 + ConstantIntValue(DebugInfoReadStream* stream); 1.137 + void write_on(DebugInfoWriteStream* stream); 1.138 + 1.139 + // Printing 1.140 + void print_on(outputStream* st) const; 1.141 +}; 1.142 + 1.143 +class ConstantLongValue: public ScopeValue { 1.144 + private: 1.145 + jlong _value; 1.146 + public: 1.147 + ConstantLongValue(jlong value) { _value = value; } 1.148 + jlong value() const { return _value; } 1.149 + bool is_constant_long() const { return true; } 1.150 + bool equals(ScopeValue* other) const { return false; } 1.151 + 1.152 + // Serialization of debugging information 1.153 + ConstantLongValue(DebugInfoReadStream* stream); 1.154 + void write_on(DebugInfoWriteStream* stream); 1.155 + 1.156 + // Printing 1.157 + void print_on(outputStream* st) const; 1.158 +}; 1.159 + 1.160 +class ConstantDoubleValue: public ScopeValue { 1.161 + private: 1.162 + jdouble _value; 1.163 + public: 1.164 + ConstantDoubleValue(jdouble value) { _value = value; } 1.165 + jdouble value() const { return _value; } 1.166 + bool is_constant_double() const { return true; } 1.167 + bool equals(ScopeValue* other) const { return false; } 1.168 + 1.169 + // Serialization of debugging information 1.170 + ConstantDoubleValue(DebugInfoReadStream* stream); 1.171 + void write_on(DebugInfoWriteStream* stream); 1.172 + 1.173 + // Printing 1.174 + void print_on(outputStream* st) const; 1.175 +}; 1.176 + 1.177 +// A ConstantOopWriteValue is created by the compiler to 1.178 +// be written as debugging information. 1.179 + 1.180 +class ConstantOopWriteValue: public ScopeValue { 1.181 + private: 1.182 + jobject _value; 1.183 + public: 1.184 + ConstantOopWriteValue(jobject value) { _value = value; } 1.185 + jobject value() const { return _value; } 1.186 + bool is_constant_oop() const { return true; } 1.187 + bool equals(ScopeValue* other) const { return false; } 1.188 + 1.189 + // Serialization of debugging information 1.190 + void write_on(DebugInfoWriteStream* stream); 1.191 + 1.192 + // Printing 1.193 + void print_on(outputStream* st) const; 1.194 +}; 1.195 + 1.196 +// A ConstantOopReadValue is created by the VM when reading 1.197 +// debug information 1.198 + 1.199 +class ConstantOopReadValue: public ScopeValue { 1.200 + private: 1.201 + Handle _value; 1.202 + public: 1.203 + Handle value() const { return _value; } 1.204 + bool is_constant_oop() const { return true; } 1.205 + bool equals(ScopeValue* other) const { return false; } 1.206 + 1.207 + // Serialization of debugging information 1.208 + ConstantOopReadValue(DebugInfoReadStream* stream); 1.209 + void write_on(DebugInfoWriteStream* stream); 1.210 + 1.211 + // Printing 1.212 + void print_on(outputStream* st) const; 1.213 +}; 1.214 + 1.215 +// MonitorValue describes the pair used for monitor_enter and monitor_exit. 1.216 + 1.217 +class MonitorValue: public ResourceObj { 1.218 + private: 1.219 + ScopeValue* _owner; 1.220 + Location _basic_lock; 1.221 + bool _eliminated; 1.222 + public: 1.223 + // Constructor 1.224 + MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false); 1.225 + 1.226 + // Accessors 1.227 + ScopeValue* owner() const { return _owner; } 1.228 + Location basic_lock() const { return _basic_lock; } 1.229 + bool eliminated() const { return _eliminated; } 1.230 + 1.231 + // Serialization of debugging information 1.232 + MonitorValue(DebugInfoReadStream* stream); 1.233 + void write_on(DebugInfoWriteStream* stream); 1.234 + 1.235 + // Printing 1.236 + void print_on(outputStream* st) const; 1.237 +}; 1.238 + 1.239 +// DebugInfoReadStream specializes CompressedReadStream for reading 1.240 +// debugging information. Used by ScopeDesc. 1.241 + 1.242 +class DebugInfoReadStream : public CompressedReadStream { 1.243 + private: 1.244 + const nmethod* _code; 1.245 + const nmethod* code() const { return _code; } 1.246 + GrowableArray<ScopeValue*>* _obj_pool; 1.247 + public: 1.248 + DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) : 1.249 + CompressedReadStream(code->scopes_data_begin(), offset) { 1.250 + _code = code; 1.251 + _obj_pool = obj_pool; 1.252 + 1.253 + } ; 1.254 + 1.255 + oop read_oop() { 1.256 + return code()->oop_at(read_int()); 1.257 + } 1.258 + ScopeValue* read_object_value(); 1.259 + ScopeValue* get_cached_object(); 1.260 + // BCI encoding is mostly unsigned, but -1 is a distinguished value 1.261 + int read_bci() { return read_int() + InvocationEntryBci; } 1.262 +}; 1.263 + 1.264 +// DebugInfoWriteStream specializes CompressedWriteStream for 1.265 +// writing debugging information. Used by ScopeDescRecorder. 1.266 + 1.267 +class DebugInfoWriteStream : public CompressedWriteStream { 1.268 + private: 1.269 + DebugInformationRecorder* _recorder; 1.270 + DebugInformationRecorder* recorder() const { return _recorder; } 1.271 + public: 1.272 + DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size); 1.273 + void write_handle(jobject h); 1.274 + void write_bci(int bci) { write_int(bci - InvocationEntryBci); } 1.275 +};