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

Avoid VM_EnableBiasedLocking VM operation during bootstrap if BiasedLockingStartupDelay is 0

XMLWordPrintable

    • b04

      Currently we will execute a VM operation during bootstrap to change the _prototype_header of all Klass instances, which triggers a safepoint early on. Instead we should consider doing the right thing from the start in this (the default) case.

      Prototype patch below seems to work (with and without CDS)

      diff -r b084d60c1377 src/hotspot/share/oops/klass.cpp
      --- a/src/hotspot/share/oops/klass.cpp Wed Jun 05 14:03:07 2019 +0200
      +++ b/src/hotspot/share/oops/klass.cpp Wed Jun 05 16:34:55 2019 +0200
      @@ -195,10 +195,14 @@
       // should be NULL before setting it.
       Klass::Klass(KlassID id) : _id(id),
                                  _java_mirror(NULL),
      - _prototype_header(markOopDesc::prototype()),
                                  _shared_class_path_index(-1) {
         CDS_ONLY(_shared_class_flags = 0;)
         CDS_JAVA_HEAP_ONLY(_archived_mirror = 0;)
      + if (UseBiasedLocking && BiasedLockingStartupDelay == 0) {
      + _prototype_header = markOopDesc::biased_locking_prototype();
      + } else {
      + _prototype_header = markOopDesc::prototype();
      + }
         _primary_supers[0] = this;
         set_super_check_offset(in_bytes(primary_supers_offset()));
       }
      diff -r b084d60c1377 src/hotspot/share/runtime/biasedLocking.cpp
      --- a/src/hotspot/share/runtime/biasedLocking.cpp Wed Jun 05 14:03:07 2019 +0200
      +++ b/src/hotspot/share/runtime/biasedLocking.cpp Wed Jun 05 16:34:55 2019 +0200
      @@ -104,16 +104,12 @@
           if (BiasedLockingStartupDelay > 0) {
             EnableBiasedLockingTask* task = new EnableBiasedLockingTask(BiasedLockingStartupDelay);
             task->enroll();
      - } else {
      - VM_EnableBiasedLocking op(false);
      - VMThread::execute(&op);
           }
         }
       }
       
      -
       bool BiasedLocking::enabled() {
      - return _biased_locking_enabled;
      + return (UseBiasedLocking && BiasedLockingStartupDelay == 0) || _biased_locking_enabled;
       }
       
       // Returns MonitorInfos for all objects locked on this thread in youngest to oldest order

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: