src/share/vm/code/debugInfoRec.hpp

Fri, 28 Sep 2012 10:16:29 -0700

author
kvn
date
Fri, 28 Sep 2012 10:16:29 -0700
changeset 4117
f2e12eb74117
parent 4037
da91efe96a93
child 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

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

mercurial