< prev index next >

src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp

Print this page

121 }
122 
123 template <typename Writer>
124 static void write_frame(Writer& w, traceid methodid, int line, int bci, u1 type) {
125   w.write((u8)methodid);
126   w.write((u4)line);
127   w.write((u4)bci);
128   w.write((u8)type);
129 }
130 
131 void JfrStackFrame::write(JfrChunkWriter& cw) const {
132   write_frame(cw, _methodid, _line, _bci, _type);
133 }
134 
135 void JfrStackFrame::write(JfrCheckpointWriter& cpw) const {
136   write_frame(cpw, _methodid, _line, _bci, _type);
137 }
138 
139 class JfrVframeStream : public vframeStreamCommon {
140  private:

141   const ContinuationEntry* _cont_entry;
142   bool _async_mode;
143   bool _vthread;
144   bool step_to_sender();
145   void next_frame();
146  public:
147   JfrVframeStream(JavaThread* jt, const frame& fr, bool stop_at_java_call_stub, bool async_mode);
148   void next_vframe();
149 };
150 
151 static RegisterMap::WalkContinuation walk_continuation(JavaThread* jt) {
152   // NOTE: WalkContinuation::skip, because of interactions with ZGC relocation
153   //       and load barriers. This code is run while generating stack traces for
154   //       the ZPage allocation event, even when ZGC is relocating  objects.
155   //       When ZGC is relocating, it is forbidden to run code that performs
156   //       load barriers. With WalkContinuation::include, we visit heap stack
157   //       chunks and could be using load barriers.
158   return (UseZGC && !StackWatermarkSet::processing_started(jt))
159       ? RegisterMap::WalkContinuation::skip
160       : RegisterMap::WalkContinuation::include;
161 }
162 
163 JfrVframeStream::JfrVframeStream(JavaThread* jt, const frame& fr, bool stop_at_java_call_stub, bool async_mode) :
164   vframeStreamCommon(RegisterMap(jt,
165                                  RegisterMap::UpdateMap::skip,
166                                  RegisterMap::ProcessFrames::skip,
167                                  walk_continuation(jt))),
168     _cont_entry(JfrThreadLocal::is_vthread(jt) ? jt->last_continuation() : nullptr),
169     _async_mode(async_mode), _vthread(JfrThreadLocal::is_vthread(jt)) {

170   assert(!_vthread || _cont_entry != nullptr, "invariant");
171   _reg_map.set_async(async_mode);
172   _frame = fr;
173   _stop_at_java_call_stub = stop_at_java_call_stub;
174   while (!fill_from_frame()) {
175     step_to_sender();
176   }
177 }
178 
179 inline bool JfrVframeStream::step_to_sender() {
180   if (_async_mode && !_frame.safe_for_sender(_thread)) {
181     _mode = at_end_mode;
182     return false;
183   }
184   _frame = _frame.sender(&_reg_map);
185   return true;
186 }
187 
188 inline void JfrVframeStream::next_frame() {
189   static constexpr const u4 loop_max = MAX_STACK_DEPTH * 2;

121 }
122 
123 template <typename Writer>
124 static void write_frame(Writer& w, traceid methodid, int line, int bci, u1 type) {
125   w.write((u8)methodid);
126   w.write((u4)line);
127   w.write((u4)bci);
128   w.write((u8)type);
129 }
130 
131 void JfrStackFrame::write(JfrChunkWriter& cw) const {
132   write_frame(cw, _methodid, _line, _bci, _type);
133 }
134 
135 void JfrStackFrame::write(JfrCheckpointWriter& cpw) const {
136   write_frame(cpw, _methodid, _line, _bci, _type);
137 }
138 
139 class JfrVframeStream : public vframeStreamCommon {
140  private:
141   bool _vthread;
142   const ContinuationEntry* _cont_entry;
143   bool _async_mode;

144   bool step_to_sender();
145   void next_frame();
146  public:
147   JfrVframeStream(JavaThread* jt, const frame& fr, bool stop_at_java_call_stub, bool async_mode);
148   void next_vframe();
149 };
150 
151 static RegisterMap::WalkContinuation walk_continuation(JavaThread* jt) {
152   // NOTE: WalkContinuation::skip, because of interactions with ZGC relocation
153   //       and load barriers. This code is run while generating stack traces for
154   //       the ZPage allocation event, even when ZGC is relocating  objects.
155   //       When ZGC is relocating, it is forbidden to run code that performs
156   //       load barriers. With WalkContinuation::include, we visit heap stack
157   //       chunks and could be using load barriers.
158   return (UseZGC && !StackWatermarkSet::processing_started(jt))
159       ? RegisterMap::WalkContinuation::skip
160       : RegisterMap::WalkContinuation::include;
161 }
162 
163 JfrVframeStream::JfrVframeStream(JavaThread* jt, const frame& fr, bool stop_at_java_call_stub, bool async_mode) :
164   vframeStreamCommon(RegisterMap(jt,
165                                  RegisterMap::UpdateMap::skip,
166                                  RegisterMap::ProcessFrames::skip,
167                                  walk_continuation(jt))),
168     _vthread(JfrThreadLocal::is_vthread(jt)),
169     _cont_entry(_vthread ? jt->last_continuation() : nullptr),
170     _async_mode(async_mode) {
171   assert(!_vthread || _cont_entry != nullptr, "invariant");
172   _reg_map.set_async(async_mode);
173   _frame = fr;
174   _stop_at_java_call_stub = stop_at_java_call_stub;
175   while (!fill_from_frame()) {
176     step_to_sender();
177   }
178 }
179 
180 inline bool JfrVframeStream::step_to_sender() {
181   if (_async_mode && !_frame.safe_for_sender(_thread)) {
182     _mode = at_end_mode;
183     return false;
184   }
185   _frame = _frame.sender(&_reg_map);
186   return true;
187 }
188 
189 inline void JfrVframeStream::next_frame() {
190   static constexpr const u4 loop_max = MAX_STACK_DEPTH * 2;
< prev index next >