56 JfrStackFrame(const traceid& id, int bci, int type, int lineno) : |
56 JfrStackFrame(const traceid& id, int bci, int type, int lineno) : |
57 _method(NULL), _methodid(id), _line(lineno), _bci(bci), _type(type) {} |
57 _method(NULL), _methodid(id), _line(lineno), _bci(bci), _type(type) {} |
58 bool equals(const JfrStackFrame& rhs) const; |
58 bool equals(const JfrStackFrame& rhs) const; |
59 void write(JfrChunkWriter& cw) const; |
59 void write(JfrChunkWriter& cw) const; |
60 void write(JfrCheckpointWriter& cpw) const; |
60 void write(JfrCheckpointWriter& cpw) const; |
61 void resolve_lineno(); |
61 void resolve_lineno() const; |
62 }; |
62 }; |
63 |
63 |
64 class JfrStackTrace : public StackObj { |
64 class JfrStackTrace : public StackObj { |
65 friend class JfrStackTraceRepository; |
65 friend class JfrStackTraceRepository; |
66 private: |
66 private: |
80 _max_frames(max_frames), |
80 _max_frames(max_frames), |
81 _reached_root(false), |
81 _reached_root(false), |
82 _lineno(false) {} |
82 _lineno(false) {} |
83 bool record_thread(JavaThread& thread, frame& frame); |
83 bool record_thread(JavaThread& thread, frame& frame); |
84 bool record_safe(JavaThread* thread, int skip, bool leakp = false); |
84 bool record_safe(JavaThread* thread, int skip, bool leakp = false); |
85 void resolve_linenos(); |
85 void resolve_linenos() const; |
86 void set_nr_of_frames(u4 nr_of_frames) { _nr_of_frames = nr_of_frames; } |
86 void set_nr_of_frames(u4 nr_of_frames) { _nr_of_frames = nr_of_frames; } |
87 void set_hash(unsigned int hash) { _hash = hash; } |
87 void set_hash(unsigned int hash) { _hash = hash; } |
|
88 unsigned int hash() const { return _hash; } |
88 void set_frame(u4 frame_pos, JfrStackFrame& frame); |
89 void set_frame(u4 frame_pos, JfrStackFrame& frame); |
89 void set_reached_root(bool reached_root) { _reached_root = reached_root; } |
90 void set_reached_root(bool reached_root) { _reached_root = reached_root; } |
90 bool full_stacktrace() const { return _reached_root; } |
91 bool full_stacktrace() const { return _reached_root; } |
91 bool have_lineno() const { return _lineno; } |
92 bool have_lineno() const { return _lineno; } |
92 }; |
93 }; |
126 static const u4 TABLE_SIZE = 2053; |
127 static const u4 TABLE_SIZE = 2053; |
127 StackTrace* _table[TABLE_SIZE]; |
128 StackTrace* _table[TABLE_SIZE]; |
128 traceid _next_id; |
129 traceid _next_id; |
129 u4 _entries; |
130 u4 _entries; |
130 |
131 |
|
132 traceid add_trace(const JfrStackTrace& stacktrace); |
|
133 static traceid add(const JfrStackTrace* stacktrace, JavaThread* thread); |
|
134 traceid record_for(JavaThread* thread, int skip, JfrStackFrame* frames, u4 max_frames); |
|
135 |
131 size_t write_impl(JfrChunkWriter& cw, bool clear); |
136 size_t write_impl(JfrChunkWriter& cw, bool clear); |
132 traceid record_for(JavaThread* thread, int skip, JfrStackFrame* frames, u4 max_frames); |
|
133 traceid record_for(JavaThread* thread, int skip, JfrStackFrame* frames, u4 max_frames, unsigned int* hash); |
|
134 traceid add_trace(const JfrStackTrace& stacktrace); |
|
135 const StackTrace* resolve_entry(unsigned int hash, traceid id) const; |
137 const StackTrace* resolve_entry(unsigned int hash, traceid id) const; |
136 |
|
137 static void write_metadata(JfrCheckpointWriter& cpw); |
138 static void write_metadata(JfrCheckpointWriter& cpw); |
138 |
139 |
|
140 static bool fill_stacktrace_for(JavaThread* thread, JfrStackTrace* stacktrace, int skip); |
|
141 |
139 JfrStackTraceRepository(); |
142 JfrStackTraceRepository(); |
140 static JfrStackTraceRepository& instance(); |
|
141 public: |
|
142 static JfrStackTraceRepository* create(); |
143 static JfrStackTraceRepository* create(); |
143 bool initialize(); |
144 bool initialize(); |
144 static void destroy(); |
145 static void destroy(); |
|
146 |
|
147 static JfrStackTraceRepository& instance(); |
|
148 |
|
149 public: |
145 static traceid add(const JfrStackTrace& stacktrace); |
150 static traceid add(const JfrStackTrace& stacktrace); |
146 static traceid record(Thread* thread, int skip = 0); |
151 static traceid record(Thread* thread, int skip = 0); |
147 static traceid record(Thread* thread, int skip, unsigned int* hash); |
|
148 traceid write(JfrCheckpointWriter& cpw, traceid id, unsigned int hash); |
152 traceid write(JfrCheckpointWriter& cpw, traceid id, unsigned int hash); |
149 size_t write(JfrChunkWriter& cw, bool clear); |
153 size_t write(JfrChunkWriter& cw, bool clear); |
150 size_t clear(); |
154 size_t clear(); |
151 }; |
155 }; |
152 |
156 |