< prev index next >

src/share/vm/gc_implementation/shenandoah/shenandoahCodeRoots.cpp

Print this page
rev 10682 : [backport] Code root iterators should not be instantiated in worker threads
rev 10683 : [backport] Record location when asserting the code root correctness
rev 10714 : [backport] Rehash and cleanup usages of ShenandoahHeap::heap()
rev 10715 : [backport] Cleanup up superfluous newlines
rev 10740 : [backport] Protect more internal code from false sharing
rev 10761 : [backport] Make ResourceMark use consistent in ShenandoahCodeRoots
rev 10772 : [backport] Update copyrights

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2017, 2018, Red Hat, Inc. and/or its affiliates.
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
  *

@@ -19,21 +19,21 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  *
  */
 
-
 #include "precompiled.hpp"
 #include "code/codeCache.hpp"
 #include "code/nmethod.hpp"
 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
 #include "gc_implementation/shenandoah/shenandoahCodeRoots.hpp"
+#include "memory/resourceArea.hpp"
 
 ShenandoahParallelCodeCacheIterator::ShenandoahParallelCodeCacheIterator() :
         _claimed_idx(0), _finished(false) {
-};
+}
 
 void ShenandoahParallelCodeCacheIterator::parallel_blobs_do(CodeBlobClosure* f) {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
 
   /*

@@ -78,15 +78,15 @@
   _finished = true;
 }
 
 class ShenandoahNMethodOopDetector : public OopClosure {
 private:
-  ShenandoahHeap* _heap;
+  ResourceMark rm; // For growable array allocation below.
   GrowableArray<oop*> _oops;
 
 public:
-  ShenandoahNMethodOopDetector() : _heap(ShenandoahHeap::heap()), _oops(10) {};
+  ShenandoahNMethodOopDetector() : _oops(10) {};
 
   void do_oop(oop* o) {
     _oops.append(o);
   }
 

@@ -128,15 +128,15 @@
   void do_oop(narrowOop* o) {
     do_oop_work(o);
   }
 };
 
-volatile jint ShenandoahCodeRoots::_recorded_nms_lock;
+ShenandoahCodeRoots::PaddedLock ShenandoahCodeRoots::_recorded_nms_lock;
 GrowableArray<ShenandoahNMethod*>* ShenandoahCodeRoots::_recorded_nms;
 
 void ShenandoahCodeRoots::initialize() {
-  _recorded_nms_lock = 0;
+  _recorded_nms_lock._lock = 0;
   _recorded_nms = new (ResourceObj::C_HEAP, mtGC) GrowableArray<ShenandoahNMethod*>(100, true, mtGC);
 }
 
 void ShenandoahCodeRoots::add_nmethod(nmethod* nm) {
   switch (ShenandoahCodeRootsStyle) {

@@ -206,10 +206,11 @@
 
 ShenandoahCodeRootsIterator::ShenandoahCodeRootsIterator() :
         _heap(ShenandoahHeap::heap()),
         _claimed(0) {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
+  assert(!Thread::current()->is_Worker_thread(), "Should not be acquired by workers");
   switch (ShenandoahCodeRootsStyle) {
     case 0:
     case 1:
       break;
     case 2:

@@ -331,13 +332,14 @@
 void ShenandoahNMethod::assert_alive_and_correct() {
   assert(_nm->is_alive(), "only alive nmethods here");
   assert(_oops_count > 0, "should have filtered nmethods without oops before");
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   for (int c = 0; c < _oops_count; c++) {
-    oop o = oopDesc::load_heap_oop(_oops[c]);
-    shenandoah_assert_correct_except(NULL, o, o == NULL || heap->is_full_gc_move_in_progress());
-    assert(_nm->code_contains((address)_oops[c]) || _nm->oops_contains(_oops[c]), "nmethod should contain the oop*");
+    oop *loc = _oops[c];
+    assert(_nm->code_contains((address)loc) || _nm->oops_contains(loc), "nmethod should contain the oop*");
+    oop o = oopDesc::load_heap_oop(loc);
+    shenandoah_assert_correct_except(loc, o, o == NULL || heap->is_full_gc_move_in_progress());
   }
 }
 
 void ShenandoahNMethod::assert_same_oops(GrowableArray<oop*>* oops) {
   assert(_oops_count == oops->length(), "should have the same number of oop*");
< prev index next >