RFR: Unreachable assert in ShenandoahCodeRoots::acquire_lock

Aleksey Shipilev shade at redhat.com
Wed Sep 5 08:41:37 UTC 2018


Static analysis says that assert is unreachable. Indeed it is, because the loop exits with return.
Not only that, the assert itself is incorrect.

diff -r b67a4350c0b0 src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp   Tue Sep 04 12:47:36 2018 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp   Wed Sep 05 09:37:45 2018 +0200
@@ -151,16 +151,16 @@
       while (true) {
         int cur = OrderAccess::load_acquire(loc);
         if (cur >= 0) {
           if (Atomic::cmpxchg(cur + 1, loc, cur) == cur) {
             // Success!
+            assert (*loc > 0, "acquired for read");
             return;
           }
         }
         SpinPause();
       }
-      assert (*loc > 1, "acquired for read");
     }
   }

   static void release_lock(bool write) {
     volatile int* loc = &ShenandoahCodeRoots::_recorded_nms_lock;


Testing: tier3_gc_shenandoah

Thanks,
-Aleksey



More information about the shenandoah-dev mailing list