Skip to content

Commit 5052e90

Browse files
committed
recent review updates
1 parent 88e217d commit 5052e90

3 files changed

Lines changed: 57 additions & 59 deletions

File tree

runtime/compiler/control/CompilationThread.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,14 @@ void TR::CompilationInfo::freeAllResources()
861861

862862
PORT_ACCESS_FROM_JITCONFIG(_jitConfig);
863863
for (int i = 0; i < J9_LONGEST_SYNC_COMP; i++) {
864-
if (_syncCompStats.longestWaitMethods[i].method != NULL) {
865-
j9mem_free_memory(_syncCompStats.longestWaitMethods[i].method);
866-
_syncCompStats.longestWaitMethods[i].method = NULL;
864+
J9JITLongestSyncComp &longestWaitMethod = _syncCompStats.longestWaitMethods[i];
865+
if (longestWaitMethod.method != NULL) {
866+
j9mem_free_memory(longestWaitMethod.method);
867+
longestWaitMethod.method = NULL;
867868
}
868-
if (_syncCompStats.longestWaitMethods[i].thread != NULL) {
869-
j9mem_free_memory(_syncCompStats.longestWaitMethods[i].thread);
870-
_syncCompStats.longestWaitMethods[i].thread = NULL;
869+
if (longestWaitMethod.thread != NULL) {
870+
j9mem_free_memory(longestWaitMethod.thread);
871+
longestWaitMethod.thread = NULL;
871872
}
872873
}
873874
}
@@ -6305,7 +6306,7 @@ void *TR::CompilationInfo::compileOnSeparateThread(J9VMThread *vmThread, TR::IlG
63056306
_syncCompStats.totalCount++;
63066307
_syncCompStats.totalWaitTime += duration;
63076308

6308-
/* Obtain index to insert */
6309+
/* Obtain index to insert. */
63096310
int idx = -1;
63106311
for (int i = 0; i < J9_LONGEST_SYNC_COMP; i++) {
63116312
if (_syncCompStats.longestWaitMethods[i].waitTime < duration) {
@@ -6314,14 +6315,14 @@ void *TR::CompilationInfo::compileOnSeparateThread(J9VMThread *vmThread, TR::IlG
63146315
}
63156316
}
63166317

6317-
if (idx >= 0) {
6318-
/* Remove the shortest wait-time */
6318+
if (0 <= idx) {
6319+
/* Remove the shortest wait-time. */
63196320
J9JITLongestSyncComp &lastMethod = _syncCompStats.longestWaitMethods[J9_LONGEST_SYNC_COMP - 1];
6320-
if (lastMethod.method != NULL) {
6321+
if (NULL != lastMethod.method) {
63216322
j9mem_free_memory(lastMethod.method);
63226323
lastMethod.method = NULL;
63236324
}
6324-
if (lastMethod.thread != NULL) {
6325+
if (NULL != lastMethod.thread) {
63256326
j9mem_free_memory(lastMethod.thread);
63266327
lastMethod.thread = NULL;
63276328
}
@@ -6339,18 +6340,18 @@ void *TR::CompilationInfo::compileOnSeparateThread(J9VMThread *vmThread, TR::IlG
63396340

63406341
uint32_t totalLen = J9UTF8_LENGTH(className) + J9UTF8_LENGTH(name) + J9UTF8_LENGTH(signature) + 2;
63416342
char *templongestWaitMethod = (char *)j9mem_allocate_memory(totalLen, J9MEM_CATEGORY_JIT);
6342-
if (templongestWaitMethod != NULL) {
6343-
snprintf(templongestWaitMethod, totalLen, "%.*s.%.*s%.*s", J9UTF8_LENGTH(className),
6343+
if (NULL != templongestWaitMethod) {
6344+
j9str_printf(templongestWaitMethod, totalLen, "%.*s.%.*s%.*s", J9UTF8_LENGTH(className),
63446345
J9UTF8_DATA(className), J9UTF8_LENGTH(name), J9UTF8_DATA(name), J9UTF8_LENGTH(signature),
63456346
J9UTF8_DATA(signature));
63466347
}
63476348
_syncCompStats.longestWaitMethods[idx].method = templongestWaitMethod;
63486349

6349-
char *threadName = getOMRVMThreadName(vmThread->omrVMThread);
6350-
uint32_t len = strlen(threadName) + 1;
6351-
char *tempThread = (char *)j9mem_allocate_memory(len, J9MEM_CATEGORY_JIT);
6352-
if (tempThread != NULL) {
6353-
memcpy(tempThread, threadName, len);
6350+
const char *threadName = getOMRVMThreadName(vmThread->omrVMThread);
6351+
uint32_t len = strlen(threadName);
6352+
char *tempThread = (char *)j9mem_allocate_memory(len + 1, J9MEM_CATEGORY_JIT);
6353+
if (NULL != tempThread) {
6354+
memcpy(tempThread, threadName, len + 1);
63546355
}
63556356
_syncCompStats.longestWaitMethods[idx].thread = tempThread;
63566357
releaseOMRVMThreadName(vmThread->omrVMThread);

runtime/oti/j9nonbuilder.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
#define J9_CATCHTYPE_VALUE_FOR_SYNTHETIC_HANDLER_4BYTES 0xFFFFFFFF
298298
#define J9_CATCHTYPE_VALUE_FOR_SYNTHETIC_HANDLER_2BYTES 0xFFFF
299299

300-
/* Constant for information regarding longest synchronous compilations */
300+
/* Constant for information regarding longest synchronous compilations. */
301301
#define J9_LONGEST_SYNC_COMP 3
302302

303303
#if JAVA_SPEC_VERSION >= 19
@@ -4380,20 +4380,16 @@ typedef struct J9ClassCastParms {
43804380
} J9ClassCastParms;
43814381

43824382
typedef struct J9JITLongestSyncComp {
4383-
/* microseconds (us) */
4384-
uint64_t waitTime;
4385-
/* absolute timestamp */
4386-
uint64_t waitTimeEnd;
4387-
char* method;
4388-
char* thread;
4383+
uint64_t waitTime; /* microseconds */
4384+
uint64_t waitTimeEnd; /* absolute timestamp */
4385+
char *method;
4386+
char *thread;
43894387
} J9JITLongestSyncComp;
43904388

43914389
typedef struct J9JITSyncCompilationStatistics {
43924390
uint32_t totalCount;
4393-
/* microseconds (us) */
4394-
uint64_t totalWaitTime;
4395-
/* sorted in increasing order */
4396-
J9JITLongestSyncComp longestWaitMethods[J9_LONGEST_SYNC_COMP];
4391+
uint64_t totalWaitTime; /* microseconds */
4392+
J9JITLongestSyncComp longestWaitMethods[J9_LONGEST_SYNC_COMP]; /* sorted in increasing order */
43974393
} J9JITSyncCompilationStatistics;
43984394

43994395
/* @ddr_namespace: map_to_type=J9JITConfig */

runtime/rasdump/javadump.cpp

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,9 +2925,9 @@ JavaCoreDumpWriter::writeSynchronousCompilationSection(void)
29252925
OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);
29262926

29272927
J9JITConfig *jitConfig = _VirtualMachine->jitConfig;
2928-
if (NULL == jitConfig || NULL == jitConfig->syncCompStats) {
2929-
return;
2930-
}
2928+
if ((NULL == jitConfig) || (NULL == jitConfig->syncCompStats)) {
2929+
return;
2930+
}
29312931

29322932
J9JITSyncCompilationStatistics *stats = jitConfig->syncCompStats;
29332933

@@ -2936,57 +2936,58 @@ JavaCoreDumpWriter::writeSynchronousCompilationSection(void)
29362936
_OutputStream.writeCharacters("1NOTE This data is reset after each javacore file is written\n");
29372937
_OutputStream.writeCharacters("NULL ------------------------------------------------------------------------\n");
29382938
_OutputStream.writeCharacters("1JITSYNCSTATS Synchronous Compilation Statistics\n");
2939-
_OutputStream.writeCharacters("NULL ------------------------------------------------------------------------\n");
2939+
_OutputStream.writeCharacters("NULL ------------------------------------------------------------------------\n");
29402940
_OutputStream.writeCharacters("2JITSYNCCOUNT Total synchronous compilations: ");
2941-
_OutputStream.writeInteger(stats->totalCount, "%u");
2942-
_OutputStream.writeCharacters("\n");
2941+
_OutputStream.writeInteger(stats->totalCount, "%u");
2942+
_OutputStream.writeCharacters("\n");
29432943
_OutputStream.writeCharacters("2JITTOTALWAIT Total application wait time: ");
2944-
_OutputStream.writeInteger(stats->totalWaitTime, "%llu");
2945-
_OutputStream.writeCharacters("us\n");
2944+
_OutputStream.writeInteger(stats->totalWaitTime, "%llu");
2945+
_OutputStream.writeCharacters("us\n");
29462946
for (int i = 0; i < J9_LONGEST_SYNC_COMP; i++) {
2947-
if (stats->longestWaitMethods[i].waitTime == 0 || stats->longestWaitMethods[i].method == NULL)
2947+
J9JITLongestSyncComp &longestWaitMethod = stats->longestWaitMethods[i];
2948+
if ((0 == longestWaitMethod.waitTime) || (NULL == longestWaitMethod.method)) {
29482949
break;
2950+
}
29492951
_OutputStream.writeCharacters("2JITLONGEST ");
29502952
_OutputStream.writeInteger64(i + 1, "%zu");
29512953
_OutputStream.writeCharacters(". Longest Synchronous Compilation\n");
29522954

29532955
_OutputStream.writeCharacters("3JITWAITTIME Wait time: ");
2954-
_OutputStream.writeInteger(stats->longestWaitMethods[i].waitTime, "%llu");
2956+
_OutputStream.writeInteger(longestWaitMethod.waitTime, "%llu");
29552957
_OutputStream.writeCharacters("us\n");
29562958

29572959
_OutputStream.writeCharacters("3JITENDTIME Wait time end: ");
29582960
omrstr_ftime_ex(timeStamp, _MaximumTimeStampLength, "%Y-%m-%dT%H:%M:%S",
2959-
stats->longestWaitMethods[i].waitTimeEnd, OMRSTR_FTIME_FLAG_LOCAL);
2961+
longestWaitMethod.waitTimeEnd, OMRSTR_FTIME_FLAG_LOCAL);
29602962
timeStamp[_MaximumTimeStampLength] = '\0';
29612963
_OutputStream.writeCharacters(timeStamp);
2962-
_OutputStream.writeInteger64(stats->longestWaitMethods[i].waitTimeEnd % 1000, ".%03llu");
2964+
_OutputStream.writeInteger64(longestWaitMethod.waitTimeEnd % 1000, ".%03llu");
29632965
_OutputStream.writeCharacters("\n");
29642966

29652967
_OutputStream.writeCharacters("3JITMETHOD Method: ");
2966-
_OutputStream.writeCharacters(stats->longestWaitMethods[i].method);
2968+
_OutputStream.writeCharacters(longestWaitMethod.method);
29672969
_OutputStream.writeCharacters("\n");
29682970

2969-
if (stats->longestWaitMethods[i].thread != NULL) {
2970-
_OutputStream.writeCharacters("3JITTHREAD Thread: ");
2971-
_OutputStream.writeCharacters(stats->longestWaitMethods[i].thread);
2972-
_OutputStream.writeCharacters("\n");
2973-
}
2971+
_OutputStream.writeCharacters("3JITTHREAD Thread: ");
2972+
_OutputStream.writeCharacters(longestWaitMethod.thread);
2973+
_OutputStream.writeCharacters("\n");
29742974
}
29752975

29762976
stats->totalCount = 0;
2977-
stats->totalWaitTime = 0;
2977+
stats->totalWaitTime = 0;
29782978
for (int i = 0; i < J9_LONGEST_SYNC_COMP; i++) {
2979-
stats->longestWaitMethods[i].waitTime = 0;
2980-
stats->longestWaitMethods[i].waitTimeEnd = 0;
2981-
if (stats->longestWaitMethods[i].method != NULL) {
2982-
j9mem_free_memory(stats->longestWaitMethods[i].method);
2983-
stats->longestWaitMethods[i].method = NULL;
2984-
}
2985-
if (stats->longestWaitMethods[i].thread != NULL) {
2986-
j9mem_free_memory(stats->longestWaitMethods[i].thread);
2987-
stats->longestWaitMethods[i].thread = NULL;
2988-
}
2989-
}
2979+
J9JITLongestSyncComp &longestWaitMethod = stats->longestWaitMethods[i];
2980+
longestWaitMethod.waitTime = 0;
2981+
longestWaitMethod.waitTimeEnd = 0;
2982+
if (NULL != longestWaitMethod.method) {
2983+
j9mem_free_memory(longestWaitMethod.method);
2984+
longestWaitMethod.method = NULL;
2985+
}
2986+
if (NULL != longestWaitMethod.thread) {
2987+
j9mem_free_memory(longestWaitMethod.thread);
2988+
longestWaitMethod.thread = NULL;
2989+
}
2990+
}
29902991
}
29912992

29922993
#if defined(OMR_OPT_CUDA)

0 commit comments

Comments
 (0)