Skip to content

Commit cd71984

Browse files
committed
Address review comments
Formating fix and use predefined macros Signed-off-by: Jack Lu <[email protected]>
1 parent dd63f7e commit cd71984

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

jcl/src/java.base/share/classes/java/lang/Thread.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ private static final class TidLock {
9494
*/
9595
private volatile boolean deadInterrupt;
9696
/*[ENDIF] JAVA_SPEC_VERSION >= 14 */
97-
private volatile boolean started; // If !isAlive(), tells if Thread died already or hasn't even started
98-
private String name; // The Thread's name
99-
private int priority = NORM_PRIORITY; // The Thread's current priority
97+
private volatile boolean started; // If !isAlive(), tells if Thread died already or hasn't even started
98+
private String name; // The Thread's name
99+
private int priority = NORM_PRIORITY; // The Thread's current priority
100100
private boolean isDaemon; // Tells if the Thread is a daemon thread or not.
101101
private volatile int threadStatus; // The Thread's state.
102102

103-
ThreadGroup group; // A Thread belongs to exactly one ThreadGroup
103+
ThreadGroup group; // A Thread belongs to exactly one ThreadGroup
104104
private Runnable runnable; // Target (optional) runnable object
105-
private boolean stopCalled = false; // Used by the VM
105+
private boolean stopCalled = false; // Used by the VM
106106
/*[PR 1FENTZW]*/
107107
private ClassLoader contextClassLoader; // Used to find classes and resources in this Thread
108108
ThreadLocal.ThreadLocalMap threadLocals;
@@ -1492,32 +1492,33 @@ public static enum State {
14921492
/**
14931493
* Returns the translation from a J9VMThread state to a Thread::State.
14941494
*
1495+
* @param status thread status value set by VM.
14951496
* @return this thread's state.
14961497
*
14971498
* @see State
14981499
*/
14991500
private State translateJ9VMThreadStateToThreadState(int status) {
15001501
switch (status) {
1501-
case 1: // J9VMTHREAD_STATE_RUNNING
1502-
return State.RUNNABLE;
1503-
case 2: // J9VMTHREAD_STATE_BLOCKED
1504-
return State.BLOCKED;
1505-
case 4: // J9VMTHREAD_STATE_WAITING
1506-
case 0x80: // J9VMTHREAD_STATE_PARKED
1507-
return State.WAITING;
1508-
case 8: // J9VMTHREAD_STATE_SLEEPING
1509-
case 64: // J9VMTHREAD_STATE_WAITING_TIMED
1510-
case 0x100: // J9VMTHREAD_STATE_PARKED_TIMED
1511-
return State.TIMED_WAITING;
1512-
case 32: // J9VMTHREAD_STATE_DEAD
1513-
return State.TERMINATED;
1514-
default:
1515-
synchronized (lock) {
1516-
if (threadRef == NO_REF) {
1517-
return State.TERMINATED;
1518-
}
1519-
return State.values()[getStateImpl(threadRef)];
1502+
case 1: // J9VMTHREAD_STATE_RUNNING
1503+
return State.RUNNABLE;
1504+
case 2: // J9VMTHREAD_STATE_BLOCKED
1505+
return State.BLOCKED;
1506+
case 4: // J9VMTHREAD_STATE_WAITING
1507+
case 0x80: // J9VMTHREAD_STATE_PARKED
1508+
return State.WAITING;
1509+
case 8: // J9VMTHREAD_STATE_SLEEPING
1510+
case 64: // J9VMTHREAD_STATE_WAITING_TIMED
1511+
case 0x100: // J9VMTHREAD_STATE_PARKED_TIMED
1512+
return State.TIMED_WAITING;
1513+
case 32: // J9VMTHREAD_STATE_DEAD
1514+
return State.TERMINATED;
1515+
default:
1516+
synchronized (lock) {
1517+
if (threadRef == NO_REF) {
1518+
return State.TERMINATED;
15201519
}
1520+
return State.values()[getStateImpl(threadRef)];
1521+
}
15211522
}
15221523
}
15231524

runtime/vm/threadhelp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ monitorWaitImpl(J9VMThread *vmThread, j9object_t object, I_64 millis, I_32 nanos
107107
J9VMTHREAD_SET_BLOCKINGENTEROBJECT(vmThread, vmThread, object);
108108
object = NULL;
109109
/* Set j.l.Thread status to WAITING. */
110-
U_64 oldState = (0 != (thrstate & J9_PUBLIC_FLAGS_THREAD_TIMED))
110+
U_64 oldState = J9_ARE_ANY_BITS_SET(thrstate, J9_PUBLIC_FLAGS_THREAD_TIMED)
111111
? VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING_TIMED)
112112
: VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING);
113113
internalReleaseVMAccessSetStatus(vmThread, thrstate);

runtime/vm/threadpark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ threadParkImpl(J9VMThread *vmThread, BOOLEAN timeoutIsEpochRelative, I_64 timeou
9999
J9VMTHREAD_SET_BLOCKINGENTEROBJECT(vmThread, vmThread, J9VMJAVALANGTHREAD_PARKBLOCKER(vmThread, vmThread->threadObject));
100100
TRIGGER_J9HOOK_VM_PARK(vm->hookInterface, vmThread, millis, nanos);
101101
/* Set j.l.Thread status to WAITING. */
102-
U_64 oldState = (0 != (thrstate & J9_PUBLIC_FLAGS_THREAD_TIMED))
102+
U_64 oldState = J9_ARE_ANY_BITS_SET(thrstate, J9_PUBLIC_FLAGS_THREAD_TIMED)
103103
? VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING_TIMED)
104104
: VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING);
105105
internalReleaseVMAccessSetStatus(vmThread, thrstate);

0 commit comments

Comments
 (0)