src/share/vm/code/debugInfoRec.hpp

Wed, 02 Jun 2010 22:45:42 -0700

author
jrose
date
Wed, 02 Jun 2010 22:45:42 -0700
changeset 1934
e9ff18c4ace7
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

Merge

duke@435 1 /*
trims@1907 2 * Copyright (c) 1998, 2009, 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
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,
kvn@1688 92 bool return_oop = false,
duke@435 93 DebugToken* locals = NULL,
duke@435 94 DebugToken* expressions = NULL,
duke@435 95 DebugToken* monitors = NULL);
duke@435 96
duke@435 97
duke@435 98 void dump_object_pool(GrowableArray<ScopeValue*>* objects);
duke@435 99
duke@435 100 // This call must follow every add_safepoint,
duke@435 101 // after any intervening describe_scope calls.
duke@435 102 void end_safepoint(int pc_offset) { end_scopes(pc_offset, true); }
duke@435 103 void end_non_safepoint(int pc_offset) { end_scopes(pc_offset, false); }
duke@435 104
duke@435 105 // helper fuctions for describe_scope to enable sharing
duke@435 106 DebugToken* create_scope_values(GrowableArray<ScopeValue*>* values);
duke@435 107 DebugToken* create_monitor_values(GrowableArray<MonitorValue*>* monitors);
duke@435 108
duke@435 109 // returns the size of the generated scopeDescs.
duke@435 110 int data_size();
duke@435 111 int pcs_size();
duke@435 112 int oop_size() { return oop_recorder()->oop_size(); }
duke@435 113
duke@435 114 // copy the generated debugging information to nmethod
duke@435 115 void copy_to(nmethod* nm);
duke@435 116
duke@435 117 // verifies the debug information
duke@435 118 void verify(const nmethod* code);
duke@435 119
duke@435 120 static void print_statistics() PRODUCT_RETURN;
duke@435 121
duke@435 122 // Method for setting oopmaps to temporarily preserve old handling of oopmaps
duke@435 123 OopMapSet *_oopmaps;
duke@435 124 void set_oopmaps(OopMapSet *oopmaps) { _oopmaps = oopmaps; }
duke@435 125
duke@435 126 OopRecorder* oop_recorder() { return _oop_recorder; }
duke@435 127
duke@435 128 int last_pc_offset() { return last_pc()->pc_offset(); }
duke@435 129
duke@435 130 bool recording_non_safepoints() { return _recording_non_safepoints; }
duke@435 131
duke@435 132 private:
duke@435 133 friend class ScopeDesc;
duke@435 134 friend class vframeStreamCommon;
duke@435 135 friend class DIR_Chunk;
duke@435 136
duke@435 137 // True if we are recording non-safepoint scopes.
duke@435 138 // This flag is set if DebugNonSafepoints is true, or if
duke@435 139 // JVMTI post_compiled_method_load events are enabled.
duke@435 140 const bool _recording_non_safepoints;
duke@435 141
duke@435 142 DebugInfoWriteStream* _stream;
duke@435 143
duke@435 144 DebugInfoWriteStream* stream() const { return _stream; }
duke@435 145
duke@435 146 OopRecorder* _oop_recorder;
duke@435 147
duke@435 148 // Scopes that have been described so far.
duke@435 149 GrowableArray<DIR_Chunk*>* _all_chunks;
duke@435 150 GrowableArray<DIR_Chunk*>* _shared_chunks;
duke@435 151 DIR_Chunk* _next_chunk;
duke@435 152 DIR_Chunk* _next_chunk_limit;
duke@435 153
duke@435 154 #ifdef ASSERT
duke@435 155 enum { rs_null, rs_safepoint, rs_non_safepoint };
duke@435 156 int _recording_state;
duke@435 157 #endif
duke@435 158
duke@435 159 PcDesc* _pcs;
duke@435 160 int _pcs_size;
duke@435 161 int _pcs_length;
duke@435 162 // Note: Would use GrowableArray<PcDesc>, but structs are not supported.
duke@435 163
duke@435 164 // PC of most recent real safepoint before the current one,
duke@435 165 // updated after end_scopes.
duke@435 166 int _prev_safepoint_pc;
duke@435 167
duke@435 168 PcDesc* last_pc() {
duke@435 169 guarantee(_pcs_length > 0, "a safepoint must be declared already");
duke@435 170 return &_pcs[_pcs_length-1];
duke@435 171 }
duke@435 172 PcDesc* prev_pc() {
duke@435 173 guarantee(_pcs_length > 1, "a safepoint must be declared already");
duke@435 174 return &_pcs[_pcs_length-2];
duke@435 175 }
duke@435 176 void add_new_pc_offset(int pc_offset);
duke@435 177 void end_scopes(int pc_offset, bool is_safepoint);
duke@435 178
duke@435 179 int serialize_monitor_values(GrowableArray<MonitorValue*>* monitors);
duke@435 180 int serialize_scope_values(GrowableArray<ScopeValue*>* values);
duke@435 181 int find_sharable_decode_offset(int stream_offset);
duke@435 182
duke@435 183 public:
duke@435 184 enum { serialized_null = 0 };
duke@435 185 };

mercurial