Tue, 05 Jan 2010 16:12:26 -0800
6914002: unsigned compare problem after 5057818
Reviewed-by: kvn, twisti
duke@435 | 1 | /* |
xdono@1383 | 2 | * Copyright 1998-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 | //** The DebugInformationRecorder collects debugging information |
duke@435 | 26 | // for a compiled method. |
duke@435 | 27 | // Debugging information is used for: |
duke@435 | 28 | // - garbage collecting compiled frames |
duke@435 | 29 | // - stack tracing across compiled frames |
duke@435 | 30 | // - deoptimizating compiled frames |
duke@435 | 31 | // |
duke@435 | 32 | // The implementation requires the compiler to use the recorder |
duke@435 | 33 | // in the following order: |
duke@435 | 34 | // 1) Describe debug information for safepoints at increasing addresses. |
duke@435 | 35 | // a) Add safepoint entry (use add_safepoint or add_non_safepoint) |
duke@435 | 36 | // b) Describe scopes for that safepoint |
duke@435 | 37 | // - create locals if needed (use create_scope_values) |
duke@435 | 38 | // - create expressions if needed (use create_scope_values) |
duke@435 | 39 | // - create monitor stack if needed (use create_monitor_values) |
duke@435 | 40 | // - describe scope (use describe_scope) |
duke@435 | 41 | // "repeat last four steps for all scopes" |
duke@435 | 42 | // "outer most scope first and inner most scope last" |
duke@435 | 43 | // NB: nodes from create_scope_values and create_locations |
duke@435 | 44 | // can be reused for simple sharing. |
duke@435 | 45 | // - mark the end of the scopes (end_safepoint or end_non_safepoint) |
duke@435 | 46 | // 2) Use oop_size, data_size, pcs_size to create the nmethod and |
duke@435 | 47 | // finally migrate the debugging information into the nmethod |
duke@435 | 48 | // by calling copy_to. |
duke@435 | 49 | |
duke@435 | 50 | class DebugToken; // Opaque datatype for stored: |
duke@435 | 51 | // - GrowableArray<ScopeValue*> |
duke@435 | 52 | // - GrowableArray<MonitorValue*> |
duke@435 | 53 | |
duke@435 | 54 | // Alias for InvocationEntryBci. |
duke@435 | 55 | // Both constants are used for a pseudo-BCI which refers |
duke@435 | 56 | // to the state just _before_ a method is entered. |
duke@435 | 57 | // SynchronizationEntryBCI is used where the emphasis |
duke@435 | 58 | // is on the implicit monitorenter of a synchronized method. |
duke@435 | 59 | const int SynchronizationEntryBCI = InvocationEntryBci; |
duke@435 | 60 | |
duke@435 | 61 | class DIR_Chunk; // private class, a nugget of collected information |
duke@435 | 62 | |
duke@435 | 63 | class DebugInformationRecorder: public ResourceObj { |
duke@435 | 64 | public: |
duke@435 | 65 | // constructor |
duke@435 | 66 | DebugInformationRecorder(OopRecorder* oop_recorder); |
duke@435 | 67 | |
duke@435 | 68 | // adds an oopmap at a specific offset |
duke@435 | 69 | void add_oopmap(int pc_offset, OopMap* map); |
duke@435 | 70 | |
duke@435 | 71 | // adds a jvm mapping at pc-offset, for a safepoint only |
duke@435 | 72 | void add_safepoint(int pc_offset, OopMap* map); |
duke@435 | 73 | |
duke@435 | 74 | // adds a jvm mapping at pc-offset, for a non-safepoint (profile point) |
duke@435 | 75 | void add_non_safepoint(int pc_offset); |
duke@435 | 76 | |
duke@435 | 77 | // Describes debugging information for a scope at the given pc_offset. |
duke@435 | 78 | // Calls must be in non-decreasing order of pc_offset. |
duke@435 | 79 | // If there are several calls at a single pc_offset, |
duke@435 | 80 | // then they occur in the same order as they were performed by the JVM, |
duke@435 | 81 | // with the most recent (innermost) call being described last. |
duke@435 | 82 | // For a safepoint, the pc_offset must have been mentioned |
duke@435 | 83 | // previously by add_safepoint. |
duke@435 | 84 | // Otherwise, the pc_offset must have been mentioned previously |
duke@435 | 85 | // by add_non_safepoint, and the locals, expressions, and monitors |
duke@435 | 86 | // must all be null. |
duke@435 | 87 | void describe_scope(int pc_offset, |
duke@435 | 88 | ciMethod* method, |
duke@435 | 89 | int bci, |
cfang@1335 | 90 | bool reexecute, |
twisti@1570 | 91 | bool is_method_handle_invoke = false, |
duke@435 | 92 | DebugToken* locals = NULL, |
duke@435 | 93 | DebugToken* expressions = NULL, |
duke@435 | 94 | DebugToken* monitors = NULL); |
duke@435 | 95 | |
duke@435 | 96 | |
duke@435 | 97 | void dump_object_pool(GrowableArray<ScopeValue*>* objects); |
duke@435 | 98 | |
duke@435 | 99 | // This call must follow every add_safepoint, |
duke@435 | 100 | // after any intervening describe_scope calls. |
duke@435 | 101 | void end_safepoint(int pc_offset) { end_scopes(pc_offset, true); } |
duke@435 | 102 | void end_non_safepoint(int pc_offset) { end_scopes(pc_offset, false); } |
duke@435 | 103 | |
duke@435 | 104 | // helper fuctions for describe_scope to enable sharing |
duke@435 | 105 | DebugToken* create_scope_values(GrowableArray<ScopeValue*>* values); |
duke@435 | 106 | DebugToken* create_monitor_values(GrowableArray<MonitorValue*>* monitors); |
duke@435 | 107 | |
duke@435 | 108 | // returns the size of the generated scopeDescs. |
duke@435 | 109 | int data_size(); |
duke@435 | 110 | int pcs_size(); |
duke@435 | 111 | int oop_size() { return oop_recorder()->oop_size(); } |
duke@435 | 112 | |
duke@435 | 113 | // copy the generated debugging information to nmethod |
duke@435 | 114 | void copy_to(nmethod* nm); |
duke@435 | 115 | |
duke@435 | 116 | // verifies the debug information |
duke@435 | 117 | void verify(const nmethod* code); |
duke@435 | 118 | |
duke@435 | 119 | static void print_statistics() PRODUCT_RETURN; |
duke@435 | 120 | |
duke@435 | 121 | // Method for setting oopmaps to temporarily preserve old handling of oopmaps |
duke@435 | 122 | OopMapSet *_oopmaps; |
duke@435 | 123 | void set_oopmaps(OopMapSet *oopmaps) { _oopmaps = oopmaps; } |
duke@435 | 124 | |
duke@435 | 125 | OopRecorder* oop_recorder() { return _oop_recorder; } |
duke@435 | 126 | |
duke@435 | 127 | int last_pc_offset() { return last_pc()->pc_offset(); } |
duke@435 | 128 | |
duke@435 | 129 | bool recording_non_safepoints() { return _recording_non_safepoints; } |
duke@435 | 130 | |
duke@435 | 131 | private: |
duke@435 | 132 | friend class ScopeDesc; |
duke@435 | 133 | friend class vframeStreamCommon; |
duke@435 | 134 | friend class DIR_Chunk; |
duke@435 | 135 | |
duke@435 | 136 | // True if we are recording non-safepoint scopes. |
duke@435 | 137 | // This flag is set if DebugNonSafepoints is true, or if |
duke@435 | 138 | // JVMTI post_compiled_method_load events are enabled. |
duke@435 | 139 | const bool _recording_non_safepoints; |
duke@435 | 140 | |
duke@435 | 141 | DebugInfoWriteStream* _stream; |
duke@435 | 142 | |
duke@435 | 143 | DebugInfoWriteStream* stream() const { return _stream; } |
duke@435 | 144 | |
duke@435 | 145 | OopRecorder* _oop_recorder; |
duke@435 | 146 | |
duke@435 | 147 | // Scopes that have been described so far. |
duke@435 | 148 | GrowableArray<DIR_Chunk*>* _all_chunks; |
duke@435 | 149 | GrowableArray<DIR_Chunk*>* _shared_chunks; |
duke@435 | 150 | DIR_Chunk* _next_chunk; |
duke@435 | 151 | DIR_Chunk* _next_chunk_limit; |
duke@435 | 152 | |
duke@435 | 153 | #ifdef ASSERT |
duke@435 | 154 | enum { rs_null, rs_safepoint, rs_non_safepoint }; |
duke@435 | 155 | int _recording_state; |
duke@435 | 156 | #endif |
duke@435 | 157 | |
duke@435 | 158 | PcDesc* _pcs; |
duke@435 | 159 | int _pcs_size; |
duke@435 | 160 | int _pcs_length; |
duke@435 | 161 | // Note: Would use GrowableArray<PcDesc>, but structs are not supported. |
duke@435 | 162 | |
duke@435 | 163 | // PC of most recent real safepoint before the current one, |
duke@435 | 164 | // updated after end_scopes. |
duke@435 | 165 | int _prev_safepoint_pc; |
duke@435 | 166 | |
duke@435 | 167 | PcDesc* last_pc() { |
duke@435 | 168 | guarantee(_pcs_length > 0, "a safepoint must be declared already"); |
duke@435 | 169 | return &_pcs[_pcs_length-1]; |
duke@435 | 170 | } |
duke@435 | 171 | PcDesc* prev_pc() { |
duke@435 | 172 | guarantee(_pcs_length > 1, "a safepoint must be declared already"); |
duke@435 | 173 | return &_pcs[_pcs_length-2]; |
duke@435 | 174 | } |
duke@435 | 175 | void add_new_pc_offset(int pc_offset); |
duke@435 | 176 | void end_scopes(int pc_offset, bool is_safepoint); |
duke@435 | 177 | |
duke@435 | 178 | int serialize_monitor_values(GrowableArray<MonitorValue*>* monitors); |
duke@435 | 179 | int serialize_scope_values(GrowableArray<ScopeValue*>* values); |
duke@435 | 180 | int find_sharable_decode_offset(int stream_offset); |
duke@435 | 181 | |
duke@435 | 182 | public: |
duke@435 | 183 | enum { serialized_null = 0 }; |
duke@435 | 184 | }; |