Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8267767

Redundant condition check in SafepointSynchronize::thread_not_running

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 18
    • 17
    • hotspot
    • b26

      `SafepointSynchronize::thread_not_running` starts by checking if the current state is `is_running`:

      ```
      bool SafepointSynchronize::thread_not_running(ThreadSafepointState *cur_state) {
        if (!cur_state->is_running()) {
          return true;
        }
        ...
      }
      ```

      However, this has been asserted by the caller, `SafepointSynchronize::synchronize_threads`.

      ## call site 1

      ```
        for (; JavaThread *cur = jtiwh.next(); ) {
          assert(cur->safepoint_state()->is_running(), "Illegal initial state");
        }
        ...
        if (thread_not_running(cur_tss)) {
      ```

      ## call site 2

      ```
            assert(cur_tss->is_running(), "Illegal initial state");
            if (thread_not_running(cur_tss)) {
      ```

      Therefore, `!cur_state->is_running()` is always false, and the `if` is just skipped.

            dholmes David Holmes
            ayang Albert Yang
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: