1 /* 2 * Copyright (c) 2013, 2018, Red Hat, Inc. and/or its affiliates. 3 * 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 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 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 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAP_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAP_HPP 26 27 #include "gc/shared/markBitMap.hpp" 28 #include "gc/shared/softRefPolicy.hpp" 29 #include "gc/shared/collectedHeap.hpp" 30 #include "gc/shenandoah/shenandoahHeapLock.hpp" 31 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp" 32 #include "gc/shenandoah/shenandoahSharedVariables.hpp" 33 #include "gc/shenandoah/shenandoahWorkGroup.hpp" 34 #include "services/memoryManager.hpp" 35 36 class ConcurrentGCTimer; 37 class ShenandoahAsserts; 38 class ShenandoahAllocTracker; 39 class ShenandoahCollectorPolicy; 40 class ShenandoahConnectionMatrix; 41 class ShenandoahPhaseTimings; 42 class ShenandoahHeap; 43 class ShenandoahHeapRegion; 44 class ShenandoahHeapRegionClosure; 45 class ShenandoahHeapRegionSet; 46 class ShenandoahCollectionSet; 47 class ShenandoahFreeSet; 48 class ShenandoahConcurrentMark; 49 class ShenandoahMarkCompact; 50 class ShenandoahPartialGC; 51 class ShenandoahPacer; 52 class ShenandoahTraversalGC; 53 class ShenandoahVerifier; 54 class ShenandoahConcurrentThread; 55 class ShenandoahMonitoringSupport; 56 57 class ShenandoahRegionIterator : public StackObj { 58 private: 59 volatile size_t _index; 60 ShenandoahHeap* _heap; 61 public: 62 ShenandoahRegionIterator(); 63 ShenandoahRegionIterator(ShenandoahHeap* heap); 64 65 // Returns next region, or NULL if there are no more regions. 66 // This is multi-thread-safe. 67 inline ShenandoahHeapRegion* next(); 68 69 // This is *not* MT safe. However, in the absence of multithreaded access, it 70 // can be used to determine if there is more work to do. 71 bool has_next() const; 72 }; 73 74 class ShenandoahHeapRegionClosure : public StackObj { 75 public: 76 // typically called on each region until it returns true; 77 virtual bool heap_region_do(ShenandoahHeapRegion* r) = 0; 78 }; 79 80 class ShenandoahUpdateRefsClosure: public OopClosure { 81 private: 82 ShenandoahHeap* _heap; 83 84 template <class T> 85 inline void do_oop_work(T* p); 86 87 public: 88 ShenandoahUpdateRefsClosure(); 89 inline void do_oop(oop* p); 90 inline void do_oop(narrowOop* p); 91 }; 92 93 #ifdef ASSERT 94 class ShenandoahAssertToSpaceClosure : public OopClosure { 95 private: 96 template <class T> 97 void do_oop_nv(T* p); 98 public: 99 void do_oop(narrowOop* p); 100 void do_oop(oop* p); 101 }; 102 #endif 103 104 class ShenandoahAlwaysTrueClosure : public BoolObjectClosure { 105 public: 106 bool do_object_b(oop p) { return true; } 107 }; 108 109 class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure { 110 private: 111 ShenandoahHeap* _heap; 112 public: 113 ShenandoahForwardedIsAliveClosure(); 114 void init(ShenandoahHeap* heap) { 115 _heap = heap; 116 } 117 bool do_object_b(oop obj); 118 }; 119 120 class ShenandoahIsAliveClosure: public BoolObjectClosure { 121 private: 122 ShenandoahHeap* _heap; 123 public: 124 ShenandoahIsAliveClosure(); 125 void init(ShenandoahHeap* heap) { 126 _heap = heap; 127 } 128 bool do_object_b(oop obj); 129 }; 130 131 class VMStructs; 132 133 // // A "ShenandoahHeap" is an implementation of a java heap for HotSpot. 134 // // It uses a new pauseless GC algorithm based on Brooks pointers. 135 // // Derived from G1 136 137 // // 138 // // CollectedHeap 139 // // SharedHeap 140 // // ShenandoahHeap 141 class ShenandoahHeap : public CollectedHeap { 142 friend class ShenandoahAsserts; 143 friend class VMStructs; 144 145 enum CancelState { 146 147 // Normal state. GC has not been cancelled and is open for cancellation. 148 // Worker threads can suspend for safepoint. 149 CANCELLABLE, 150 151 // GC has been cancelled. Worker threads can not suspend for 152 // safepoint but must finish their work as soon as possible. 153 CANCELLED, 154 155 // GC has not been cancelled and must not be cancelled. At least 156 // one worker thread checks for pending safepoint and may suspend 157 // if a safepoint is pending. 158 NOT_CANCELLED 159 160 }; 161 162 public: 163 // GC state describes the important parts of collector state, that may be 164 // used to make barrier selection decisions in the native and generated code. 165 // Multiple bits can be set at once. 166 // 167 // Important invariant: when GC state is zero, the heap is stable, and no barriers 168 // are required. 169 enum GCStateBitPos { 170 // Heap has forwarded objects: need RB, ACMP, CAS barriers. 171 HAS_FORWARDED_BITPOS = 0, 172 173 // Heap is under marking: needs SATB barriers. 174 MARKING_BITPOS = 1, 175 176 // Heap is under evacuation: needs WB barriers. (Set together with UNSTABLE) 177 EVACUATION_BITPOS = 2, 178 179 // Heap is under updating: needs SVRB/SVWB barriers. 180 UPDATEREFS_BITPOS = 3, 181 182 // Heap is under partial collection 183 PARTIAL_BITPOS = 4, 184 185 // Heap is under traversal collection 186 TRAVERSAL_BITPOS = 5, 187 }; 188 189 enum GCState { 190 STABLE = 0, 191 HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS, 192 MARKING = 1 << MARKING_BITPOS, 193 EVACUATION = 1 << EVACUATION_BITPOS, 194 UPDATEREFS = 1 << UPDATEREFS_BITPOS, 195 PARTIAL = 1 << PARTIAL_BITPOS, 196 TRAVERSAL = 1 << TRAVERSAL_BITPOS, 197 }; 198 199 enum ShenandoahDegenPoint { 200 _degenerated_unset, 201 _degenerated_partial, 202 _degenerated_traversal, 203 _degenerated_outside_cycle, 204 _degenerated_mark, 205 _degenerated_evac, 206 _degenerated_updaterefs, 207 _DEGENERATED_LIMIT, 208 }; 209 210 static const char* degen_point_to_string(ShenandoahDegenPoint point) { 211 switch (point) { 212 case _degenerated_unset: 213 return "<UNSET>"; 214 case _degenerated_partial: 215 return "Partial"; 216 case _degenerated_traversal: 217 return "Traversal"; 218 case _degenerated_outside_cycle: 219 return "Outside of Cycle"; 220 case _degenerated_mark: 221 return "Mark"; 222 case _degenerated_evac: 223 return "Evacuation"; 224 case _degenerated_updaterefs: 225 return "Update Refs"; 226 default: 227 ShouldNotReachHere(); 228 return "ERROR"; 229 } 230 }; 231 232 private: 233 ShenandoahSharedBitmap _gc_state; 234 ShenandoahHeapLock _lock; 235 ShenandoahCollectorPolicy* _shenandoah_policy; 236 SoftRefPolicy _soft_ref_policy; 237 size_t _bitmap_size; 238 size_t _bitmap_regions_per_slice; 239 size_t _bitmap_bytes_per_slice; 240 MemRegion _heap_region; 241 MemRegion _bitmap0_region; 242 MemRegion _bitmap1_region; 243 MemRegion _aux_bitmap_region; 244 245 ShenandoahHeapRegion** _regions; 246 ShenandoahFreeSet* _free_set; 247 ShenandoahCollectionSet* _collection_set; 248 249 ShenandoahRegionIterator _update_refs_iterator; 250 251 ShenandoahConcurrentMark* _scm; 252 ShenandoahMarkCompact* _full_gc; 253 ShenandoahPartialGC* _partial_gc; 254 ShenandoahTraversalGC* _traversal_gc; 255 ShenandoahVerifier* _verifier; 256 ShenandoahPacer* _pacer; 257 258 ShenandoahConcurrentThread* _concurrent_gc_thread; 259 260 ShenandoahMonitoringSupport* _monitoring_support; 261 262 ShenandoahPhaseTimings* _phase_timings; 263 ShenandoahAllocTracker* _alloc_tracker; 264 265 size_t _num_regions; 266 size_t _initial_size; 267 268 uint _max_workers; 269 ShenandoahWorkGang* _workers; 270 ShenandoahWorkGang* _safepoint_workers; 271 272 volatile size_t _used; 273 volatile size_t _committed; 274 275 MarkBitMap _verification_bit_map; 276 MarkBitMap _mark_bit_map0; 277 MarkBitMap _mark_bit_map1; 278 MarkBitMap* _complete_mark_bit_map; 279 MarkBitMap* _next_mark_bit_map; 280 MarkBitMap _aux_bit_map; 281 282 HeapWord** _complete_top_at_mark_starts; 283 HeapWord** _complete_top_at_mark_starts_base; 284 285 HeapWord** _next_top_at_mark_starts; 286 HeapWord** _next_top_at_mark_starts_base; 287 288 volatile size_t _bytes_allocated_since_gc_start; 289 290 ShenandoahSharedFlag _degenerated_gc_in_progress; 291 ShenandoahSharedFlag _full_gc_in_progress; 292 ShenandoahSharedFlag _full_gc_move_in_progress; 293 294 ShenandoahSharedFlag _inject_alloc_failure; 295 296 ShenandoahSharedFlag _process_references; 297 ShenandoahSharedFlag _unload_classes; 298 299 ShenandoahSharedEnumFlag<CancelState> _cancelled_concgc; 300 301 ReferenceProcessor* _ref_processor; 302 303 ShenandoahForwardedIsAliveClosure _forwarded_is_alive; 304 ShenandoahIsAliveClosure _is_alive; 305 306 ConcurrentGCTimer* _gc_timer; 307 308 ShenandoahConnectionMatrix* _connection_matrix; 309 310 GCMemoryManager _stw_memory_manager; 311 GCMemoryManager _cycle_memory_manager; 312 313 MemoryPool* _memory_pool; 314 315 ShenandoahEvacOOMHandler _oom_evac_handler; 316 317 #ifdef ASSERT 318 int _heap_expansion_count; 319 #endif 320 321 public: 322 ShenandoahHeap(ShenandoahCollectorPolicy* policy); 323 324 const char* name() const /* override */; 325 HeapWord* allocate_new_tlab(size_t word_size) /* override */; 326 void print_on(outputStream* st) const /* override */; 327 void print_extended_on(outputStream *st) const /* override */; 328 329 ShenandoahHeap::Name kind() const /* override */{ 330 return CollectedHeap::Shenandoah; 331 } 332 333 jint initialize() /* override */; 334 void post_initialize() /* override */; 335 size_t capacity() const /* override */; 336 size_t used() const /* override */; 337 size_t committed() const; 338 bool is_maximal_no_gc() const /* override */; 339 size_t max_capacity() const /* override */; 340 size_t initial_capacity() const /* override */; 341 bool is_in(const void* p) const /* override */; 342 bool is_scavengable(oop obj) /* override */; 343 HeapWord* mem_allocate(size_t size, bool* what) /* override */; 344 bool can_elide_tlab_store_barriers() const /* override */; 345 oop new_store_pre_barrier(JavaThread* thread, oop new_obj) /* override */; 346 bool can_elide_initializing_store_barrier(oop new_obj) /* override */; 347 bool card_mark_must_follow_store() const /* override */; 348 void collect(GCCause::Cause cause) /* override */; 349 void do_full_collection(bool clear_all_soft_refs) /* override */; 350 AdaptiveSizePolicy* size_policy() /* override */; 351 CollectorPolicy* collector_policy() const /* override */; 352 SoftRefPolicy* soft_ref_policy() /* override */; 353 void ensure_parsability(bool retire_tlabs) /* override */; 354 HeapWord* block_start(const void* addr) const /* override */; 355 size_t block_size(const HeapWord* addr) const /* override */; 356 bool block_is_obj(const HeapWord* addr) const /* override */; 357 jlong millis_since_last_gc() /* override */; 358 void prepare_for_verify() /* override */; 359 void print_gc_threads_on(outputStream* st) const /* override */; 360 void gc_threads_do(ThreadClosure* tcl) const /* override */; 361 void print_tracing_info() const /* override */; 362 void verify(VerifyOption vo) /* override */; 363 bool supports_tlab_allocation() const /* override */; 364 size_t tlab_capacity(Thread *thr) const /* override */; 365 void object_iterate(ObjectClosure* cl) /* override */; 366 void safe_object_iterate(ObjectClosure* cl) /* override */; 367 size_t unsafe_max_tlab_alloc(Thread *thread) const /* override */; 368 size_t max_tlab_size() const /* override */; 369 void resize_all_tlabs() /* override */; 370 void accumulate_statistics_all_gclabs() /* override */; 371 HeapWord* tlab_post_allocation_setup(HeapWord* obj) /* override */; 372 uint oop_extra_words() /* override */; 373 size_t tlab_used(Thread* ignored) const /* override */; 374 void stop() /* override */; 375 virtual void safepoint_synchronize_begin(); 376 virtual void safepoint_synchronize_end(); 377 378 WorkGang* get_safepoint_workers() { return _safepoint_workers; } 379 380 #ifndef CC_INTERP 381 void compile_prepare_oop(MacroAssembler* masm, Register obj) /* override */; 382 #endif 383 384 void register_nmethod(nmethod* nm); 385 void unregister_nmethod(nmethod* nm); 386 387 /* override: object pinning support */ 388 bool supports_object_pinning() const { return true; } 389 oop pin_object(JavaThread* thread, oop obj); 390 void unpin_object(JavaThread* thread, oop obj); 391 392 static ShenandoahHeap* heap(); 393 static ShenandoahHeap* heap_no_check(); 394 static address in_cset_fast_test_addr(); 395 static address cancelled_concgc_addr(); 396 static address gc_state_addr(); 397 398 ShenandoahCollectorPolicy *shenandoahPolicy() const { return _shenandoah_policy; } 399 ShenandoahPhaseTimings* phase_timings() const { return _phase_timings; } 400 ShenandoahAllocTracker* alloc_tracker() const { return _alloc_tracker; } 401 402 inline ShenandoahHeapRegion* const heap_region_containing(const void* addr) const; 403 inline size_t heap_region_index_containing(const void* addr) const; 404 inline bool requires_marking(const void* entry) const; 405 406 template <class T> 407 inline oop evac_update_with_forwarded(T* p, bool &evac); 408 409 template <class T> 410 inline oop maybe_update_with_forwarded(T* p); 411 412 template <class T> 413 inline oop maybe_update_with_forwarded_not_null(T* p, oop obj); 414 415 template <class T> 416 inline oop update_with_forwarded_not_null(T* p, oop obj); 417 418 void trash_cset_regions(); 419 420 void stop_concurrent_marking(); 421 422 void prepare_for_concurrent_evacuation(); 423 void evacuate_and_update_roots(); 424 // Fixup roots after concurrent cycle failed 425 void fixup_roots(); 426 427 void update_heap_references(bool concurrent); 428 429 void roots_iterate(OopClosure* cl); 430 431 private: 432 void set_gc_state_all_threads(char state); 433 void set_gc_state_mask(uint mask, bool value); 434 435 public: 436 void set_concurrent_mark_in_progress(bool in_progress); 437 void set_evacuation_in_progress(bool in_progress); 438 void set_update_refs_in_progress(bool in_progress); 439 void set_degenerated_gc_in_progress(bool in_progress); 440 void set_full_gc_in_progress(bool in_progress); 441 void set_full_gc_move_in_progress(bool in_progress); 442 void set_concurrent_partial_in_progress(bool in_progress); 443 void set_concurrent_traversal_in_progress(bool in_progress); 444 void set_has_forwarded_objects(bool cond); 445 446 void set_process_references(bool pr); 447 void set_unload_classes(bool uc); 448 449 inline bool is_stable() const; 450 inline bool is_idle() const; 451 inline bool is_concurrent_mark_in_progress() const; 452 inline bool is_update_refs_in_progress() const; 453 inline bool is_evacuation_in_progress() const; 454 inline bool is_degenerated_gc_in_progress() const; 455 inline bool is_full_gc_in_progress() const; 456 inline bool is_full_gc_move_in_progress() const; 457 inline bool is_concurrent_partial_in_progress() const; 458 inline bool is_concurrent_traversal_in_progress() const; 459 inline bool has_forwarded_objects() const; 460 inline bool is_gc_in_progress_mask(uint mask) const; 461 462 char gc_state() const; 463 464 bool process_references() const; 465 bool unload_classes() const; 466 467 inline bool region_in_collection_set(size_t region_index) const; 468 469 // Mainly there to avoid accidentally calling the templated 470 // method below with ShenandoahHeapRegion* which would be *wrong*. 471 inline bool in_collection_set(ShenandoahHeapRegion* r) const; 472 473 template <class T> 474 inline bool in_collection_set(T obj) const; 475 476 inline bool allocated_after_next_mark_start(HeapWord* addr) const; 477 void set_next_top_at_mark_start(HeapWord* region_base, HeapWord* addr); 478 HeapWord* next_top_at_mark_start(HeapWord* region_base); 479 480 inline bool allocated_after_complete_mark_start(HeapWord* addr) const; 481 void set_complete_top_at_mark_start(HeapWord* region_base, HeapWord* addr); 482 HeapWord* complete_top_at_mark_start(HeapWord* region_base); 483 484 // Evacuates object src. Returns the evacuated object if this thread 485 // succeeded, otherwise rolls back the evacuation and returns the 486 // evacuated object by the competing thread. 'succeeded' is an out 487 // param and set to true if this thread succeeded, otherwise to false. 488 inline oop evacuate_object(oop src, Thread* thread, bool& evacuated); 489 inline bool cancelled_concgc() const; 490 inline bool check_cancelled_concgc_and_yield(bool sts_active = true); 491 inline bool try_cancel_concgc(); 492 inline void clear_cancelled_concgc(); 493 494 inline ShenandoahHeapRegion* const get_region(size_t region_idx) const; 495 ShenandoahRegionIterator region_iterator() const; 496 void heap_region_iterate(ShenandoahHeapRegionClosure& cl) const; 497 498 ShenandoahFreeSet* free_set() const { return _free_set; } 499 ShenandoahCollectionSet* collection_set() const { return _collection_set; } 500 501 ShenandoahConnectionMatrix* connection_matrix() const; 502 503 void increase_used(size_t bytes); 504 void decrease_used(size_t bytes); 505 506 void set_used(size_t bytes); 507 508 void increase_committed(size_t bytes); 509 void decrease_committed(size_t bytes); 510 511 void increase_allocated(size_t bytes); 512 513 void notify_alloc(size_t words, bool waste); 514 515 void handle_heap_shrinkage(double shrink_before); 516 517 void reset_next_mark_bitmap(); 518 519 MarkBitMap* complete_mark_bit_map(); 520 MarkBitMap* next_mark_bit_map(); 521 inline bool is_marked_complete(oop obj) const; 522 inline bool mark_next(oop obj) const; 523 inline bool is_marked_next(oop obj) const; 524 bool is_next_bitmap_clear(); 525 bool is_next_bitmap_clear_range(HeapWord* start, HeapWord* end); 526 bool is_complete_bitmap_clear_range(HeapWord* start, HeapWord* end); 527 528 bool commit_bitmap_slice(ShenandoahHeapRegion *r); 529 bool uncommit_bitmap_slice(ShenandoahHeapRegion *r); 530 531 // Hint that the bitmap slice is not needed 532 bool idle_bitmap_slice(ShenandoahHeapRegion* r); 533 void activate_bitmap_slice(ShenandoahHeapRegion* r); 534 535 bool is_bitmap_slice_committed(ShenandoahHeapRegion* r, bool skip_self = false); 536 537 void print_heap_regions_on(outputStream* st) const; 538 539 size_t bytes_allocated_since_gc_start(); 540 void reset_bytes_allocated_since_gc_start(); 541 542 void trash_humongous_region_at(ShenandoahHeapRegion *r); 543 544 virtual GrowableArray<GCMemoryManager*> memory_managers(); 545 virtual GrowableArray<MemoryPool*> memory_pools(); 546 547 ShenandoahMonitoringSupport* monitoring_support(); 548 ShenandoahConcurrentMark* concurrentMark() { return _scm; } 549 ShenandoahMarkCompact* full_gc() { return _full_gc; } 550 ShenandoahPartialGC* partial_gc(); 551 ShenandoahTraversalGC* traversal_gc(); 552 ShenandoahVerifier* verifier(); 553 ShenandoahPacer* pacer() const; 554 555 ReferenceProcessor* ref_processor() { return _ref_processor;} 556 557 WorkGang* workers() const { return _workers;} 558 559 uint max_workers(); 560 561 void assert_gc_workers(uint nworker) PRODUCT_RETURN; 562 563 void do_evacuation(); 564 ShenandoahHeapRegion* next_compaction_region(const ShenandoahHeapRegion* r); 565 566 void heap_region_iterate(ShenandoahHeapRegionClosure* blk, bool skip_cset_regions = false, bool skip_humongous_continuation = false) const; 567 568 // Delete entries for dead interned string and clean up unreferenced symbols 569 // in symbol table, possibly in parallel. 570 void unload_classes_and_cleanup_tables(bool full_gc); 571 572 inline size_t num_regions() const { return _num_regions; } 573 574 BoolObjectClosure* is_alive_closure(); 575 576 // Call before starting evacuation. 577 void enter_evacuation(); 578 // Call after finished with evacuation. 579 void leave_evacuation(); 580 581 private: 582 template<class T> 583 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 584 585 template<class T> 586 inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 587 588 public: 589 template<class T> 590 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl); 591 592 template<class T> 593 inline void marked_object_safe_iterate(ShenandoahHeapRegion* region, T* cl); 594 595 template<class T> 596 inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl); 597 598 template<class T> 599 inline void marked_object_oop_safe_iterate(ShenandoahHeapRegion* region, T* cl); 600 601 GCTimer* gc_timer() const; 602 603 void swap_mark_bitmaps(); 604 605 void cancel_concgc(GCCause::Cause cause); 606 607 ShenandoahHeapLock* lock() { return &_lock; } 608 void assert_heaplock_owned_by_current_thread() PRODUCT_RETURN; 609 void assert_heaplock_not_owned_by_current_thread() PRODUCT_RETURN; 610 void assert_heaplock_or_safepoint() PRODUCT_RETURN; 611 612 public: 613 typedef enum { 614 _alloc_shared, // Allocate common, outside of TLAB 615 _alloc_shared_gc, // Allocate common, outside of GCLAB 616 _alloc_tlab, // Allocate TLAB 617 _alloc_gclab, // Allocate GCLAB 618 _ALLOC_LIMIT, 619 } AllocType; 620 621 static const char* alloc_type_to_string(AllocType type) { 622 switch (type) { 623 case _alloc_shared: 624 return "Shared"; 625 case _alloc_shared_gc: 626 return "Shared GC"; 627 case _alloc_tlab: 628 return "TLAB"; 629 case _alloc_gclab: 630 return "GCLAB"; 631 default: 632 ShouldNotReachHere(); 633 return ""; 634 } 635 } 636 private: 637 638 virtual void initialize_serviceability(); 639 640 HeapWord* allocate_new_lab(size_t word_size, AllocType type); 641 HeapWord* allocate_memory_under_lock(size_t word_size, AllocType type, bool &new_region); 642 HeapWord* allocate_memory(size_t word_size, AllocType type); 643 // Shenandoah functionality. 644 inline HeapWord* allocate_from_gclab(Thread* thread, size_t size); 645 HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size); 646 HeapWord* allocate_new_gclab(size_t word_size); 647 648 template<class T> 649 inline void do_object_marked_complete(T* cl, oop obj); 650 651 ShenandoahConcurrentThread* concurrent_thread() { return _concurrent_gc_thread; } 652 653 public: 654 inline oop atomic_compare_exchange_oop(oop n, narrowOop* addr, oop c); 655 inline oop atomic_compare_exchange_oop(oop n, oop* addr, oop c); 656 657 private: 658 void ref_processing_init(); 659 660 GCTracer* tracer(); 661 662 private: 663 uint64_t _alloc_seq_at_last_gc_start; 664 uint64_t _alloc_seq_at_last_gc_end; 665 size_t _used_at_last_gc; 666 667 public: 668 uint64_t alloc_seq_at_last_gc_end() const { return _alloc_seq_at_last_gc_end; } 669 uint64_t alloc_seq_at_last_gc_start() const { return _alloc_seq_at_last_gc_start;} 670 size_t used_at_last_gc() const { return _used_at_last_gc;} 671 672 void set_alloc_seq_gc_start(); 673 void set_alloc_seq_gc_end(); 674 675 void set_used_at_last_gc() {_used_at_last_gc = used();} 676 677 void make_tlabs_parsable(bool retire_tlabs) /* override */; 678 679 GCMemoryManager* cycle_memory_manager() { return &_cycle_memory_manager; } 680 GCMemoryManager* stw_memory_manager() { return &_stw_memory_manager; } 681 682 public: 683 // Entry points to STW GC operations, these cause a related safepoint, that then 684 // call the entry method below 685 void vmop_entry_init_mark(); 686 void vmop_entry_final_mark(); 687 void vmop_entry_final_evac(); 688 void vmop_entry_init_updaterefs(); 689 void vmop_entry_final_updaterefs(); 690 void vmop_entry_init_partial(); 691 void vmop_entry_final_partial(); 692 void vmop_entry_init_traversal(); 693 void vmop_entry_final_traversal(); 694 void vmop_entry_full(GCCause::Cause cause); 695 void vmop_degenerated(ShenandoahDegenPoint point); 696 697 // Entry methods to normally STW GC operations. These set up logging, monitoring 698 // and workers for net VM operation 699 void entry_init_mark(); 700 void entry_final_mark(); 701 void entry_final_evac(); 702 void entry_init_updaterefs(); 703 void entry_final_updaterefs(); 704 void entry_init_partial(); 705 void entry_final_partial(); 706 void entry_init_traversal(); 707 void entry_final_traversal(); 708 void entry_full(GCCause::Cause cause); 709 void entry_degenerated(int point); 710 711 // Entry methods to normally concurrent GC operations. These set up logging, monitoring 712 // for concurrent operation. 713 void entry_mark(); 714 void entry_preclean(); 715 void entry_cleanup(); 716 void entry_cleanup_bitmaps(); 717 void entry_evac(); 718 void entry_updaterefs(); 719 void entry_partial(); 720 void entry_traversal(); 721 722 private: 723 // Actual work for the phases 724 void op_init_mark(); 725 void op_final_mark(); 726 void op_final_evac(); 727 void op_init_updaterefs(); 728 void op_final_updaterefs(); 729 void op_init_partial(); 730 void op_final_partial(); 731 void op_init_traversal(); 732 void op_final_traversal(); 733 void op_full(GCCause::Cause cause); 734 void op_degenerated(ShenandoahDegenPoint point); 735 void op_degenerated_fail(); 736 void op_degenerated_futile(); 737 738 void op_mark(); 739 void op_preclean(); 740 void op_cleanup(); 741 void op_evac(); 742 void op_updaterefs(); 743 void op_cleanup_bitmaps(); 744 void op_partial(); 745 void op_traversal(); 746 747 private: 748 void try_inject_alloc_failure(); 749 bool should_inject_alloc_failure(); 750 }; 751 752 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAP_HPP