src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp
changeset 53582 881c5fbeb849
parent 53244 9807daeb47c4
child 53850 f42c58bab973
equal deleted inserted replaced
53581:dfacdb971494 53582:881c5fbeb849
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2018, Red Hat, Inc. All rights reserved.
     2  * Copyright (c) 2015, 2019, Red Hat, Inc. All rights reserved.
     3  *
     3  *
     4  * This code is free software; you can redistribute it and/or modify it
     4  * This code is free software; you can redistribute it and/or modify it
     5  * under the terms of the GNU General Public License version 2 only, as
     5  * under the terms of the GNU General Public License version 2 only, as
     6  * published by the Free Software Foundation.
     6  * published by the Free Software Foundation.
     7  *
     7  *
    29 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
    29 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
    30 #include "gc/shared/suspendibleThreadSet.hpp"
    30 #include "gc/shared/suspendibleThreadSet.hpp"
    31 #include "gc/shenandoah/shenandoahAsserts.hpp"
    31 #include "gc/shenandoah/shenandoahAsserts.hpp"
    32 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
    32 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
    33 #include "gc/shenandoah/shenandoahBrooksPointer.inline.hpp"
    33 #include "gc/shenandoah/shenandoahBrooksPointer.inline.hpp"
    34 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
       
    35 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
    34 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
    36 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
    35 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
    37 #include "gc/shenandoah/shenandoahHeap.hpp"
    36 #include "gc/shenandoah/shenandoahHeap.hpp"
    38 #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
    37 #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
    39 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
    38 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
    40 #include "gc/shenandoah/shenandoahControlThread.hpp"
    39 #include "gc/shenandoah/shenandoahControlThread.hpp"
    41 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
    40 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
    42 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
    41 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
    43 #include "oops/oop.inline.hpp"
    42 #include "oops/oop.inline.hpp"
    44 #include "runtime/atomic.hpp"
    43 #include "runtime/atomic.hpp"
    45 #include "runtime/interfaceSupport.inline.hpp"
       
    46 #include "runtime/prefetch.hpp"
       
    47 #include "runtime/prefetch.inline.hpp"
    44 #include "runtime/prefetch.inline.hpp"
    48 #include "runtime/thread.hpp"
    45 #include "runtime/thread.hpp"
    49 #include "utilities/copy.hpp"
    46 #include "utilities/copy.hpp"
    50 #include "utilities/globalDefinitions.hpp"
    47 #include "utilities/globalDefinitions.hpp"
    51 
    48 
   211       _cancelled_gc.set(CANCELLABLE);
   208       _cancelled_gc.set(CANCELLABLE);
   212     }
   209     }
   213     return false;
   210     return false;
   214   } else {
   211   } else {
   215     return true;
   212     return true;
   216   }
       
   217 }
       
   218 
       
   219 inline bool ShenandoahHeap::try_cancel_gc() {
       
   220   while (true) {
       
   221     jbyte prev = _cancelled_gc.cmpxchg(CANCELLED, CANCELLABLE);
       
   222     if (prev == CANCELLABLE) return true;
       
   223     else if (prev == CANCELLED) return false;
       
   224     assert(ShenandoahSuspendibleWorkers, "should not get here when not using suspendible workers");
       
   225     assert(prev == NOT_CANCELLED, "must be NOT_CANCELLED");
       
   226     {
       
   227       // We need to provide a safepoint here, otherwise we might
       
   228       // spin forever if a SP is pending.
       
   229       ThreadBlockInVM sp(JavaThread::current());
       
   230       SpinPause();
       
   231     }
       
   232   }
   213   }
   233 }
   214 }
   234 
   215 
   235 inline void ShenandoahHeap::clear_cancelled_gc() {
   216 inline void ShenandoahHeap::clear_cancelled_gc() {
   236   _cancelled_gc.set(CANCELLABLE);
   217   _cancelled_gc.set(CANCELLABLE);