Fri, 08 Nov 2013 01:13:11 -0800
8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie
Reviewed-by: kvn, iveresov
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_CODE_DEBUGINFO_HPP |
stefank@2314 | 26 | #define SHARE_VM_CODE_DEBUGINFO_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "code/compressedStream.hpp" |
stefank@2314 | 29 | #include "code/location.hpp" |
stefank@2314 | 30 | #include "code/nmethod.hpp" |
stefank@2314 | 31 | #include "code/oopRecorder.hpp" |
stefank@2314 | 32 | #include "runtime/stackValue.hpp" |
stefank@2314 | 33 | #include "utilities/growableArray.hpp" |
stefank@2314 | 34 | |
duke@435 | 35 | // Classes used for serializing debugging information. |
duke@435 | 36 | // These abstractions are introducted to provide symmetric |
duke@435 | 37 | // read and write operations. |
duke@435 | 38 | |
duke@435 | 39 | // ScopeValue describes the value of a variable/expression in a scope |
duke@435 | 40 | // - LocationValue describes a value in a given location (in frame or register) |
duke@435 | 41 | // - ConstantValue describes a constant |
duke@435 | 42 | |
coleenp@4037 | 43 | class ConstantOopReadValue; |
coleenp@4037 | 44 | |
duke@435 | 45 | class ScopeValue: public ResourceObj { |
duke@435 | 46 | public: |
duke@435 | 47 | // Testers |
duke@435 | 48 | virtual bool is_location() const { return false; } |
duke@435 | 49 | virtual bool is_object() const { return false; } |
duke@435 | 50 | virtual bool is_constant_int() const { return false; } |
duke@435 | 51 | virtual bool is_constant_double() const { return false; } |
duke@435 | 52 | virtual bool is_constant_long() const { return false; } |
duke@435 | 53 | virtual bool is_constant_oop() const { return false; } |
duke@435 | 54 | virtual bool equals(ScopeValue* other) const { return false; } |
duke@435 | 55 | |
coleenp@4037 | 56 | ConstantOopReadValue* as_ConstantOopReadValue() { |
coleenp@4037 | 57 | assert(is_constant_oop(), "must be"); |
coleenp@4037 | 58 | return (ConstantOopReadValue*) this; |
coleenp@4037 | 59 | } |
coleenp@4037 | 60 | |
duke@435 | 61 | // Serialization of debugging information |
duke@435 | 62 | virtual void write_on(DebugInfoWriteStream* stream) = 0; |
duke@435 | 63 | static ScopeValue* read_from(DebugInfoReadStream* stream); |
duke@435 | 64 | }; |
duke@435 | 65 | |
duke@435 | 66 | |
duke@435 | 67 | // A Location value describes a value in a given location; i.e. the corresponding |
duke@435 | 68 | // logical entity (e.g., a method temporary) lives in this location. |
duke@435 | 69 | |
duke@435 | 70 | class LocationValue: public ScopeValue { |
duke@435 | 71 | private: |
duke@435 | 72 | Location _location; |
duke@435 | 73 | public: |
duke@435 | 74 | LocationValue(Location location) { _location = location; } |
duke@435 | 75 | bool is_location() const { return true; } |
duke@435 | 76 | Location location() const { return _location; } |
duke@435 | 77 | |
duke@435 | 78 | // Serialization of debugging information |
duke@435 | 79 | LocationValue(DebugInfoReadStream* stream); |
duke@435 | 80 | void write_on(DebugInfoWriteStream* stream); |
duke@435 | 81 | |
duke@435 | 82 | // Printing |
duke@435 | 83 | void print_on(outputStream* st) const; |
duke@435 | 84 | }; |
duke@435 | 85 | |
duke@435 | 86 | |
duke@435 | 87 | // An ObjectValue describes an object eliminated by escape analysis. |
duke@435 | 88 | |
duke@435 | 89 | class ObjectValue: public ScopeValue { |
duke@435 | 90 | private: |
duke@435 | 91 | int _id; |
duke@435 | 92 | ScopeValue* _klass; |
duke@435 | 93 | GrowableArray<ScopeValue*> _field_values; |
duke@435 | 94 | Handle _value; |
duke@435 | 95 | bool _visited; |
duke@435 | 96 | |
duke@435 | 97 | public: |
duke@435 | 98 | ObjectValue(int id, ScopeValue* klass) |
duke@435 | 99 | : _id(id) |
duke@435 | 100 | , _klass(klass) |
duke@435 | 101 | , _field_values() |
duke@435 | 102 | , _value() |
duke@435 | 103 | , _visited(false) { |
coleenp@4037 | 104 | assert(klass->is_constant_oop(), "should be constant java mirror oop"); |
duke@435 | 105 | } |
duke@435 | 106 | |
duke@435 | 107 | ObjectValue(int id) |
duke@435 | 108 | : _id(id) |
duke@435 | 109 | , _klass(NULL) |
duke@435 | 110 | , _field_values() |
duke@435 | 111 | , _value() |
duke@435 | 112 | , _visited(false) {} |
duke@435 | 113 | |
duke@435 | 114 | // Accessors |
duke@435 | 115 | bool is_object() const { return true; } |
duke@435 | 116 | int id() const { return _id; } |
duke@435 | 117 | ScopeValue* klass() const { return _klass; } |
duke@435 | 118 | GrowableArray<ScopeValue*>* field_values() { return &_field_values; } |
duke@435 | 119 | ScopeValue* field_at(int i) const { return _field_values.at(i); } |
duke@435 | 120 | int field_size() { return _field_values.length(); } |
duke@435 | 121 | Handle value() const { return _value; } |
duke@435 | 122 | bool is_visited() const { return _visited; } |
duke@435 | 123 | |
duke@435 | 124 | void set_value(oop value) { _value = Handle(value); } |
duke@435 | 125 | void set_visited(bool visited) { _visited = false; } |
duke@435 | 126 | |
duke@435 | 127 | // Serialization of debugging information |
duke@435 | 128 | void read_object(DebugInfoReadStream* stream); |
duke@435 | 129 | void write_on(DebugInfoWriteStream* stream); |
duke@435 | 130 | |
duke@435 | 131 | // Printing |
duke@435 | 132 | void print_on(outputStream* st) const; |
duke@435 | 133 | void print_fields_on(outputStream* st) const; |
duke@435 | 134 | }; |
duke@435 | 135 | |
duke@435 | 136 | |
duke@435 | 137 | // A ConstantIntValue describes a constant int; i.e., the corresponding logical entity |
duke@435 | 138 | // is either a source constant or its computation has been constant-folded. |
duke@435 | 139 | |
duke@435 | 140 | class ConstantIntValue: public ScopeValue { |
duke@435 | 141 | private: |
duke@435 | 142 | jint _value; |
duke@435 | 143 | public: |
duke@435 | 144 | ConstantIntValue(jint value) { _value = value; } |
duke@435 | 145 | jint value() const { return _value; } |
duke@435 | 146 | bool is_constant_int() 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 | ConstantIntValue(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 ConstantLongValue: public ScopeValue { |
duke@435 | 158 | private: |
duke@435 | 159 | jlong _value; |
duke@435 | 160 | public: |
duke@435 | 161 | ConstantLongValue(jlong value) { _value = value; } |
duke@435 | 162 | jlong value() const { return _value; } |
duke@435 | 163 | bool is_constant_long() 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 | ConstantLongValue(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 | class ConstantDoubleValue: public ScopeValue { |
duke@435 | 175 | private: |
duke@435 | 176 | jdouble _value; |
duke@435 | 177 | public: |
duke@435 | 178 | ConstantDoubleValue(jdouble value) { _value = value; } |
duke@435 | 179 | jdouble value() const { return _value; } |
duke@435 | 180 | bool is_constant_double() const { return true; } |
duke@435 | 181 | bool equals(ScopeValue* other) const { return false; } |
duke@435 | 182 | |
duke@435 | 183 | // Serialization of debugging information |
duke@435 | 184 | ConstantDoubleValue(DebugInfoReadStream* stream); |
duke@435 | 185 | void write_on(DebugInfoWriteStream* stream); |
duke@435 | 186 | |
duke@435 | 187 | // Printing |
duke@435 | 188 | void print_on(outputStream* st) const; |
duke@435 | 189 | }; |
duke@435 | 190 | |
duke@435 | 191 | // A ConstantOopWriteValue is created by the compiler to |
duke@435 | 192 | // be written as debugging information. |
duke@435 | 193 | |
duke@435 | 194 | class ConstantOopWriteValue: public ScopeValue { |
duke@435 | 195 | private: |
duke@435 | 196 | jobject _value; |
duke@435 | 197 | public: |
duke@435 | 198 | ConstantOopWriteValue(jobject value) { _value = value; } |
duke@435 | 199 | jobject value() const { return _value; } |
duke@435 | 200 | bool is_constant_oop() const { return true; } |
duke@435 | 201 | bool equals(ScopeValue* other) const { return false; } |
duke@435 | 202 | |
duke@435 | 203 | // Serialization of debugging information |
duke@435 | 204 | void write_on(DebugInfoWriteStream* stream); |
duke@435 | 205 | |
duke@435 | 206 | // Printing |
duke@435 | 207 | void print_on(outputStream* st) const; |
duke@435 | 208 | }; |
duke@435 | 209 | |
duke@435 | 210 | // A ConstantOopReadValue is created by the VM when reading |
duke@435 | 211 | // debug information |
duke@435 | 212 | |
duke@435 | 213 | class ConstantOopReadValue: public ScopeValue { |
duke@435 | 214 | private: |
duke@435 | 215 | Handle _value; |
duke@435 | 216 | public: |
duke@435 | 217 | Handle value() const { return _value; } |
duke@435 | 218 | bool is_constant_oop() const { return true; } |
duke@435 | 219 | bool equals(ScopeValue* other) const { return false; } |
duke@435 | 220 | |
duke@435 | 221 | // Serialization of debugging information |
duke@435 | 222 | ConstantOopReadValue(DebugInfoReadStream* stream); |
duke@435 | 223 | void write_on(DebugInfoWriteStream* stream); |
duke@435 | 224 | |
duke@435 | 225 | // Printing |
duke@435 | 226 | void print_on(outputStream* st) const; |
duke@435 | 227 | }; |
duke@435 | 228 | |
duke@435 | 229 | // MonitorValue describes the pair used for monitor_enter and monitor_exit. |
duke@435 | 230 | |
duke@435 | 231 | class MonitorValue: public ResourceObj { |
duke@435 | 232 | private: |
duke@435 | 233 | ScopeValue* _owner; |
duke@435 | 234 | Location _basic_lock; |
duke@435 | 235 | bool _eliminated; |
duke@435 | 236 | public: |
duke@435 | 237 | // Constructor |
duke@435 | 238 | MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false); |
duke@435 | 239 | |
duke@435 | 240 | // Accessors |
duke@435 | 241 | ScopeValue* owner() const { return _owner; } |
duke@435 | 242 | Location basic_lock() const { return _basic_lock; } |
duke@435 | 243 | bool eliminated() const { return _eliminated; } |
duke@435 | 244 | |
duke@435 | 245 | // Serialization of debugging information |
duke@435 | 246 | MonitorValue(DebugInfoReadStream* stream); |
duke@435 | 247 | void write_on(DebugInfoWriteStream* stream); |
duke@435 | 248 | |
duke@435 | 249 | // Printing |
duke@435 | 250 | void print_on(outputStream* st) const; |
duke@435 | 251 | }; |
duke@435 | 252 | |
duke@435 | 253 | // DebugInfoReadStream specializes CompressedReadStream for reading |
duke@435 | 254 | // debugging information. Used by ScopeDesc. |
duke@435 | 255 | |
duke@435 | 256 | class DebugInfoReadStream : public CompressedReadStream { |
duke@435 | 257 | private: |
duke@435 | 258 | const nmethod* _code; |
duke@435 | 259 | const nmethod* code() const { return _code; } |
duke@435 | 260 | GrowableArray<ScopeValue*>* _obj_pool; |
duke@435 | 261 | public: |
duke@435 | 262 | DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) : |
duke@435 | 263 | CompressedReadStream(code->scopes_data_begin(), offset) { |
duke@435 | 264 | _code = code; |
duke@435 | 265 | _obj_pool = obj_pool; |
duke@435 | 266 | |
duke@435 | 267 | } ; |
duke@435 | 268 | |
duke@435 | 269 | oop read_oop() { |
coleenp@4037 | 270 | oop o = code()->oop_at(read_int()); |
coleenp@4037 | 271 | assert(o == NULL || o->is_oop(), "oop only"); |
coleenp@4037 | 272 | return o; |
coleenp@4037 | 273 | } |
coleenp@4037 | 274 | Method* read_method() { |
coleenp@4037 | 275 | Method* o = (Method*)(code()->metadata_at(read_int())); |
coleenp@4037 | 276 | assert(o == NULL || |
coleenp@5307 | 277 | o->is_metaspace_object(), "meta data only"); |
coleenp@4037 | 278 | return o; |
duke@435 | 279 | } |
duke@435 | 280 | ScopeValue* read_object_value(); |
duke@435 | 281 | ScopeValue* get_cached_object(); |
duke@435 | 282 | // BCI encoding is mostly unsigned, but -1 is a distinguished value |
cfang@1366 | 283 | int read_bci() { return read_int() + InvocationEntryBci; } |
duke@435 | 284 | }; |
duke@435 | 285 | |
duke@435 | 286 | // DebugInfoWriteStream specializes CompressedWriteStream for |
duke@435 | 287 | // writing debugging information. Used by ScopeDescRecorder. |
duke@435 | 288 | |
duke@435 | 289 | class DebugInfoWriteStream : public CompressedWriteStream { |
duke@435 | 290 | private: |
duke@435 | 291 | DebugInformationRecorder* _recorder; |
duke@435 | 292 | DebugInformationRecorder* recorder() const { return _recorder; } |
duke@435 | 293 | public: |
duke@435 | 294 | DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size); |
duke@435 | 295 | void write_handle(jobject h); |
cfang@1366 | 296 | void write_bci(int bci) { write_int(bci - InvocationEntryBci); } |
coleenp@4037 | 297 | |
coleenp@4037 | 298 | void write_metadata(Metadata* m); |
duke@435 | 299 | }; |
stefank@2314 | 300 | |
stefank@2314 | 301 | #endif // SHARE_VM_CODE_DEBUGINFO_HPP |