< prev index next >

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

Print this page
rev 55608 : Rename ShenandoahBrooksPointer to ShenandoahForwarding
rev 55609 : Eliminate extra forwarding pointer per object


   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shenandoah/shenandoahAsserts.hpp"
  26 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  27 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
  28 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  29 #include "gc/shenandoah/shenandoahForwarding.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  32 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
  33 #include "memory/iterator.inline.hpp"
  34 #include "runtime/interfaceSupport.inline.hpp"
  35 #ifdef COMPILER1
  36 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
  37 #endif
  38 #ifdef COMPILER2
  39 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  40 #endif
  41 
  42 class ShenandoahBarrierSetC1;
  43 class ShenandoahBarrierSetC2;
  44 
  45 template <bool STOREVAL_WRITE_BARRIER>
  46 class ShenandoahUpdateRefsForOopClosure: public BasicOopIterateClosure {
  47 private:
  48   ShenandoahHeap* _heap;
  49   ShenandoahBarrierSet* _bs;


 245     oop res_oop = _heap->evacuate_object(obj, thread);
 246 
 247     // Since we are already here and paid the price of getting through runtime call adapters
 248     // and acquiring oom-scope, it makes sense to try and evacuate more adjacent objects,
 249     // thus amortizing the overhead. For sparsely live heaps, scan costs easily dominate
 250     // total assist costs, and can introduce a lot of evacuation latency. This is why we
 251     // only scan for _nearest_ N objects, regardless if they are eligible for evac or not.
 252     // The scan itself should also avoid touching the non-marked objects below TAMS, because
 253     // their metadata (notably, klasses) may be incorrect already.
 254 
 255     size_t max = ShenandoahEvacAssist;
 256     if (max > 0) {
 257       // Traversal is special: it uses incomplete marking context, because it coalesces evac with mark.
 258       // Other code uses complete marking context, because evac happens after the mark.
 259       ShenandoahMarkingContext* ctx = _heap->is_concurrent_traversal_in_progress() ?
 260                                       _heap->marking_context() : _heap->complete_marking_context();
 261 
 262       ShenandoahHeapRegion* r = _heap->heap_region_containing(obj);
 263       assert(r->is_cset(), "sanity");
 264 
 265       HeapWord* cur = (HeapWord*)obj + obj->size() + ShenandoahForwarding::word_size();
 266 
 267       size_t count = 0;
 268       while ((cur < r->top()) && ctx->is_marked(oop(cur)) && (count++ < max)) {
 269         oop cur_oop = oop(cur);
 270         if (oopDesc::equals_raw(cur_oop, resolve_forwarded_not_null(cur_oop))) {
 271           _heap->evacuate_object(cur_oop, thread);
 272         }
 273         cur = cur + cur_oop->size() + ShenandoahForwarding::word_size();
 274       }
 275     }
 276 
 277     return res_oop;
 278   }
 279   return fwd;
 280 }
 281 
 282 oop ShenandoahBarrierSet::load_reference_barrier_impl(oop obj) {
 283   assert(ShenandoahLoadRefBarrier, "should be enabled");
 284   if (!CompressedOops::is_null(obj)) {
 285     bool evac_in_progress = _heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
 286     oop fwd = resolve_forwarded_not_null(obj);
 287     if (evac_in_progress &&
 288         _heap->in_collection_set(obj) &&
 289         oopDesc::equals_raw(obj, fwd)) {
 290       Thread *t = Thread::current();
 291       if (t->is_GC_task_thread()) {
 292         return _heap->evacuate_object(obj, t);
 293       } else {




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

  29 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  30 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  31 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
  32 #include "memory/iterator.inline.hpp"
  33 #include "runtime/interfaceSupport.inline.hpp"
  34 #ifdef COMPILER1
  35 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
  36 #endif
  37 #ifdef COMPILER2
  38 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  39 #endif
  40 
  41 class ShenandoahBarrierSetC1;
  42 class ShenandoahBarrierSetC2;
  43 
  44 template <bool STOREVAL_WRITE_BARRIER>
  45 class ShenandoahUpdateRefsForOopClosure: public BasicOopIterateClosure {
  46 private:
  47   ShenandoahHeap* _heap;
  48   ShenandoahBarrierSet* _bs;


 244     oop res_oop = _heap->evacuate_object(obj, thread);
 245 
 246     // Since we are already here and paid the price of getting through runtime call adapters
 247     // and acquiring oom-scope, it makes sense to try and evacuate more adjacent objects,
 248     // thus amortizing the overhead. For sparsely live heaps, scan costs easily dominate
 249     // total assist costs, and can introduce a lot of evacuation latency. This is why we
 250     // only scan for _nearest_ N objects, regardless if they are eligible for evac or not.
 251     // The scan itself should also avoid touching the non-marked objects below TAMS, because
 252     // their metadata (notably, klasses) may be incorrect already.
 253 
 254     size_t max = ShenandoahEvacAssist;
 255     if (max > 0) {
 256       // Traversal is special: it uses incomplete marking context, because it coalesces evac with mark.
 257       // Other code uses complete marking context, because evac happens after the mark.
 258       ShenandoahMarkingContext* ctx = _heap->is_concurrent_traversal_in_progress() ?
 259                                       _heap->marking_context() : _heap->complete_marking_context();
 260 
 261       ShenandoahHeapRegion* r = _heap->heap_region_containing(obj);
 262       assert(r->is_cset(), "sanity");
 263 
 264       HeapWord* cur = (HeapWord*)obj + obj->size();
 265 
 266       size_t count = 0;
 267       while ((cur < r->top()) && ctx->is_marked(oop(cur)) && (count++ < max)) {
 268         oop cur_oop = oop(cur);
 269         if (oopDesc::equals_raw(cur_oop, resolve_forwarded_not_null(cur_oop))) {
 270           _heap->evacuate_object(cur_oop, thread);
 271         }
 272         cur = cur + cur_oop->size();
 273       }
 274     }
 275 
 276     return res_oop;
 277   }
 278   return fwd;
 279 }
 280 
 281 oop ShenandoahBarrierSet::load_reference_barrier_impl(oop obj) {
 282   assert(ShenandoahLoadRefBarrier, "should be enabled");
 283   if (!CompressedOops::is_null(obj)) {
 284     bool evac_in_progress = _heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
 285     oop fwd = resolve_forwarded_not_null(obj);
 286     if (evac_in_progress &&
 287         _heap->in_collection_set(obj) &&
 288         oopDesc::equals_raw(obj, fwd)) {
 289       Thread *t = Thread::current();
 290       if (t->is_GC_task_thread()) {
 291         return _heap->evacuate_object(obj, t);
 292       } else {


< prev index next >