@@ -764,9 +764,9 @@ u64 Profiler::recordJVMTISample(u64 counter, int tid, jthread thread, jint event
764764 atomicIncRelaxed (_total_samples);
765765
766766 u32 lock_index = getLockIndex (tid);
767- if (!_locks[lock_index].tryLock () &&
767+ if (unlikely ( !_locks[lock_index].tryLock () &&
768768 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
769- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
769+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
770770 // Too many concurrent signals already
771771 atomicIncRelaxed (_failures[-ticks_skipped]);
772772
@@ -811,9 +811,9 @@ void Profiler::recordDeferredSample(int tid, u64 call_trace_id, jint event_type,
811811 atomicIncRelaxed (_total_samples);
812812
813813 u32 lock_index = getLockIndex (tid);
814- if (!_locks[lock_index].tryLock () &&
814+ if (unlikely ( !_locks[lock_index].tryLock () &&
815815 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
816- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
816+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
817817 // Too many concurrent signals already
818818 atomicIncRelaxed (_failures[-ticks_skipped]);
819819 return ;
@@ -829,9 +829,9 @@ void Profiler::recordSample(void *ucontext, u64 counter, int tid,
829829 atomicIncRelaxed (_total_samples);
830830
831831 u32 lock_index = getLockIndex (tid);
832- if (!_locks[lock_index].tryLock () &&
832+ if (unlikely ( !_locks[lock_index].tryLock () &&
833833 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
834- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
834+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
835835 // Too many concurrent signals already
836836 atomicIncRelaxed (_failures[-ticks_skipped]);
837837
@@ -849,7 +849,7 @@ void Profiler::recordSample(void *ucontext, u64 counter, int tid,
849849 // record a null stacktrace we can skip the unwind if we've got a
850850 // call_trace_id determined to be reusable at a higher level
851851
852- if (!_omit_stacktraces && call_trace_id == 0 ) {
852+ if (likely ( !_omit_stacktraces && call_trace_id == 0 ) ) {
853853 u64 startTime = TSC::ticks ();
854854 ASGCT_CallFrame *frames = _calltrace_buffer[lock_index]->_asgct_frames ;
855855
@@ -859,7 +859,7 @@ void Profiler::recordSample(void *ucontext, u64 counter, int tid,
859859 ASGCT_CallFrame *native_stop = frames + num_frames;
860860 num_frames += getNativeTrace (ucontext, native_stop, event_type, tid,
861861 &java_ctx, &truncated, lock_index);
862- if (num_frames < _max_stack_depth) {
862+ if (likely ( num_frames < _max_stack_depth) ) {
863863 int max_remaining = _max_stack_depth - num_frames;
864864 if (_features.mixed ) {
865865 int vm_start = num_frames;
@@ -887,14 +887,14 @@ void Profiler::recordSample(void *ucontext, u64 counter, int tid,
887887 }
888888 }
889889 }
890- if (num_frames == 0 ) {
890+ if (unlikely ( num_frames == 0 ) ) {
891891 num_frames += makeFrame (frames + num_frames, BCI_ERROR , " no_Java_frame" );
892892 }
893893
894894 call_trace_id =
895895 _call_trace_storage.put (num_frames, frames, truncated, counter);
896896 ProfiledThread *thread = ProfiledThread::currentSignalSafe ();
897- if (thread != nullptr ) {
897+ if (likely ( thread != nullptr ) ) {
898898 thread->recordCallTraceId (call_trace_id);
899899 }
900900 u64 duration = TSC::ticks () - startTime;
@@ -909,9 +909,9 @@ void Profiler::recordSample(void *ucontext, u64 counter, int tid,
909909
910910void Profiler::recordWallClockEpoch (int tid, WallClockEpochEvent *event) {
911911 u32 lock_index = getLockIndex (tid);
912- if (!_locks[lock_index].tryLock () &&
912+ if (unlikely ( !_locks[lock_index].tryLock () &&
913913 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
914- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
914+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
915915 return ;
916916 }
917917 _jfr.wallClockEpoch (lock_index, event);
@@ -920,9 +920,9 @@ void Profiler::recordWallClockEpoch(int tid, WallClockEpochEvent *event) {
920920
921921void Profiler::recordTraceRoot (int tid, TraceRootEvent *event) {
922922 u32 lock_index = getLockIndex (tid);
923- if (!_locks[lock_index].tryLock () &&
923+ if (unlikely ( !_locks[lock_index].tryLock () &&
924924 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
925- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
925+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
926926 return ;
927927 }
928928 _jfr.recordTraceRoot (lock_index, tid, event);
@@ -931,9 +931,9 @@ void Profiler::recordTraceRoot(int tid, TraceRootEvent *event) {
931931
932932void Profiler::recordQueueTime (int tid, QueueTimeEvent *event) {
933933 u32 lock_index = getLockIndex (tid);
934- if (!_locks[lock_index].tryLock () &&
934+ if (unlikely ( !_locks[lock_index].tryLock () &&
935935 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
936- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
936+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
937937 return ;
938938 }
939939 _jfr.recordQueueTime (lock_index, tid, event);
@@ -957,9 +957,9 @@ void Profiler::recordExternalSample(u64 weight, int tid, int num_frames,
957957
958958 u64 call_trace_id =
959959 _call_trace_storage.put (num_frames, extended_frames, truncated, weight);
960- if (!_locks[lock_index].tryLock () &&
960+ if (unlikely ( !_locks[lock_index].tryLock () &&
961961 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
962- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
962+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
963963 // Too many concurrent signals already
964964 atomicIncRelaxed (_failures[-ticks_skipped]);
965965 return ;
@@ -982,9 +982,9 @@ void Profiler::writeDatadogProfilerSetting(int tid, int length,
982982 const char *name, const char *value,
983983 const char *unit) {
984984 u32 lock_index = getLockIndex (tid);
985- if (!_locks[lock_index].tryLock () &&
985+ if (unlikely ( !_locks[lock_index].tryLock () &&
986986 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
987- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
987+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
988988 return ;
989989 }
990990 _jfr.recordDatadogSetting (lock_index, length, name, value, unit);
@@ -997,9 +997,9 @@ void Profiler::writeHeapUsage(long value, bool live) {
997997 return ;
998998 }
999999 u32 lock_index = getLockIndex (tid);
1000- if (!_locks[lock_index].tryLock () &&
1000+ if (unlikely ( !_locks[lock_index].tryLock () &&
10011001 !_locks[lock_index = (lock_index + 1 ) % CONCURRENCY_LEVEL ].tryLock () &&
1002- !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ()) {
1002+ !_locks[lock_index = (lock_index + 2 ) % CONCURRENCY_LEVEL ].tryLock ())) {
10031003 return ;
10041004 }
10051005 _jfr.recordHeapUsage (lock_index, value, live);
0 commit comments