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

JNIHandles::is_weak_global_handle is not cheap

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 14
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
      None

      Description

      The compiler task queue code that makes weak global handles into strong global handles in select_for_compilation, could set a flag that the compileTask is active, so that it doesn't have to ask is_weak_global_handle() about the holders, which is expensive (lock and several SafeFetch loads).

      bool CompileTask::is_unloaded() const {
        return _method_holder != NULL && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_global_weak_cleared(_method_holder);
      }

      // Replace weak handles by strong handles to avoid unloading during compilation.
      CompileTask* CompileTask::select_for_compilation() {
        if (is_unloaded()) {
          // Guard against concurrent class unloading
          return NULL;
        }
        Thread* thread = Thread::current();
        assert(_method->method_holder()->is_loader_alive(), "should be alive");
        Handle method_holder(thread, _method->method_holder()->klass_holder());
        JNIHandles::destroy_weak_global(_method_holder);
        JNIHandles::destroy_weak_global(_hot_method_holder);
        _method_holder = JNIHandles::make_global(method_holder);
        if (_hot_method != NULL) {
          _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder()));
        }
        return this;
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                coleenp Coleen Phillimore
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: