equal
deleted
inserted
replaced
75 |
75 |
76 bool JfrStackTraceRepository::is_modified() const { |
76 bool JfrStackTraceRepository::is_modified() const { |
77 return last_id != _next_id; |
77 return last_id != _next_id; |
78 } |
78 } |
79 |
79 |
80 size_t JfrStackTraceRepository::write_impl(JfrChunkWriter& sw, bool clear) { |
80 size_t JfrStackTraceRepository::write(JfrChunkWriter& sw, bool clear) { |
|
81 if (_entries == 0) { |
|
82 return 0; |
|
83 } |
81 MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag); |
84 MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag); |
82 assert(_entries > 0, "invariant"); |
85 assert(_entries > 0, "invariant"); |
83 int count = 0; |
86 int count = 0; |
84 for (u4 i = 0; i < TABLE_SIZE; ++i) { |
87 for (u4 i = 0; i < TABLE_SIZE; ++i) { |
85 JfrStackTrace* stacktrace = _table[i]; |
88 JfrStackTrace* stacktrace = _table[i]; |
101 } |
104 } |
102 last_id = _next_id; |
105 last_id = _next_id; |
103 return count; |
106 return count; |
104 } |
107 } |
105 |
108 |
106 size_t JfrStackTraceRepository::write(JfrChunkWriter& sw, bool clear) { |
|
107 return _entries > 0 ? write_impl(sw, clear) : 0; |
|
108 } |
|
109 |
|
110 traceid JfrStackTraceRepository::write(JfrCheckpointWriter& writer, traceid id, unsigned int hash) { |
|
111 assert(JfrStacktrace_lock->owned_by_self(), "invariant"); |
|
112 const JfrStackTrace* const trace = lookup(hash, id); |
|
113 assert(trace != NULL, "invariant"); |
|
114 assert(trace->hash() == hash, "invariant"); |
|
115 assert(trace->id() == id, "invariant"); |
|
116 trace->write(writer); |
|
117 return id; |
|
118 } |
|
119 |
|
120 void JfrStackTraceRepository::write_metadata(JfrCheckpointWriter& writer) { |
|
121 JfrFrameType fct; |
|
122 writer.write_type(TYPE_FRAMETYPE); |
|
123 fct.serialize(writer); |
|
124 } |
|
125 |
|
126 size_t JfrStackTraceRepository::clear() { |
109 size_t JfrStackTraceRepository::clear() { |
127 MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag); |
110 MutexLocker lock(JfrStacktrace_lock, Mutex::_no_safepoint_check_flag); |
128 if (_entries == 0) { |
111 if (_entries == 0) { |
129 return 0; |
112 return 0; |
130 } |
113 } |
138 } |
121 } |
139 memset(_table, 0, sizeof(_table)); |
122 memset(_table, 0, sizeof(_table)); |
140 const size_t processed = _entries; |
123 const size_t processed = _entries; |
141 _entries = 0; |
124 _entries = 0; |
142 return processed; |
125 return processed; |
|
126 } |
|
127 |
143 traceid JfrStackTraceRepository::record(Thread* thread, int skip /* 0 */) { |
128 traceid JfrStackTraceRepository::record(Thread* thread, int skip /* 0 */) { |
144 assert(thread == Thread::current(), "invariant"); |
129 assert(thread == Thread::current(), "invariant"); |
145 JfrThreadLocal* const tl = thread->jfr_thread_local(); |
130 JfrThreadLocal* const tl = thread->jfr_thread_local(); |
146 assert(tl != NULL, "invariant"); |
131 assert(tl != NULL, "invariant"); |
147 if (tl->has_cached_stack_trace()) { |
132 if (tl->has_cached_stack_trace()) { |