< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "code/icBuffer.hpp"
  28 #include "code/nmethod.hpp"
  29 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  30 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  31 #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
  32 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  33 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  34 #include "gc/shenandoah/shenandoahUtils.hpp"
  35 #include "memory/resourceArea.hpp"
  36 #include "memory/universe.hpp"
  37 #include "runtime/atomic.hpp"
  38 #include "utilities/powerOfTwo.hpp"
  39 
  40 ShenandoahParallelCodeCacheIterator::ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps) {
  41   _length = heaps->length();
  42   _iters = NEW_C_HEAP_ARRAY(ShenandoahParallelCodeHeapIterator, _length, mtGC);
  43   for (int h = 0; h < _length; h++) {
  44     _iters[h] = ShenandoahParallelCodeHeapIterator(heaps->at(h));
  45   }
  46 }
  47 
  48 ShenandoahParallelCodeCacheIterator::~ShenandoahParallelCodeCacheIterator() {
  49   FREE_C_HEAP_ARRAY(ParallelCodeHeapIterator, _iters);
  50 }
  51 


 294   ICRefillVerifier*                   _verifier;
 295   ShenandoahConcurrentNMethodIterator _iterator;
 296 
 297 public:
 298   ShenandoahUnlinkTask(bool unloading_occurred, ICRefillVerifier* verifier) :
 299     AbstractGangTask("ShenandoahNMethodUnlinkTask"),
 300     _cl(unloading_occurred),
 301     _verifier(verifier),
 302     _iterator(ShenandoahCodeRoots::table()) {
 303     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 304     _iterator.nmethods_do_begin();
 305   }
 306 
 307   ~ShenandoahUnlinkTask() {
 308     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 309     _iterator.nmethods_do_end();
 310   }
 311 
 312   virtual void work(uint worker_id) {
 313     ICRefillVerifierMark mark(_verifier);
 314     ShenandoahEvacOOMScope evac_scope;
 315     _iterator.nmethods_do(&_cl);
 316   }
 317 
 318   bool success() const {
 319     return !_cl.failed();
 320   }
 321 };
 322 
 323 void ShenandoahCodeRoots::unlink(WorkGang* workers, bool unloading_occurred) {
 324   assert(ShenandoahConcurrentRoots::should_do_concurrent_class_unloading(),
 325          "Only when running concurrent class unloading");
 326 
 327   for (;;) {
 328     ICRefillVerifier verifier;
 329 
 330     {
 331       ShenandoahUnlinkTask task(unloading_occurred, &verifier);
 332       workers->run_task(&task);
 333       if (task.success()) {
 334         return;




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "code/icBuffer.hpp"
  28 #include "code/nmethod.hpp"
  29 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  30 #include "gc/shenandoah/shenandoahCodeRoots.hpp"

  31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  32 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  33 #include "gc/shenandoah/shenandoahUtils.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "memory/universe.hpp"
  36 #include "runtime/atomic.hpp"
  37 #include "utilities/powerOfTwo.hpp"
  38 
  39 ShenandoahParallelCodeCacheIterator::ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps) {
  40   _length = heaps->length();
  41   _iters = NEW_C_HEAP_ARRAY(ShenandoahParallelCodeHeapIterator, _length, mtGC);
  42   for (int h = 0; h < _length; h++) {
  43     _iters[h] = ShenandoahParallelCodeHeapIterator(heaps->at(h));
  44   }
  45 }
  46 
  47 ShenandoahParallelCodeCacheIterator::~ShenandoahParallelCodeCacheIterator() {
  48   FREE_C_HEAP_ARRAY(ParallelCodeHeapIterator, _iters);
  49 }
  50 


 293   ICRefillVerifier*                   _verifier;
 294   ShenandoahConcurrentNMethodIterator _iterator;
 295 
 296 public:
 297   ShenandoahUnlinkTask(bool unloading_occurred, ICRefillVerifier* verifier) :
 298     AbstractGangTask("ShenandoahNMethodUnlinkTask"),
 299     _cl(unloading_occurred),
 300     _verifier(verifier),
 301     _iterator(ShenandoahCodeRoots::table()) {
 302     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 303     _iterator.nmethods_do_begin();
 304   }
 305 
 306   ~ShenandoahUnlinkTask() {
 307     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 308     _iterator.nmethods_do_end();
 309   }
 310 
 311   virtual void work(uint worker_id) {
 312     ICRefillVerifierMark mark(_verifier);

 313     _iterator.nmethods_do(&_cl);
 314   }
 315 
 316   bool success() const {
 317     return !_cl.failed();
 318   }
 319 };
 320 
 321 void ShenandoahCodeRoots::unlink(WorkGang* workers, bool unloading_occurred) {
 322   assert(ShenandoahConcurrentRoots::should_do_concurrent_class_unloading(),
 323          "Only when running concurrent class unloading");
 324 
 325   for (;;) {
 326     ICRefillVerifier verifier;
 327 
 328     {
 329       ShenandoahUnlinkTask task(unloading_occurred, &verifier);
 330       workers->run_task(&task);
 331       if (task.success()) {
 332         return;


< prev index next >