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_heap_regions_on(outputStream* st) const; 164 165 void stop(); 166 167 void prepare_for_verify(); 168 void verify(VerifyOption vo); 169 170 // ---------- Heap counters and metrics 171 // 172 private: 173 size_t _initial_size; 174 size_t _minimum_size; 175 shenandoah_padding(0); 176 volatile size_t _used; 177 volatile size_t _committed; 178 volatile size_t _bytes_allocated_since_gc_start; 179 shenandoah_padding(1); 180 181 public: 182 void increase_used(size_t bytes); 183 void decrease_used(size_t bytes); 184 void set_used(size_t bytes); 185 186 void increase_committed(size_t bytes); 187 void decrease_committed(size_t bytes); 188 void increase_allocated(size_t bytes); 189 190 size_t bytes_allocated_since_gc_start(); 191 void reset_bytes_allocated_since_gc_start(); 192 193 size_t min_capacity() const; 194 size_t max_capacity() const; 195 size_t initial_capacity() const; 196 size_t capacity() const; 197 size_t used() const; 198 size_t committed() const; 199 200 // ---------- Workers handling 201 // 202 private: 203 uint _max_workers; 204 ShenandoahWorkGang* _workers; 205 ShenandoahWorkGang* _safepoint_workers; 206 207 public: 208 uint max_workers(); 209 void assert_gc_workers(uint nworker) NOT_DEBUG_RETURN; 210 211 WorkGang* workers() const; 212 WorkGang* get_safepoint_workers(); 213 214 void gc_threads_do(ThreadClosure* tcl) const; 215 216 // ---------- Heap regions handling machinery 217 // 218 private: 219 MemRegion _heap_region; 220 bool _heap_region_special; 221 size_t _num_regions; 222 ShenandoahHeapRegion** _regions; 223 ShenandoahRegionIterator _update_refs_iterator; 224 225 public: 226 227 inline HeapWord* base() const { return _heap_region.start(); } 228 229 inline size_t num_regions() const { return _num_regions; } 230 inline bool is_heap_region_special() { return _heap_region_special; } 231 232 inline ShenandoahHeapRegion* const heap_region_containing(const void* addr) const; 233 inline size_t heap_region_index_containing(const void* addr) const; 234 235 inline ShenandoahHeapRegion* const get_region(size_t region_idx) const; 236 237 void heap_region_iterate(ShenandoahHeapRegionClosure* blk) const; 238 void parallel_heap_region_iterate(ShenandoahHeapRegionClosure* blk) const; 239 240 // ---------- GC state machinery 241 // 242 // GC state describes the important parts of collector state, that may be 243 // used to make barrier selection decisions in the native and generated code. 244 // Multiple bits can be set at once. 245 // 246 // Important invariant: when GC state is zero, the heap is stable, and no barriers 247 // are required. 248 // 249 public: 250 enum GCStateBitPos { 251 // Heap has forwarded objects: needs LRB barriers. 252 HAS_FORWARDED_BITPOS = 0, 253 254 // Heap is under marking: needs SATB barriers. 255 MARKING_BITPOS = 1, 256 257 // Heap is under evacuation: needs LRB barriers. (Set together with HAS_FORWARDED) 258 EVACUATION_BITPOS = 2, 259 260 // Heap is under updating: needs no additional barriers. 261 UPDATEREFS_BITPOS = 3, 262 }; 263 264 enum GCState { 265 STABLE = 0, 266 HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS, 267 MARKING = 1 << MARKING_BITPOS, 268 EVACUATION = 1 << EVACUATION_BITPOS, 269 UPDATEREFS = 1 << UPDATEREFS_BITPOS, 270 }; 271 272 private: 273 ShenandoahSharedBitmap _gc_state; 274 ShenandoahSharedFlag _degenerated_gc_in_progress; 275 ShenandoahSharedFlag _full_gc_in_progress; 276 ShenandoahSharedFlag _full_gc_move_in_progress; 277 ShenandoahSharedFlag _progress_last_gc; 278 ShenandoahSharedFlag _concurrent_strong_root_in_progress; 279 ShenandoahSharedFlag _concurrent_weak_root_in_progress; 280 281 void set_gc_state_all_threads(char state); 282 void set_gc_state_mask(uint mask, bool value); 283 284 public: 285 char gc_state() const; 286 static address gc_state_addr(); 287 288 void set_concurrent_mark_in_progress(bool in_progress); 289 void set_evacuation_in_progress(bool in_progress); 290 void set_update_refs_in_progress(bool in_progress); 291 void set_degenerated_gc_in_progress(bool in_progress); 292 void set_full_gc_in_progress(bool in_progress); 293 void set_full_gc_move_in_progress(bool in_progress); 294 void set_has_forwarded_objects(bool cond); 295 void set_concurrent_strong_root_in_progress(bool cond); 296 void set_concurrent_weak_root_in_progress(bool cond); 297 298 inline bool is_stable() const; 299 inline bool is_idle() const; 300 inline bool is_concurrent_mark_in_progress() const; 301 inline bool is_update_refs_in_progress() const; 302 inline bool is_evacuation_in_progress() const; 303 inline bool is_degenerated_gc_in_progress() const; 304 inline bool is_full_gc_in_progress() const; 305 inline bool is_full_gc_move_in_progress() const; 306 inline bool has_forwarded_objects() const; 307 inline bool is_gc_in_progress_mask(uint mask) const; 308 inline bool is_stw_gc_in_progress() const; 309 inline bool is_concurrent_strong_root_in_progress() const; 310 inline bool is_concurrent_weak_root_in_progress() const; 311 312 // ---------- GC cancellation and degeneration machinery 313 // 314 // Cancelled GC flag is used to notify concurrent phases that they should terminate. 315 // 316 public: 317 enum ShenandoahDegenPoint { 318 _degenerated_unset, 319 _degenerated_outside_cycle, 320 _degenerated_mark, 321 _degenerated_evac, 322 _degenerated_updaterefs, 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: 335 return "Evacuation"; 336 case _degenerated_updaterefs: 337 return "Update Refs"; 338 default: 339 ShouldNotReachHere(); 340 return "ERROR"; 341 } 342 }; 343 344 private: 345 enum CancelState { 346 // Normal state. GC has not been cancelled and is open for cancellation. 347 // Worker threads can suspend for safepoint. 348 CANCELLABLE, 349 350 // GC has been cancelled. Worker threads can not suspend for 351 // safepoint but must finish their work as soon as possible. 352 CANCELLED, 353 354 // GC has not been cancelled and must not be cancelled. At least 355 // one worker thread checks for pending safepoint and may suspend 356 // if a safepoint is pending. 357 NOT_CANCELLED 358 }; 359 360 ShenandoahSharedEnumFlag<CancelState> _cancelled_gc; 361 bool try_cancel_gc(); 362 363 public: 364 static address cancelled_gc_addr(); 365 366 inline bool cancelled_gc() const; 367 inline bool check_cancelled_gc_and_yield(bool sts_active = true); 368 369 inline void clear_cancelled_gc(); 370 371 void cancel_gc(GCCause::Cause cause); 372 373 // ---------- GC operations entry points 374 // 375 public: 376 // Entry points to STW GC operations, these cause a related safepoint, that then 377 // call the entry method below 378 void vmop_entry_init_mark(); 379 void vmop_entry_final_mark(); 380 void vmop_entry_init_updaterefs(); 381 void vmop_entry_final_updaterefs(); 382 void vmop_entry_full(GCCause::Cause cause); 383 void vmop_degenerated(ShenandoahDegenPoint point); 384 385 // Entry methods to normally STW GC operations. These set up logging, monitoring 386 // and workers for net VM operation 387 void entry_init_mark(); 388 void entry_final_mark(); 389 void entry_init_updaterefs(); 390 void entry_final_updaterefs(); 391 void entry_full(GCCause::Cause cause); 392 void entry_degenerated(int point); 393 394 // Entry methods to normally concurrent GC operations. These set up logging, monitoring 395 // for concurrent operation. 396 void entry_reset(); 397 void entry_mark(); 398 void entry_preclean(); 399 void entry_weak_roots(); 400 void entry_class_unloading(); 401 void entry_strong_roots(); 402 void entry_cleanup_early(); 403 void entry_evac(); 404 void entry_updaterefs(); 405 void entry_cleanup_complete(); 406 void entry_uncommit(double shrink_before); 407 408 private: 409 // Actual work for the phases 410 void op_init_mark(); 411 void op_final_mark(); 412 void op_init_updaterefs(); 413 void op_final_updaterefs(); 414 void op_full(GCCause::Cause cause); 415 void op_degenerated(ShenandoahDegenPoint point); 416 void op_degenerated_fail(); 417 void op_degenerated_futile(); 418 419 void op_reset(); 420 void op_mark(); 421 void op_preclean(); 422 void op_weak_roots(); 423 void op_class_unloading(); 424 void op_strong_roots(); 425 void op_cleanup_early(); 426 void op_conc_evac(); 427 void op_stw_evac(); 428 void op_updaterefs(); 429 void op_cleanup_complete(); 430 void op_uncommit(double shrink_before); 431 432 // Messages for GC trace events, they have to be immortal for 433 // passing around the logging/tracing systems 434 const char* init_mark_event_message() const; 435 const char* final_mark_event_message() const; 436 const char* conc_mark_event_message() const; 437 const char* degen_event_message(ShenandoahDegenPoint point) const; 438 439 // ---------- GC subsystems 440 // 441 private: 442 ShenandoahControlThread* _control_thread; 443 ShenandoahCollectorPolicy* _shenandoah_policy; 444 ShenandoahMode* _gc_mode; 445 ShenandoahHeuristics* _heuristics; 446 ShenandoahFreeSet* _free_set; 447 ShenandoahConcurrentMark* _scm; 448 ShenandoahMarkCompact* _full_gc; 449 ShenandoahPacer* _pacer; 450 ShenandoahVerifier* _verifier; 451 452 ShenandoahPhaseTimings* _phase_timings; 453 454 ShenandoahControlThread* control_thread() { return _control_thread; } 455 ShenandoahMarkCompact* full_gc() { return _full_gc; } 456 457 public: 458 ShenandoahCollectorPolicy* shenandoah_policy() const { return _shenandoah_policy; } 459 ShenandoahMode* mode() const { return _gc_mode; } 460 ShenandoahHeuristics* heuristics() const { return _heuristics; } 461 ShenandoahFreeSet* free_set() const { return _free_set; } 462 ShenandoahConcurrentMark* concurrent_mark() { return _scm; } 463 ShenandoahPacer* pacer() const { return _pacer; } 464 465 ShenandoahPhaseTimings* phase_timings() const { return _phase_timings; } 466 467 ShenandoahVerifier* verifier(); 468 469 // ---------- VM subsystem bindings 470 // 471 private: 472 ShenandoahMonitoringSupport* _monitoring_support; 473 MemoryPool* _memory_pool; 474 GCMemoryManager _stw_memory_manager; 475 GCMemoryManager _cycle_memory_manager; 476 ConcurrentGCTimer* _gc_timer; 477 SoftRefPolicy _soft_ref_policy; 478 479 // For exporting to SA 480 int _log_min_obj_alignment_in_bytes; 481 public: 482 ShenandoahMonitoringSupport* monitoring_support() { return _monitoring_support; } 483 GCMemoryManager* cycle_memory_manager() { return &_cycle_memory_manager; } 484 GCMemoryManager* stw_memory_manager() { return &_stw_memory_manager; } 485 SoftRefPolicy* soft_ref_policy() { return &_soft_ref_policy; } 486 487 GrowableArray<GCMemoryManager*> memory_managers(); 488 GrowableArray<MemoryPool*> memory_pools(); 489 MemoryUsage memory_usage(); 490 GCTracer* tracer(); 491 ConcurrentGCTimer* gc_timer() const; 492 493 // ---------- Reference processing 494 // 495 private: 496 AlwaysTrueClosure _subject_to_discovery; 497 ReferenceProcessor* _ref_processor; 498 ShenandoahSharedFlag _process_references; 499 bool _ref_proc_mt_discovery; 500 bool _ref_proc_mt_processing; 501 502 void ref_processing_init(); 503 504 public: 505 ReferenceProcessor* ref_processor() { return _ref_processor; } 506 bool ref_processor_mt_discovery() { return _ref_proc_mt_discovery; } 507 bool ref_processor_mt_processing() { return _ref_proc_mt_processing; } 508 void set_process_references(bool pr); 509 bool process_references() const; 510 511 // ---------- Class Unloading 512 // 513 private: 514 ShenandoahSharedFlag _unload_classes; 515 ShenandoahUnload _unloader; 516 517 public: 518 void set_unload_classes(bool uc); 519 bool unload_classes() const; 520 521 // Perform STW class unloading and weak root cleaning 522 void parallel_cleaning(bool full_gc); 523 524 private: 525 void stw_unload_classes(bool full_gc); 526 void stw_process_weak_roots(bool full_gc); 527 528 // Prepare concurrent root processing 529 void prepare_concurrent_roots(); 530 // Prepare and finish concurrent unloading 531 void prepare_concurrent_unloading(); 532 void finish_concurrent_unloading(); 533 534 // ---------- Generic interface hooks 535 // Minor things that super-interface expects us to implement to play nice with 536 // the rest of runtime. Some of the things here are not required to be implemented, 537 // and can be stubbed out. 538 // 539 public: 540 AdaptiveSizePolicy* size_policy() shenandoah_not_implemented_return(NULL); 541 bool is_maximal_no_gc() const shenandoah_not_implemented_return(false); 542 543 bool is_in(const void* p) const; 544 545 MemRegion reserved_region() const { return _reserved; } 546 bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); } 547 548 void collect(GCCause::Cause cause); 549 void do_full_collection(bool clear_all_soft_refs); 550 551 // Used for parsing heap during error printing 552 HeapWord* block_start(const void* addr) const; 553 bool block_is_obj(const HeapWord* addr) const; 554 bool print_location(outputStream* st, void* addr) const; 555 556 // Used for native heap walkers: heap dumpers, mostly 557 void object_iterate(ObjectClosure* cl); 558 559 // Keep alive an object that was loaded with AS_NO_KEEPALIVE. 560 void keep_alive(oop obj); 561 562 // Used by RMI 563 jlong millis_since_last_gc(); 564 565 // ---------- Safepoint interface hooks 566 // 567 public: 568 void safepoint_synchronize_begin(); 569 void safepoint_synchronize_end(); 570 571 // ---------- Code roots handling hooks 572 // 573 public: 574 void register_nmethod(nmethod* nm); 575 void unregister_nmethod(nmethod* nm); 576 void flush_nmethod(nmethod* nm); 577 void verify_nmethod(nmethod* nm) {} 578 579 // ---------- Pinning hooks 580 // 581 public: 582 // Shenandoah supports per-object (per-region) pinning 583 bool supports_object_pinning() const { return true; } 584 585 oop pin_object(JavaThread* thread, oop obj); 586 void unpin_object(JavaThread* thread, oop obj); 587 588 void sync_pinned_region_status(); 589 void assert_pinned_region_status() NOT_DEBUG_RETURN; 590 591 // ---------- Allocation support 592 // 593 private: 594 HeapWord* allocate_memory_under_lock(ShenandoahAllocRequest& request, bool& in_new_region); 595 inline HeapWord* allocate_from_gclab(Thread* thread, size_t size); 596 HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size); 597 HeapWord* allocate_new_gclab(size_t min_size, size_t word_size, size_t* actual_size); 598 void retire_and_reset_gclabs(); 599 600 public: 601 HeapWord* allocate_memory(ShenandoahAllocRequest& request); 602 HeapWord* mem_allocate(size_t size, bool* what); 603 MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, 604 size_t size, 605 Metaspace::MetadataType mdtype); 606 607 void notify_mutator_alloc_words(size_t words, bool waste); 608 609 // Shenandoah supports TLAB allocation 610 bool supports_tlab_allocation() const { return true; } 611 612 HeapWord* allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size); 613 size_t tlab_capacity(Thread *thr) const; 614 size_t unsafe_max_tlab_alloc(Thread *thread) const; 615 size_t max_tlab_size() const; 616 size_t tlab_used(Thread* ignored) const; 617 618 void resize_tlabs(); 619 620 void ensure_parsability(bool retire_tlabs); 621 void make_parsable(bool retire_tlabs); 622 623 // ---------- Marking support 624 // 625 private: 626 ShenandoahMarkingContext* _marking_context; 627 MemRegion _bitmap_region; 628 MemRegion _aux_bitmap_region; 629 MarkBitMap _verification_bit_map; 630 MarkBitMap _aux_bit_map; 631 632 size_t _bitmap_size; 633 size_t _bitmap_regions_per_slice; 634 size_t _bitmap_bytes_per_slice; 635 636 size_t _pretouch_heap_page_size; 637 size_t _pretouch_bitmap_page_size; 638 639 bool _bitmap_region_special; 640 bool _aux_bitmap_region_special; 641 642 ShenandoahLiveData** _liveness_cache; 643 644 public: 645 inline ShenandoahMarkingContext* complete_marking_context() const; 646 inline ShenandoahMarkingContext* marking_context() const; 647 inline void mark_complete_marking_context(); 648 inline void mark_incomplete_marking_context(); 649 650 template<class T> 651 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl); 652 653 template<class T> 654 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 655 656 template<class T> 657 inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 658 659 void reset_mark_bitmap(); 660 661 // SATB barriers hooks 662 template<bool RESOLVE> 663 inline bool requires_marking(const void* entry) const; 664 void force_satb_flush_all_threads(); 665 666 // Support for bitmap uncommits 667 bool commit_bitmap_slice(ShenandoahHeapRegion *r); 668 bool uncommit_bitmap_slice(ShenandoahHeapRegion *r); 669 bool is_bitmap_slice_committed(ShenandoahHeapRegion* r, bool skip_self = false); 670 671 // Liveness caching support 672 ShenandoahLiveData* get_liveness_cache(uint worker_id); 673 void flush_liveness_cache(uint worker_id); 674 675 size_t pretouch_heap_page_size() { return _pretouch_heap_page_size; } 676 677 // ---------- Evacuation support 678 // 679 private: 680 ShenandoahCollectionSet* _collection_set; 681 ShenandoahEvacOOMHandler _oom_evac_handler; 682 683 void evacuate_and_update_roots(); 684 685 public: 686 static address in_cset_fast_test_addr(); 687 688 ShenandoahCollectionSet* collection_set() const { return _collection_set; } 689 690 // Checks if object is in the collection set. 691 inline bool in_collection_set(oop obj) const; 692 693 // Checks if location is in the collection set. Can be interior pointer, not the oop itself. 694 inline bool in_collection_set_loc(void* loc) const; 695 696 // Evacuates object src. Returns the evacuated object, either evacuated 697 // by this thread, or by some other thread. 698 inline oop evacuate_object(oop src, Thread* thread); 699 700 // Call before/after evacuation. 701 inline void enter_evacuation(Thread* t); 702 inline void leave_evacuation(Thread* t); 703 704 // ---------- Helper functions 705 // 706 public: 707 template <class T> 708 inline oop evac_update_with_forwarded(T* p); 709 710 template <class T> 711 inline oop maybe_update_with_forwarded(T* p); 712 713 template <class T> 714 inline oop maybe_update_with_forwarded_not_null(T* p, oop obj); 715 716 template <class T> 717 inline oop update_with_forwarded_not_null(T* p, oop obj); 718 719 static inline oop cas_oop(oop n, narrowOop* addr, oop c); 720 static inline oop cas_oop(oop n, oop* addr, oop c); 721 static inline oop cas_oop(oop n, narrowOop* addr, narrowOop c); 722 723 void trash_humongous_region_at(ShenandoahHeapRegion *r); 724 725 void deduplicate_string(oop str); 726 727 private: 728 void trash_cset_regions(); 729 void update_heap_references(bool concurrent); 730 731 // ---------- Testing helpers functions 732 // 733 private: 734 ShenandoahSharedFlag _inject_alloc_failure; 735 736 void try_inject_alloc_failure(); 737 bool should_inject_alloc_failure(); 738 }; 739 740 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP