< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahSharedVariables.hpp

Print this page
rev 59533 : 8246097: Shenandoah: limit parallelism in CLDG root handling
Reviewed-by: XXX


 228 
 229   volatile ShenandoahSharedValue* addr_of() {
 230     return &value;
 231   }
 232 
 233 private:
 234   volatile T* operator&() {
 235     fatal("Use addr_of() instead");
 236     return NULL;
 237   }
 238 
 239   bool operator==(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 240   bool operator!=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 241   bool operator> (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 242   bool operator>=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 243   bool operator< (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 244   bool operator<=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 245 
 246 };
 247 


































 248 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHSHAREDVARIABLES_HPP


 228 
 229   volatile ShenandoahSharedValue* addr_of() {
 230     return &value;
 231   }
 232 
 233 private:
 234   volatile T* operator&() {
 235     fatal("Use addr_of() instead");
 236     return NULL;
 237   }
 238 
 239   bool operator==(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 240   bool operator!=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 241   bool operator> (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 242   bool operator>=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 243   bool operator< (ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 244   bool operator<=(ShenandoahSharedEnumFlag& other) { fatal("Use get() instead"); return false; }
 245 
 246 };
 247 
 248 typedef struct ShenandoahSharedSemaphore {
 249   shenandoah_padding(0);
 250   volatile ShenandoahSharedValue value;
 251   shenandoah_padding(1);
 252 
 253   static uint max_tokens() {
 254     return sizeof(ShenandoahSharedValue) * CHAR_MAX;
 255   }
 256 
 257   ShenandoahSharedSemaphore(uint tokens) {
 258     assert(tokens <= max_tokens(), "sanity");
 259     Atomic::release_store_fence(&value, (ShenandoahSharedValue)tokens);
 260   }
 261 
 262   bool try_acquire() {
 263     while (true) {
 264       ShenandoahSharedValue ov = Atomic::load_acquire(&value);
 265       if (ov == 0) {
 266         return false;
 267       }
 268       ShenandoahSharedValue nv = ov - 1;
 269       if (Atomic::cmpxchg(&value, ov, nv) == ov) {
 270         // successfully set
 271         return true;
 272       }
 273     }
 274   }
 275 
 276   void claim_all() {
 277     Atomic::release_store_fence(&value, (ShenandoahSharedValue)0);
 278   }
 279 
 280 } ShenandoahSharedSemaphore;
 281 
 282 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHSHAREDVARIABLES_HPP
< prev index next >