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