< prev index next >

src/share/vm/gc/shenandoah/shenandoahHeap.cpp

Print this page
rev 12117 : Pin regions that contain JNI critical regions, instead of bail-and-retry protocol.


  22  */
  23 
  24 #include "memory/allocation.hpp"
  25 #include "gc/g1/heapRegionBounds.inline.hpp"
  26 
  27 #include "gc/shared/gcTimer.hpp"
  28 #include "gc/shared/gcTraceTime.inline.hpp"
  29 #include "gc/shared/parallelCleaning.hpp"
  30 
  31 #include "gc/shenandoah/brooksPointer.hpp"
  32 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  33 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
  34 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  35 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
  36 #include "gc/shenandoah/shenandoahConcurrentThread.hpp"
  37 #include "gc/shenandoah/shenandoahFreeSet.hpp"
  38 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  39 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  40 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
  41 #include "gc/shenandoah/shenandoahHumongous.hpp"
  42 #include "gc/shenandoah/shenandoahJNICritical.hpp"
  43 #include "gc/shenandoah/shenandoahMarkCompact.hpp"
  44 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
  45 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
  46 #include "gc/shenandoah/vm_operations_shenandoah.hpp"
  47 
  48 #include "runtime/vmThread.hpp"
  49 
  50 const char* ShenandoahHeap::name() const {
  51   return "Shenandoah";
  52 }
  53 
  54 void ShenandoahHeap::print_heap_locations(HeapWord* start, HeapWord* end) {
  55   HeapWord* cur = NULL;
  56   for (cur = start; cur < end; cur++) {
  57     tty->print_cr(PTR_FORMAT" : "PTR_FORMAT, p2i(cur), p2i(*((HeapWord**) cur)));
  58   }
  59 }
  60 
  61 class PrintHeapRegionsClosure : public
  62    ShenandoahHeapRegionClosure {


 195   _free_regions(NULL),
 196   _collection_set(NULL),
 197   _bytes_allocated_since_cm(0),
 198   _bytes_allocated_during_cm(0),
 199   _max_allocated_gc(0),
 200   _allocated_last_gc(0),
 201   _used_start_gc(0),
 202   _max_conc_workers((int) MAX2((uint) ConcGCThreads, 1U)),
 203   _max_parallel_workers((int) MAX2((uint) ParallelGCThreads, 1U)),
 204   _ref_processor(NULL),
 205   _in_cset_fast_test(NULL),
 206   _in_cset_fast_test_base(NULL),
 207   _top_at_mark_starts(NULL),
 208   _top_at_mark_starts_base(NULL),
 209   _mark_bit_map0(),
 210   _mark_bit_map1(),
 211   _cancelled_concgc(false),
 212   _need_update_refs(false),
 213   _need_reset_bitmaps(false),
 214   _growing_heap(0),
 215   _jni_critical(new ShenandoahJNICritical()),
 216   _gc_timer(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer())
 217 
 218 {
 219   if (ShenandoahLogConfig) {
 220     tty->print_cr("Parallel GC threads: "UINT32_FORMAT, ParallelGCThreads);
 221     tty->print_cr("Concurrent GC threads: "UINT32_FORMAT, ConcGCThreads);
 222     tty->print_cr("Parallel reference processing enabled: %s", BOOL_TO_STR(ParallelRefProcEnabled));
 223   }
 224   _scm = new ShenandoahConcurrentMark();
 225   _used = 0;
 226   // This is odd.  They are concurrent gc threads, but they are also task threads.
 227   // Framework doesn't allow both.
 228   _workers = new WorkGang("Parallel GC Threads", ParallelGCThreads,
 229                             /* are_GC_task_threads */true,
 230                             /* are_ConcurrentGC_threads */false);
 231   _conc_workers = new WorkGang("Concurrent GC Threads", ConcGCThreads,
 232                             /* are_GC_task_threads */true,
 233                             /* are_ConcurrentGC_threads */false);
 234   if ((_workers == NULL) || (_conc_workers == NULL)) {
 235     vm_exit_during_initialization("Failed necessary allocation.");


1397 }
1398 
1399 bool  ShenandoahHeap::can_elide_tlab_store_barriers() const {
1400   return true;
1401 }
1402 
1403 oop ShenandoahHeap::new_store_pre_barrier(JavaThread* thread, oop new_obj) {
1404   // Overridden to do nothing.
1405   return new_obj;
1406 }
1407 
1408 bool  ShenandoahHeap::can_elide_initializing_store_barrier(oop new_obj) {
1409   return true;
1410 }
1411 
1412 bool ShenandoahHeap::card_mark_must_follow_store() const {
1413   return false;
1414 }
1415 
1416 void ShenandoahHeap::collect(GCCause::Cause cause) {

1417   if (GCCause::is_user_requested_gc(cause)) {
1418     if (! DisableExplicitGC) {
1419       cancel_concgc();
1420       _concurrent_gc_thread->do_full_gc(cause);
1421     }
1422   } else if (cause == GCCause::_allocation_failure) {
1423 
1424     cancel_concgc();
1425     collector_policy()->set_should_clear_all_soft_refs(true);
1426       _concurrent_gc_thread->do_full_gc(cause);
1427 
1428   } else if (cause == GCCause::_gc_locker) {
1429 
1430     if (ShenandoahTraceJNICritical) {
1431       tty->print_cr("Resuming deferred evacuation after JNI critical regions");
1432     }
1433 
1434     jni_critical()->notify_jni_critical();
1435   }
1436 }
1437 
1438 void ShenandoahHeap::do_full_collection(bool clear_all_soft_refs) {
1439   //assert(false, "Shouldn't need to do full collections");
1440 }
1441 
1442 AdaptiveSizePolicy* ShenandoahHeap::size_policy() {
1443   Unimplemented();
1444   return NULL;
1445 
1446 }
1447 
1448 CollectorPolicy* ShenandoahHeap::collector_policy() const {
1449   return _shenandoah_policy;
1450 }
1451 
1452 
1453 HeapWord* ShenandoahHeap::block_start(const void* addr) const {
1454   Space* sp = heap_region_containing(addr);


2069   // to terminate, which would otherwise block until all GC threads come to finish normally.
2070   _cancelled_concgc = true;
2071   _concurrent_gc_thread->stop();
2072   cancel_concgc();
2073 }
2074 
2075 void ShenandoahHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) {
2076 
2077   StringSymbolTableUnlinkTask shenandoah_unlink_task(is_alive, process_strings, process_symbols);
2078   workers()->run_task(&shenandoah_unlink_task);
2079 
2080   //  if (G1StringDedup::is_enabled()) {
2081   //    G1StringDedup::unlink(is_alive);
2082   //  }
2083 }
2084 
2085 void ShenandoahHeap::set_need_update_refs(bool need_update_refs) {
2086   _need_update_refs = need_update_refs;
2087 }
2088 
2089 ShenandoahJNICritical* ShenandoahHeap::jni_critical() {
2090   return _jni_critical;
2091 }
2092 
2093 //fixme this should be in heapregionset
2094 ShenandoahHeapRegion* ShenandoahHeap::next_compaction_region(const ShenandoahHeapRegion* r) {
2095   size_t region_idx = r->region_number() + 1;
2096   ShenandoahHeapRegion* next = _ordered_regions->get(region_idx);
2097   guarantee(next->region_number() == region_idx, "region number must match");
2098   while (next->is_humongous()) {
2099     region_idx = next->region_number() + 1;
2100     next = _ordered_regions->get(region_idx);
2101     guarantee(next->region_number() == region_idx, "region number must match");
2102   }
2103   return next;
2104 }
2105 
2106 bool ShenandoahHeap::is_in_collection_set(const void* p) {
2107   return heap_region_containing(p)->is_in_collection_set();
2108 }
2109 
2110 ShenandoahMonitoringSupport* ShenandoahHeap::monitoring_support() {
2111   return _monitoring_support;
2112 }


2203     }
2204   }
2205 
2206 public:
2207   void do_oop(oop* o) {
2208     do_oop_work(o);
2209   }
2210   void do_oop(narrowOop* o) {
2211     do_oop_work(o);
2212   }
2213 };
2214 
2215 void ShenandoahHeap::register_nmethod(nmethod* nm) {
2216   NMethodOopInitializer init;
2217   nm->oops_do(&init);
2218   nm->fix_oop_relocations();
2219 }
2220 
2221 void ShenandoahHeap::unregister_nmethod(nmethod* nm) {
2222 }









2223 
2224 GCTimer* ShenandoahHeap::gc_timer() const {
2225   return _gc_timer;
2226 }


  22  */
  23 
  24 #include "memory/allocation.hpp"
  25 #include "gc/g1/heapRegionBounds.inline.hpp"
  26 
  27 #include "gc/shared/gcTimer.hpp"
  28 #include "gc/shared/gcTraceTime.inline.hpp"
  29 #include "gc/shared/parallelCleaning.hpp"
  30 
  31 #include "gc/shenandoah/brooksPointer.hpp"
  32 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  33 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
  34 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  35 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
  36 #include "gc/shenandoah/shenandoahConcurrentThread.hpp"
  37 #include "gc/shenandoah/shenandoahFreeSet.hpp"
  38 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  39 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  40 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
  41 #include "gc/shenandoah/shenandoahHumongous.hpp"

  42 #include "gc/shenandoah/shenandoahMarkCompact.hpp"
  43 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
  44 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
  45 #include "gc/shenandoah/vm_operations_shenandoah.hpp"
  46 
  47 #include "runtime/vmThread.hpp"
  48 
  49 const char* ShenandoahHeap::name() const {
  50   return "Shenandoah";
  51 }
  52 
  53 void ShenandoahHeap::print_heap_locations(HeapWord* start, HeapWord* end) {
  54   HeapWord* cur = NULL;
  55   for (cur = start; cur < end; cur++) {
  56     tty->print_cr(PTR_FORMAT" : "PTR_FORMAT, p2i(cur), p2i(*((HeapWord**) cur)));
  57   }
  58 }
  59 
  60 class PrintHeapRegionsClosure : public
  61    ShenandoahHeapRegionClosure {


 194   _free_regions(NULL),
 195   _collection_set(NULL),
 196   _bytes_allocated_since_cm(0),
 197   _bytes_allocated_during_cm(0),
 198   _max_allocated_gc(0),
 199   _allocated_last_gc(0),
 200   _used_start_gc(0),
 201   _max_conc_workers((int) MAX2((uint) ConcGCThreads, 1U)),
 202   _max_parallel_workers((int) MAX2((uint) ParallelGCThreads, 1U)),
 203   _ref_processor(NULL),
 204   _in_cset_fast_test(NULL),
 205   _in_cset_fast_test_base(NULL),
 206   _top_at_mark_starts(NULL),
 207   _top_at_mark_starts_base(NULL),
 208   _mark_bit_map0(),
 209   _mark_bit_map1(),
 210   _cancelled_concgc(false),
 211   _need_update_refs(false),
 212   _need_reset_bitmaps(false),
 213   _growing_heap(0),

 214   _gc_timer(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer())
 215 
 216 {
 217   if (ShenandoahLogConfig) {
 218     tty->print_cr("Parallel GC threads: "UINT32_FORMAT, ParallelGCThreads);
 219     tty->print_cr("Concurrent GC threads: "UINT32_FORMAT, ConcGCThreads);
 220     tty->print_cr("Parallel reference processing enabled: %s", BOOL_TO_STR(ParallelRefProcEnabled));
 221   }
 222   _scm = new ShenandoahConcurrentMark();
 223   _used = 0;
 224   // This is odd.  They are concurrent gc threads, but they are also task threads.
 225   // Framework doesn't allow both.
 226   _workers = new WorkGang("Parallel GC Threads", ParallelGCThreads,
 227                             /* are_GC_task_threads */true,
 228                             /* are_ConcurrentGC_threads */false);
 229   _conc_workers = new WorkGang("Concurrent GC Threads", ConcGCThreads,
 230                             /* are_GC_task_threads */true,
 231                             /* are_ConcurrentGC_threads */false);
 232   if ((_workers == NULL) || (_conc_workers == NULL)) {
 233     vm_exit_during_initialization("Failed necessary allocation.");


1395 }
1396 
1397 bool  ShenandoahHeap::can_elide_tlab_store_barriers() const {
1398   return true;
1399 }
1400 
1401 oop ShenandoahHeap::new_store_pre_barrier(JavaThread* thread, oop new_obj) {
1402   // Overridden to do nothing.
1403   return new_obj;
1404 }
1405 
1406 bool  ShenandoahHeap::can_elide_initializing_store_barrier(oop new_obj) {
1407   return true;
1408 }
1409 
1410 bool ShenandoahHeap::card_mark_must_follow_store() const {
1411   return false;
1412 }
1413 
1414 void ShenandoahHeap::collect(GCCause::Cause cause) {
1415   assert(cause != GCCause::_gc_locker, "no JNI critical callback");
1416   if (GCCause::is_user_requested_gc(cause)) {
1417     if (! DisableExplicitGC) {
1418       cancel_concgc();
1419       _concurrent_gc_thread->do_full_gc(cause);
1420     }
1421   } else if (cause == GCCause::_allocation_failure) {
1422 
1423     cancel_concgc();
1424     collector_policy()->set_should_clear_all_soft_refs(true);
1425       _concurrent_gc_thread->do_full_gc(cause);
1426 







1427   }
1428 }
1429 
1430 void ShenandoahHeap::do_full_collection(bool clear_all_soft_refs) {
1431   //assert(false, "Shouldn't need to do full collections");
1432 }
1433 
1434 AdaptiveSizePolicy* ShenandoahHeap::size_policy() {
1435   Unimplemented();
1436   return NULL;
1437 
1438 }
1439 
1440 CollectorPolicy* ShenandoahHeap::collector_policy() const {
1441   return _shenandoah_policy;
1442 }
1443 
1444 
1445 HeapWord* ShenandoahHeap::block_start(const void* addr) const {
1446   Space* sp = heap_region_containing(addr);


2061   // to terminate, which would otherwise block until all GC threads come to finish normally.
2062   _cancelled_concgc = true;
2063   _concurrent_gc_thread->stop();
2064   cancel_concgc();
2065 }
2066 
2067 void ShenandoahHeap::unlink_string_and_symbol_table(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) {
2068 
2069   StringSymbolTableUnlinkTask shenandoah_unlink_task(is_alive, process_strings, process_symbols);
2070   workers()->run_task(&shenandoah_unlink_task);
2071 
2072   //  if (G1StringDedup::is_enabled()) {
2073   //    G1StringDedup::unlink(is_alive);
2074   //  }
2075 }
2076 
2077 void ShenandoahHeap::set_need_update_refs(bool need_update_refs) {
2078   _need_update_refs = need_update_refs;
2079 }
2080 




2081 //fixme this should be in heapregionset
2082 ShenandoahHeapRegion* ShenandoahHeap::next_compaction_region(const ShenandoahHeapRegion* r) {
2083   size_t region_idx = r->region_number() + 1;
2084   ShenandoahHeapRegion* next = _ordered_regions->get(region_idx);
2085   guarantee(next->region_number() == region_idx, "region number must match");
2086   while (next->is_humongous()) {
2087     region_idx = next->region_number() + 1;
2088     next = _ordered_regions->get(region_idx);
2089     guarantee(next->region_number() == region_idx, "region number must match");
2090   }
2091   return next;
2092 }
2093 
2094 bool ShenandoahHeap::is_in_collection_set(const void* p) {
2095   return heap_region_containing(p)->is_in_collection_set();
2096 }
2097 
2098 ShenandoahMonitoringSupport* ShenandoahHeap::monitoring_support() {
2099   return _monitoring_support;
2100 }


2191     }
2192   }
2193 
2194 public:
2195   void do_oop(oop* o) {
2196     do_oop_work(o);
2197   }
2198   void do_oop(narrowOop* o) {
2199     do_oop_work(o);
2200   }
2201 };
2202 
2203 void ShenandoahHeap::register_nmethod(nmethod* nm) {
2204   NMethodOopInitializer init;
2205   nm->oops_do(&init);
2206   nm->fix_oop_relocations();
2207 }
2208 
2209 void ShenandoahHeap::unregister_nmethod(nmethod* nm) {
2210 }
2211 
2212 void ShenandoahHeap::enter_critical(oop o) {
2213   heap_region_containing(o)->enter_critical();
2214 }
2215 
2216 void ShenandoahHeap::exit_critical(oop o) {
2217   heap_region_containing(o)->exit_critical();
2218 }
2219 
2220 
2221 GCTimer* ShenandoahHeap::gc_timer() const {
2222   return _gc_timer;
2223 }
< prev index next >