1 /* 2 * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved. 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_GC_SHENANDOAH_SHENANDOAHHEAP_HPP 25 #define SHARE_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/shenandoahAsserts.hpp" 31 #include "gc/shenandoah/shenandoahAllocRequest.hpp" 32 #include "gc/shenandoah/shenandoahHeapLock.hpp" 33 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp" 34 #include "gc/shenandoah/shenandoahSharedVariables.hpp" 35 #include "services/memoryManager.hpp" 36 37 class ConcurrentGCTimer; 38 class ReferenceProcessor; 39 class ShenandoahAllocTracker; 40 class ShenandoahCollectorPolicy; 41 class ShenandoahControlThread; 42 class ShenandoahGCSession; 43 class ShenandoahHeuristics; 44 class ShenandoahMarkingContext; 45 class ShenandoahPhaseTimings; 46 class ShenandoahHeap; 47 class ShenandoahHeapRegion; 48 class ShenandoahHeapRegionClosure; 49 class ShenandoahCollectionSet; 50 class ShenandoahFreeSet; 51 class ShenandoahConcurrentMark; 52 class ShenandoahMarkCompact; 53 class ShenandoahMonitoringSupport; 54 class ShenandoahPacer; 55 class ShenandoahTraversalGC; 56 class ShenandoahVerifier; 57 class ShenandoahWorkGang; 58 class VMStructs; 59 60 class ShenandoahRegionIterator : public StackObj { 61 private: 62 ShenandoahHeap* _heap; 63 64 DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile size_t)); 65 volatile size_t _index; 66 DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0); 67 68 // No implicit copying: iterators should be passed by reference to capture the state 69 ShenandoahRegionIterator(const ShenandoahRegionIterator& that); 70 ShenandoahRegionIterator& operator=(const ShenandoahRegionIterator& o); 71 72 public: 73 ShenandoahRegionIterator(); 74 ShenandoahRegionIterator(ShenandoahHeap* heap); 75 76 // Reset iterator to default state 77 void reset(); 78 79 // Returns next region, or NULL if there are no more regions. 80 // This is multi-thread-safe. 81 inline ShenandoahHeapRegion* next(); 82 83 // This is *not* MT safe. However, in the absence of multithreaded access, it 84 // can be used to determine if there is more work to do. 85 bool has_next() const; 86 }; 87 88 class ShenandoahHeapRegionClosure : public StackObj { 89 public: 90 virtual void heap_region_do(ShenandoahHeapRegion* r) = 0; 91 virtual bool is_thread_safe() { return false; } 92 }; 93 94 #ifdef ASSERT 95 class ShenandoahAssertToSpaceClosure : public OopClosure { 96 private: 97 template <class T> 98 void do_oop_work(T* p); 99 public: 100 void do_oop(narrowOop* p); 101 void do_oop(oop* p); 102 }; 103 #endif 104 105 106 // Shenandoah GC is low-pause concurrent GC that uses Brooks forwarding pointers 107 // to encode forwarding data. See BrooksPointer for details on forwarding data encoding. 108 // See ShenandoahControlThread for GC cycle structure. 109 // 110 class ShenandoahHeap : public CollectedHeap { 111 friend class ShenandoahAsserts; 112 friend class VMStructs; 113 friend class ShenandoahGCSession; 114 115 // ---------- Locks that guard important data structures in Heap 116 // 117 private: 118 ShenandoahHeapLock _lock; 119 120 public: 121 ShenandoahHeapLock* lock() { 122 return &_lock; 123 } 124 125 void assert_heaplock_owned_by_current_thread() NOT_DEBUG_RETURN; 126 void assert_heaplock_not_owned_by_current_thread() NOT_DEBUG_RETURN; 127 void assert_heaplock_or_safepoint() NOT_DEBUG_RETURN; 128 129 // ---------- Initialization, termination, identification, printing routines 130 // 131 public: 132 static ShenandoahHeap* heap(); 133 static ShenandoahHeap* heap_no_check(); 134 135 const char* name() const { return "Shenandoah"; } 136 ShenandoahHeap::Name kind() const { return CollectedHeap::Shenandoah; } 137 138 ShenandoahHeap(ShenandoahCollectorPolicy* policy); 139 jint initialize(); 140 void post_initialize(); 141 void initialize_heuristics(); 142 143 void initialize_serviceability(); 144 145 void print_on(outputStream* st) const; 146 void print_extended_on(outputStream *st) const; 147 void print_tracing_info() const; 148 void print_gc_threads_on(outputStream* st) const; 149 void print_heap_regions_on(outputStream* st) const; 150 151 void stop(); 152 153 void prepare_for_verify(); 154 void verify(VerifyOption vo); 155 156 // ---------- Heap counters and metrics 157 // 158 private: 159 size_t _initial_size; 160 size_t _minimum_size; 161 DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile size_t)); 162 volatile size_t _used; 163 volatile size_t _committed; 164 volatile size_t _bytes_allocated_since_gc_start; 165 DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0); 166 167 public: 168 void increase_used(size_t bytes); 169 void decrease_used(size_t bytes); 170 void set_used(size_t bytes); 171 172 void increase_committed(size_t bytes); 173 void decrease_committed(size_t bytes); 174 void increase_allocated(size_t bytes); 175 176 size_t bytes_allocated_since_gc_start(); 177 void reset_bytes_allocated_since_gc_start(); 178 179 size_t min_capacity() const; 180 size_t max_capacity() const; 181 size_t initial_capacity() const; 182 size_t capacity() const; 183 size_t used() const; 184 size_t committed() const; 185 186 // ---------- Workers handling 187 // 188 private: 189 uint _max_workers; 190 ShenandoahWorkGang* _workers; 191 ShenandoahWorkGang* _safepoint_workers; 192 193 public: 194 uint max_workers(); 195 void assert_gc_workers(uint nworker) NOT_DEBUG_RETURN; 196 197 WorkGang* workers() const; 198 WorkGang* get_safepoint_workers(); 199 200 void gc_threads_do(ThreadClosure* tcl) const; 201 202 // ---------- Heap regions handling machinery 203 // 204 private: 205 MemRegion _heap_region; 206 bool _heap_region_special; 207 size_t _num_regions; 208 ShenandoahHeapRegion** _regions; 209 ShenandoahRegionIterator _update_refs_iterator; 210 211 public: 212 inline size_t num_regions() const { return _num_regions; } 213 inline bool is_heap_region_special() { return _heap_region_special; } 214 215 inline ShenandoahHeapRegion* const heap_region_containing(const void* addr) const; 216 inline size_t heap_region_index_containing(const void* addr) const; 217 218 inline ShenandoahHeapRegion* const get_region(size_t region_idx) const; 219 220 void heap_region_iterate(ShenandoahHeapRegionClosure* blk) const; 221 void parallel_heap_region_iterate(ShenandoahHeapRegionClosure* blk) const; 222 223 // ---------- GC state machinery 224 // 225 // GC state describes the important parts of collector state, that may be 226 // used to make barrier selection decisions in the native and generated code. 227 // Multiple bits can be set at once. 228 // 229 // Important invariant: when GC state is zero, the heap is stable, and no barriers 230 // are required. 231 // 232 public: 233 enum GCStateBitPos { 234 // Heap has forwarded objects: needs LRB barriers. 235 HAS_FORWARDED_BITPOS = 0, 236 237 // Heap is under marking: needs SATB barriers. 238 MARKING_BITPOS = 1, 239 240 // Heap is under evacuation: needs LRB barriers. (Set together with HAS_FORWARDED) 241 EVACUATION_BITPOS = 2, 242 243 // Heap is under updating: needs no additional barriers. 244 UPDATEREFS_BITPOS = 3, 245 246 // Heap is under traversal collection 247 TRAVERSAL_BITPOS = 4, 248 }; 249 250 enum GCState { 251 STABLE = 0, 252 HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS, 253 MARKING = 1 << MARKING_BITPOS, 254 EVACUATION = 1 << EVACUATION_BITPOS, 255 UPDATEREFS = 1 << UPDATEREFS_BITPOS, 256 TRAVERSAL = 1 << TRAVERSAL_BITPOS, 257 }; 258 259 private: 260 ShenandoahSharedBitmap _gc_state; 261 ShenandoahSharedFlag _degenerated_gc_in_progress; 262 ShenandoahSharedFlag _full_gc_in_progress; 263 ShenandoahSharedFlag _full_gc_move_in_progress; 264 ShenandoahSharedFlag _progress_last_gc; 265 266 void set_gc_state_all_threads(char state); 267 void set_gc_state_mask(uint mask, bool value); 268 269 public: 270 char gc_state() const; 271 static address gc_state_addr(); 272 273 void set_concurrent_mark_in_progress(bool in_progress); 274 void set_evacuation_in_progress(bool in_progress); 275 void set_update_refs_in_progress(bool in_progress); 276 void set_degenerated_gc_in_progress(bool in_progress); 277 void set_full_gc_in_progress(bool in_progress); 278 void set_full_gc_move_in_progress(bool in_progress); 279 void set_concurrent_traversal_in_progress(bool in_progress); 280 void set_has_forwarded_objects(bool cond); 281 282 inline bool is_stable() const; 283 inline bool is_idle() const; 284 inline bool is_concurrent_mark_in_progress() const; 285 inline bool is_update_refs_in_progress() const; 286 inline bool is_evacuation_in_progress() const; 287 inline bool is_degenerated_gc_in_progress() const; 288 inline bool is_full_gc_in_progress() const; 289 inline bool is_full_gc_move_in_progress() const; 290 inline bool is_concurrent_traversal_in_progress() const; 291 inline bool has_forwarded_objects() const; 292 inline bool is_gc_in_progress_mask(uint mask) const; 293 294 // ---------- GC cancellation and degeneration machinery 295 // 296 // Cancelled GC flag is used to notify concurrent phases that they should terminate. 297 // 298 public: 299 enum ShenandoahDegenPoint { 300 _degenerated_unset, 301 _degenerated_traversal, 302 _degenerated_outside_cycle, 303 _degenerated_mark, 304 _degenerated_evac, 305 _degenerated_updaterefs, 306 _DEGENERATED_LIMIT, 307 }; 308 309 static const char* degen_point_to_string(ShenandoahDegenPoint point) { 310 switch (point) { 311 case _degenerated_unset: 312 return "<UNSET>"; 313 case _degenerated_traversal: 314 return "Traversal"; 315 case _degenerated_outside_cycle: 316 return "Outside of Cycle"; 317 case _degenerated_mark: 318 return "Mark"; 319 case _degenerated_evac: 320 return "Evacuation"; 321 case _degenerated_updaterefs: 322 return "Update Refs"; 323 default: 324 ShouldNotReachHere(); 325 return "ERROR"; 326 } 327 }; 328 329 private: 330 enum CancelState { 331 // Normal state. GC has not been cancelled and is open for cancellation. 332 // Worker threads can suspend for safepoint. 333 CANCELLABLE, 334 335 // GC has been cancelled. Worker threads can not suspend for 336 // safepoint but must finish their work as soon as possible. 337 CANCELLED, 338 339 // GC has not been cancelled and must not be cancelled. At least 340 // one worker thread checks for pending safepoint and may suspend 341 // if a safepoint is pending. 342 NOT_CANCELLED 343 }; 344 345 ShenandoahSharedEnumFlag<CancelState> _cancelled_gc; 346 bool try_cancel_gc(); 347 348 public: 349 static address cancelled_gc_addr(); 350 351 inline bool cancelled_gc() const; 352 inline bool check_cancelled_gc_and_yield(bool sts_active = true); 353 354 inline void clear_cancelled_gc(); 355 356 void cancel_gc(GCCause::Cause cause); 357 358 // ---------- GC operations entry points 359 // 360 public: 361 // Entry points to STW GC operations, these cause a related safepoint, that then 362 // call the entry method below 363 void vmop_entry_init_mark(); 364 void vmop_entry_final_mark(); 365 void vmop_entry_final_evac(); 366 void vmop_entry_init_updaterefs(); 367 void vmop_entry_final_updaterefs(); 368 void vmop_entry_init_traversal(); 369 void vmop_entry_final_traversal(); 370 void vmop_entry_full(GCCause::Cause cause); 371 void vmop_degenerated(ShenandoahDegenPoint point); 372 373 // Entry methods to normally STW GC operations. These set up logging, monitoring 374 // and workers for net VM operation 375 void entry_init_mark(); 376 void entry_final_mark(); 377 void entry_final_evac(); 378 void entry_init_updaterefs(); 379 void entry_final_updaterefs(); 380 void entry_init_traversal(); 381 void entry_final_traversal(); 382 void entry_full(GCCause::Cause cause); 383 void entry_degenerated(int point); 384 385 // Entry methods to normally concurrent GC operations. These set up logging, monitoring 386 // for concurrent operation. 387 void entry_reset(); 388 void entry_mark(); 389 void entry_preclean(); 390 void entry_cleanup(); 391 void entry_evac(); 392 void entry_updaterefs(); 393 void entry_traversal(); 394 void entry_uncommit(double shrink_before); 395 396 private: 397 // Actual work for the phases 398 void op_init_mark(); 399 void op_final_mark(); 400 void op_final_evac(); 401 void op_init_updaterefs(); 402 void op_final_updaterefs(); 403 void op_init_traversal(); 404 void op_final_traversal(); 405 void op_full(GCCause::Cause cause); 406 void op_degenerated(ShenandoahDegenPoint point); 407 void op_degenerated_fail(); 408 void op_degenerated_futile(); 409 410 void op_reset(); 411 void op_mark(); 412 void op_preclean(); 413 void op_cleanup(); 414 void op_conc_evac(); 415 void op_stw_evac(); 416 void op_updaterefs(); 417 void op_traversal(); 418 void op_uncommit(double shrink_before); 419 420 // Messages for GC trace events, they have to be immortal for 421 // passing around the logging/tracing systems 422 const char* init_mark_event_message() const; 423 const char* final_mark_event_message() const; 424 const char* conc_mark_event_message() const; 425 const char* degen_event_message(ShenandoahDegenPoint point) const; 426 427 // ---------- GC subsystems 428 // 429 private: 430 ShenandoahControlThread* _control_thread; 431 ShenandoahCollectorPolicy* _shenandoah_policy; 432 ShenandoahHeuristics* _heuristics; 433 ShenandoahFreeSet* _free_set; 434 ShenandoahConcurrentMark* _scm; 435 ShenandoahTraversalGC* _traversal_gc; 436 ShenandoahMarkCompact* _full_gc; 437 ShenandoahPacer* _pacer; 438 ShenandoahVerifier* _verifier; 439 440 ShenandoahAllocTracker* _alloc_tracker; 441 ShenandoahPhaseTimings* _phase_timings; 442 443 ShenandoahControlThread* control_thread() { return _control_thread; } 444 ShenandoahMarkCompact* full_gc() { return _full_gc; } 445 446 public: 447 ShenandoahCollectorPolicy* shenandoah_policy() const { return _shenandoah_policy; } 448 ShenandoahHeuristics* heuristics() const { return _heuristics; } 449 ShenandoahFreeSet* free_set() const { return _free_set; } 450 ShenandoahConcurrentMark* concurrent_mark() { return _scm; } 451 ShenandoahTraversalGC* traversal_gc() { return _traversal_gc; } 452 ShenandoahPacer* pacer() const { return _pacer; } 453 454 ShenandoahPhaseTimings* phase_timings() const { return _phase_timings; } 455 ShenandoahAllocTracker* alloc_tracker() const { return _alloc_tracker; } 456 457 ShenandoahVerifier* verifier(); 458 459 // ---------- VM subsystem bindings 460 // 461 private: 462 ShenandoahMonitoringSupport* _monitoring_support; 463 MemoryPool* _memory_pool; 464 GCMemoryManager _stw_memory_manager; 465 GCMemoryManager _cycle_memory_manager; 466 ConcurrentGCTimer* _gc_timer; 467 SoftRefPolicy _soft_ref_policy; 468 469 // For exporting to SA 470 int _log_min_obj_alignment_in_bytes; 471 public: 472 ShenandoahMonitoringSupport* monitoring_support() { return _monitoring_support; } 473 GCMemoryManager* cycle_memory_manager() { return &_cycle_memory_manager; } 474 GCMemoryManager* stw_memory_manager() { return &_stw_memory_manager; } 475 SoftRefPolicy* soft_ref_policy() { return &_soft_ref_policy; } 476 477 GrowableArray<GCMemoryManager*> memory_managers(); 478 GrowableArray<MemoryPool*> memory_pools(); 479 MemoryUsage memory_usage(); 480 GCTracer* tracer(); 481 GCTimer* gc_timer() const; 482 CollectorPolicy* collector_policy() const; 483 484 // ---------- Reference processing 485 // 486 private: 487 AlwaysTrueClosure _subject_to_discovery; 488 ReferenceProcessor* _ref_processor; 489 ShenandoahSharedFlag _process_references; 490 491 void ref_processing_init(); 492 493 public: 494 ReferenceProcessor* ref_processor() { return _ref_processor; } 495 void set_process_references(bool pr); 496 bool process_references() const; 497 498 // ---------- Class Unloading 499 // 500 private: 501 ShenandoahSharedFlag _unload_classes; 502 503 public: 504 void set_unload_classes(bool uc); 505 bool unload_classes() const; 506 507 // Delete entries for dead interned string and clean up unreferenced symbols 508 // in symbol table, possibly in parallel. 509 void unload_classes_and_cleanup_tables(bool full_gc); 510 511 // ---------- Generic interface hooks 512 // Minor things that super-interface expects us to implement to play nice with 513 // the rest of runtime. Some of the things here are not required to be implemented, 514 // and can be stubbed out. 515 // 516 public: 517 AdaptiveSizePolicy* size_policy() shenandoah_not_implemented_return(NULL); 518 bool is_maximal_no_gc() const shenandoah_not_implemented_return(false); 519 520 bool is_in(const void* p) const; 521 522 void collect(GCCause::Cause cause); 523 void do_full_collection(bool clear_all_soft_refs); 524 525 // Used for parsing heap during error printing 526 HeapWord* block_start(const void* addr) const; 527 bool block_is_obj(const HeapWord* addr) const; 528 529 // Used for native heap walkers: heap dumpers, mostly 530 void object_iterate(ObjectClosure* cl); 531 void safe_object_iterate(ObjectClosure* cl); 532 533 // Used by RMI 534 jlong millis_since_last_gc(); 535 536 // ---------- Safepoint interface hooks 537 // 538 public: 539 void safepoint_synchronize_begin(); 540 void safepoint_synchronize_end(); 541 542 // ---------- Code roots handling hooks 543 // 544 public: 545 void register_nmethod(nmethod* nm); 546 void unregister_nmethod(nmethod* nm); 547 void flush_nmethod(nmethod* nm) {} 548 void verify_nmethod(nmethod* nm) {} 549 550 // ---------- Pinning hooks 551 // 552 public: 553 // Shenandoah supports per-object (per-region) pinning 554 bool supports_object_pinning() const { return true; } 555 556 oop pin_object(JavaThread* thread, oop obj); 557 void unpin_object(JavaThread* thread, oop obj); 558 559 // ---------- Allocation support 560 // 561 private: 562 HeapWord* allocate_memory_under_lock(ShenandoahAllocRequest& request, bool& in_new_region); 563 inline HeapWord* allocate_from_gclab(Thread* thread, size_t size); 564 HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size); 565 HeapWord* allocate_new_gclab(size_t min_size, size_t word_size, size_t* actual_size); 566 void retire_and_reset_gclabs(); 567 568 public: 569 HeapWord* allocate_memory(ShenandoahAllocRequest& request); 570 HeapWord* mem_allocate(size_t size, bool* what); 571 MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, 572 size_t size, 573 Metaspace::MetadataType mdtype); 574 575 void notify_mutator_alloc_words(size_t words, bool waste); 576 577 // Shenandoah supports TLAB allocation 578 bool supports_tlab_allocation() const { return true; } 579 580 HeapWord* allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size); 581 size_t tlab_capacity(Thread *thr) const; 582 size_t unsafe_max_tlab_alloc(Thread *thread) const; 583 size_t max_tlab_size() const; 584 size_t tlab_used(Thread* ignored) const; 585 586 void resize_tlabs(); 587 588 void ensure_parsability(bool retire_tlabs); 589 void make_parsable(bool retire_tlabs); 590 591 // ---------- Marking support 592 // 593 private: 594 ShenandoahMarkingContext* _marking_context; 595 MemRegion _bitmap_region; 596 MemRegion _aux_bitmap_region; 597 MarkBitMap _verification_bit_map; 598 MarkBitMap _aux_bit_map; 599 600 size_t _bitmap_size; 601 size_t _bitmap_regions_per_slice; 602 size_t _bitmap_bytes_per_slice; 603 604 bool _bitmap_region_special; 605 bool _aux_bitmap_region_special; 606 607 // Used for buffering per-region liveness data. 608 // Needed since ShenandoahHeapRegion uses atomics to update liveness. 609 // 610 // The array has max-workers elements, each of which is an array of 611 // jushort * max_regions. The choice of jushort is not accidental: 612 // there is a tradeoff between static/dynamic footprint that translates 613 // into cache pressure (which is already high during marking), and 614 // too many atomic updates. size_t/jint is too large, jbyte is too small. 615 jushort** _liveness_cache; 616 617 public: 618 inline ShenandoahMarkingContext* complete_marking_context() const; 619 inline ShenandoahMarkingContext* marking_context() const; 620 inline void mark_complete_marking_context(); 621 inline void mark_incomplete_marking_context(); 622 623 template<class T> 624 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl); 625 626 template<class T> 627 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 628 629 template<class T> 630 inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 631 632 void reset_mark_bitmap(); 633 634 // SATB barriers hooks 635 template<bool RESOLVE> 636 inline bool requires_marking(const void* entry) const; 637 void force_satb_flush_all_threads(); 638 639 // Support for bitmap uncommits 640 bool commit_bitmap_slice(ShenandoahHeapRegion *r); 641 bool uncommit_bitmap_slice(ShenandoahHeapRegion *r); 642 bool is_bitmap_slice_committed(ShenandoahHeapRegion* r, bool skip_self = false); 643 644 // Liveness caching support 645 jushort* get_liveness_cache(uint worker_id); 646 void flush_liveness_cache(uint worker_id); 647 648 // ---------- Evacuation support 649 // 650 private: 651 ShenandoahCollectionSet* _collection_set; 652 ShenandoahEvacOOMHandler _oom_evac_handler; 653 654 void evacuate_and_update_roots(); 655 656 public: 657 static address in_cset_fast_test_addr(); 658 659 ShenandoahCollectionSet* collection_set() const { return _collection_set; } 660 661 template <class T> 662 inline bool in_collection_set(T obj) const; 663 664 // Avoid accidentally calling the method above with ShenandoahHeapRegion*, which would be *wrong*. 665 inline bool in_collection_set(ShenandoahHeapRegion* r) shenandoah_not_implemented_return(false); 666 667 // Evacuates object src. Returns the evacuated object, either evacuated 668 // by this thread, or by some other thread. 669 inline oop evacuate_object(oop src, Thread* thread); 670 671 // Call before/after evacuation. 672 void enter_evacuation(); 673 void leave_evacuation(); 674 675 // ---------- Helper functions 676 // 677 public: 678 template <class T> 679 inline oop evac_update_with_forwarded(T* p); 680 681 template <class T> 682 inline oop maybe_update_with_forwarded(T* p); 683 684 template <class T> 685 inline oop maybe_update_with_forwarded_not_null(T* p, oop obj); 686 687 template <class T> 688 inline oop update_with_forwarded_not_null(T* p, oop obj); 689 690 inline oop atomic_compare_exchange_oop(oop n, narrowOop* addr, oop c); 691 inline oop atomic_compare_exchange_oop(oop n, oop* addr, oop c); 692 693 void trash_humongous_region_at(ShenandoahHeapRegion *r); 694 695 void deduplicate_string(oop str); 696 697 void stop_concurrent_marking(); 698 699 private: 700 void trash_cset_regions(); 701 void update_heap_references(bool concurrent); 702 703 // ---------- Testing helpers functions 704 // 705 private: 706 ShenandoahSharedFlag _inject_alloc_failure; 707 708 void try_inject_alloc_failure(); 709 bool should_inject_alloc_failure(); 710 }; 711 712 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP