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

Redundant condition check in SafepointSynchronize::thread_not_running

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 17
    • 18
    • hotspot
    • b26

    Description

      `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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: