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 ShenandoahFastRegionSet; 42 class ShenandoahPhaseTimings; 43 class ShenandoahHeap; 44 class ShenandoahHeapRegion; 45 class ShenandoahHeapRegionClosure; 46 class ShenandoahHeapRegionSet; 47 class ShenandoahCollectionSet; 48 class ShenandoahFreeSet; 49 class ShenandoahConcurrentMark; 50 class ShenandoahMarkCompact; 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 traversal collection 183 TRAVERSAL_BITPOS = 4, 184 }; 185 186 enum GCState { 187 STABLE = 0, 188 HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS, 189 MARKING = 1 << MARKING_BITPOS, 190 EVACUATION = 1 << EVACUATION_BITPOS, 191 UPDATEREFS = 1 << UPDATEREFS_BITPOS, 192 TRAVERSAL = 1 << TRAVERSAL_BITPOS, 193 }; 194 195 enum ShenandoahDegenPoint { 196 _degenerated_unset, 197 _degenerated_traversal, 198 _degenerated_outside_cycle, 199 _degenerated_mark, 200 _degenerated_evac, 201 _degenerated_updaterefs, 202 _DEGENERATED_LIMIT, 203 }; 204 205 enum GCCycleMode { 206 NONE, 207 MINOR, 208 MAJOR 209 }; 210 211 static const char* degen_point_to_string(ShenandoahDegenPoint point) { 212 switch (point) { 213 case _degenerated_unset: 214 return "<UNSET>"; 215 case _degenerated_traversal: 216 return "Traversal"; 217 case _degenerated_outside_cycle: 218 return "Outside of Cycle"; 219 case _degenerated_mark: 220 return "Mark"; 221 case _degenerated_evac: 222 return "Evacuation"; 223 case _degenerated_updaterefs: 224 return "Update Refs"; 225 default: 226 ShouldNotReachHere(); 227 return "ERROR"; 228 } 229 }; 230 231 private: 232 ShenandoahSharedBitmap _gc_state; 233 ShenandoahHeapLock _lock; 234 ShenandoahCollectorPolicy* _shenandoah_policy; 235 SoftRefPolicy _soft_ref_policy; 236 size_t _bitmap_size; 237 size_t _bitmap_regions_per_slice; 238 size_t _bitmap_bytes_per_slice; 239 MemRegion _heap_region; 240 MemRegion _bitmap0_region; 241 MemRegion _bitmap1_region; 242 MemRegion _aux_bitmap_region; 243 244 ShenandoahHeapRegion** _regions; 245 ShenandoahFreeSet* _free_set; 246 ShenandoahCollectionSet* _collection_set; 247 248 ShenandoahRegionIterator _update_refs_iterator; 249 250 ShenandoahConcurrentMark* _scm; 251 ShenandoahMarkCompact* _full_gc; 252 ShenandoahTraversalGC* _traversal_gc; 253 ShenandoahVerifier* _verifier; 254 ShenandoahPacer* _pacer; 255 256 ShenandoahConcurrentThread* _concurrent_gc_thread; 257 258 ShenandoahMonitoringSupport* _monitoring_support; 259 260 ShenandoahPhaseTimings* _phase_timings; 261 ShenandoahAllocTracker* _alloc_tracker; 262 263 size_t _num_regions; 264 size_t _initial_size; 265 266 uint _max_workers; 267 ShenandoahWorkGang* _workers; 268 ShenandoahWorkGang* _safepoint_workers; 269 270 volatile size_t _used; 271 volatile size_t _committed; 272 273 MarkBitMap _verification_bit_map; 274 MarkBitMap _mark_bit_map0; 275 MarkBitMap _mark_bit_map1; 276 MarkBitMap* _complete_mark_bit_map; 277 MarkBitMap* _next_mark_bit_map; 278 MarkBitMap _aux_bit_map; 279 280 HeapWord** _complete_top_at_mark_starts; 281 HeapWord** _complete_top_at_mark_starts_base; 282 283 HeapWord** _next_top_at_mark_starts; 284 HeapWord** _next_top_at_mark_starts_base; 285 286 volatile size_t _bytes_allocated_since_gc_start; 287 288 ShenandoahSharedFlag _degenerated_gc_in_progress; 289 ShenandoahSharedFlag _full_gc_in_progress; 290 ShenandoahSharedFlag _full_gc_move_in_progress; 291 292 ShenandoahSharedFlag _inject_alloc_failure; 293 294 ShenandoahSharedFlag _process_references; 295 ShenandoahSharedFlag _unload_classes; 296 297 ShenandoahSharedEnumFlag<CancelState> _cancelled_concgc; 298 299 ReferenceProcessor* _ref_processor; 300 301 ShenandoahForwardedIsAliveClosure _forwarded_is_alive; 302 ShenandoahIsAliveClosure _is_alive; 303 304 ConcurrentGCTimer* _gc_timer; 305 306 ShenandoahConnectionMatrix* _connection_matrix; 307 308 GCMemoryManager _stw_memory_manager; 309 GCMemoryManager _cycle_memory_manager; 310 311 MemoryPool* _memory_pool; 312 313 ShenandoahEvacOOMHandler _oom_evac_handler; 314 315 ShenandoahSharedEnumFlag<GCCycleMode> _gc_cycle_mode; 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); 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_traversal_in_progress(bool in_progress); 443 void set_has_forwarded_objects(bool cond); 444 445 void set_process_references(bool pr); 446 void set_unload_classes(bool uc); 447 448 inline bool is_stable() const; 449 inline bool is_idle() const; 450 inline bool is_concurrent_mark_in_progress() const; 451 inline bool is_update_refs_in_progress() const; 452 inline bool is_evacuation_in_progress() const; 453 inline bool is_degenerated_gc_in_progress() const; 454 inline bool is_full_gc_in_progress() const; 455 inline bool is_full_gc_move_in_progress() const; 456 inline bool is_concurrent_traversal_in_progress() const; 457 inline bool has_forwarded_objects() const; 458 inline bool is_gc_in_progress_mask(uint mask) const; 459 460 char gc_state() const; 461 462 bool process_references() const; 463 bool unload_classes() const; 464 465 bool is_minor_gc() const; 466 bool is_major_gc() const; 467 void set_cycle_mode(GCCycleMode gc_cycle_mode); 468 469 inline bool region_in_collection_set(size_t region_index) const; 470 471 // Mainly there to avoid accidentally calling the templated 472 // method below with ShenandoahHeapRegion* which would be *wrong*. 473 inline bool in_collection_set(ShenandoahHeapRegion* r) const; 474 475 template <class T> 476 inline bool in_collection_set(T obj) const; 477 478 inline bool allocated_after_next_mark_start(HeapWord* addr) const; 479 void set_next_top_at_mark_start(HeapWord* region_base, HeapWord* addr); 480 HeapWord* next_top_at_mark_start(HeapWord* region_base); 481 482 inline bool allocated_after_complete_mark_start(HeapWord* addr) const; 483 void set_complete_top_at_mark_start(HeapWord* region_base, HeapWord* addr); 484 HeapWord* complete_top_at_mark_start(HeapWord* region_base); 485 486 // Evacuates object src. Returns the evacuated object if this thread 487 // succeeded, otherwise rolls back the evacuation and returns the 488 // evacuated object by the competing thread. 489 inline oop evacuate_object(oop src, Thread* thread); 490 inline bool cancelled_concgc() const; 491 inline bool check_cancelled_concgc_and_yield(bool sts_active = true); 492 inline bool try_cancel_concgc(); 493 inline void clear_cancelled_concgc(); 494 495 inline ShenandoahHeapRegion* const get_region(size_t region_idx) const; 496 ShenandoahRegionIterator region_iterator() const; 497 void heap_region_iterate(ShenandoahHeapRegionClosure& cl) const; 498 499 ShenandoahFreeSet* free_set() const { return _free_set; } 500 ShenandoahCollectionSet* collection_set() const { return _collection_set; } 501 502 ShenandoahConnectionMatrix* connection_matrix() const; 503 504 void increase_used(size_t bytes); 505 void decrease_used(size_t bytes); 506 507 void set_used(size_t bytes); 508 509 void increase_committed(size_t bytes); 510 void decrease_committed(size_t bytes); 511 512 void increase_allocated(size_t bytes); 513 514 void notify_alloc(size_t words, bool waste); 515 516 void handle_heap_shrinkage(double shrink_before); 517 518 void reset_next_mark_bitmap(); 519 void reset_next_mark_bitmap_traversal(); 520 521 MarkBitMap* complete_mark_bit_map(); 522 MarkBitMap* next_mark_bit_map(); 523 inline bool is_marked_complete(oop obj) const; 524 inline bool mark_next(oop obj) const; 525 inline bool is_marked_next(oop obj) const; 526 bool is_next_bitmap_clear(); 527 bool is_next_bitmap_clear_range(HeapWord* start, HeapWord* end); 528 bool is_complete_bitmap_clear_range(HeapWord* start, HeapWord* end); 529 530 bool commit_bitmap_slice(ShenandoahHeapRegion *r); 531 bool uncommit_bitmap_slice(ShenandoahHeapRegion *r); 532 533 // Hint that the bitmap slice is not needed 534 bool idle_bitmap_slice(ShenandoahHeapRegion* r); 535 void activate_bitmap_slice(ShenandoahHeapRegion* r); 536 537 bool is_bitmap_slice_committed(ShenandoahHeapRegion* r, bool skip_self = false); 538 539 void print_heap_regions_on(outputStream* st) const; 540 541 size_t bytes_allocated_since_gc_start(); 542 void reset_bytes_allocated_since_gc_start(); 543 544 void trash_humongous_region_at(ShenandoahHeapRegion *r); 545 546 virtual GrowableArray<GCMemoryManager*> memory_managers(); 547 virtual GrowableArray<MemoryPool*> memory_pools(); 548 549 ShenandoahMonitoringSupport* monitoring_support(); 550 ShenandoahConcurrentMark* concurrentMark() { return _scm; } 551 ShenandoahMarkCompact* full_gc() { return _full_gc; } 552 ShenandoahTraversalGC* traversal_gc(); 553 ShenandoahVerifier* verifier(); 554 ShenandoahPacer* pacer() const; 555 556 ReferenceProcessor* ref_processor() { return _ref_processor;} 557 558 WorkGang* workers() const { return _workers;} 559 560 uint max_workers(); 561 562 void assert_gc_workers(uint nworker) PRODUCT_RETURN; 563 564 void do_evacuation(); 565 ShenandoahHeapRegion* next_compaction_region(const ShenandoahHeapRegion* r); 566 567 void heap_region_iterate(ShenandoahHeapRegionClosure* blk, bool skip_cset_regions = false, bool skip_humongous_continuation = false) const; 568 569 // Delete entries for dead interned string and clean up unreferenced symbols 570 // in symbol table, possibly in parallel. 571 void unload_classes_and_cleanup_tables(bool full_gc); 572 573 inline size_t num_regions() const { return _num_regions; } 574 575 BoolObjectClosure* is_alive_closure(); 576 577 // Call before starting evacuation. 578 void enter_evacuation(); 579 // Call after finished with evacuation. 580 void leave_evacuation(); 581 582 private: 583 template<class T> 584 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 585 586 template<class T> 587 inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit); 588 589 public: 590 template<class T> 591 inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl); 592 593 template<class T> 594 inline void marked_object_safe_iterate(ShenandoahHeapRegion* region, T* cl); 595 596 template<class T> 597 inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl); 598 599 template<class T> 600 inline void marked_object_oop_safe_iterate(ShenandoahHeapRegion* region, T* cl); 601 602 GCTimer* gc_timer() const; 603 604 void swap_mark_bitmaps(); 605 606 void cancel_concgc(GCCause::Cause cause); 607 608 ShenandoahHeapLock* lock() { return &_lock; } 609 void assert_heaplock_owned_by_current_thread() PRODUCT_RETURN; 610 void assert_heaplock_not_owned_by_current_thread() PRODUCT_RETURN; 611 void assert_heaplock_or_safepoint() PRODUCT_RETURN; 612 613 public: 614 typedef enum { 615 _alloc_shared, // Allocate common, outside of TLAB 616 _alloc_shared_gc, // Allocate common, outside of GCLAB 617 _alloc_tlab, // Allocate TLAB 618 _alloc_gclab, // Allocate GCLAB 619 _ALLOC_LIMIT, 620 } AllocType; 621 622 static const char* alloc_type_to_string(AllocType type) { 623 switch (type) { 624 case _alloc_shared: 625 return "Shared"; 626 case _alloc_shared_gc: 627 return "Shared GC"; 628 case _alloc_tlab: 629 return "TLAB"; 630 case _alloc_gclab: 631 return "GCLAB"; 632 default: 633 ShouldNotReachHere(); 634 return ""; 635 } 636 } 637 private: 638 639 virtual void initialize_serviceability(); 640 641 HeapWord* allocate_new_lab(size_t word_size, AllocType type); 642 HeapWord* allocate_memory_under_lock(size_t word_size, AllocType type, bool &new_region); 643 HeapWord* allocate_memory(size_t word_size, AllocType type); 644 // Shenandoah functionality. 645 inline HeapWord* allocate_from_gclab(Thread* thread, size_t size); 646 HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size); 647 HeapWord* allocate_new_gclab(size_t word_size); 648 649 template<class T> 650 inline void do_object_marked_complete(T* cl, oop obj); 651 652 ShenandoahConcurrentThread* concurrent_thread() { return _concurrent_gc_thread; } 653 654 public: 655 inline oop atomic_compare_exchange_oop(oop n, narrowOop* addr, oop c); 656 inline oop atomic_compare_exchange_oop(oop n, oop* addr, oop c); 657 658 private: 659 void ref_processing_init(); 660 661 GCTracer* tracer(); 662 663 private: 664 uint64_t _alloc_seq_at_last_gc_start; 665 uint64_t _alloc_seq_at_last_gc_end; 666 size_t _used_at_last_gc; 667 668 public: 669 uint64_t alloc_seq_at_last_gc_end() const { return _alloc_seq_at_last_gc_end; } 670 uint64_t alloc_seq_at_last_gc_start() const { return _alloc_seq_at_last_gc_start;} 671 size_t used_at_last_gc() const { return _used_at_last_gc;} 672 673 void set_alloc_seq_gc_start(); 674 void set_alloc_seq_gc_end(); 675 676 void set_used_at_last_gc() {_used_at_last_gc = used();} 677 678 void make_tlabs_parsable(bool retire_tlabs) /* override */; 679 680 GCMemoryManager* cycle_memory_manager() { return &_cycle_memory_manager; } 681 GCMemoryManager* stw_memory_manager() { return &_stw_memory_manager; } 682 683 public: 684 // Entry points to STW GC operations, these cause a related safepoint, that then 685 // call the entry method below 686 void vmop_entry_init_mark(); 687 void vmop_entry_final_mark(); 688 void vmop_entry_final_evac(); 689 void vmop_entry_init_updaterefs(); 690 void vmop_entry_final_updaterefs(); 691 void vmop_entry_init_traversal(); 692 void vmop_entry_final_traversal(); 693 void vmop_entry_full(GCCause::Cause cause); 694 void vmop_degenerated(ShenandoahDegenPoint point); 695 696 // Entry methods to normally STW GC operations. These set up logging, monitoring 697 // and workers for net VM operation 698 void entry_init_mark(); 699 void entry_final_mark(); 700 void entry_final_evac(); 701 void entry_init_updaterefs(); 702 void entry_final_updaterefs(); 703 void entry_init_traversal(); 704 void entry_final_traversal(); 705 void entry_full(GCCause::Cause cause); 706 void entry_degenerated(int point); 707 708 // Entry methods to normally concurrent GC operations. These set up logging, monitoring 709 // for concurrent operation. 710 void entry_mark(); 711 void entry_preclean(); 712 void entry_cleanup(); 713 void entry_cleanup_bitmaps(); 714 void entry_cleanup_traversal(); 715 void entry_evac(); 716 void entry_updaterefs(); 717 void entry_traversal(); 718 719 private: 720 // Actual work for the phases 721 void op_init_mark(); 722 void op_final_mark(); 723 void op_final_evac(); 724 void op_init_updaterefs(); 725 void op_final_updaterefs(); 726 void op_init_traversal(); 727 void op_final_traversal(); 728 void op_full(GCCause::Cause cause); 729 void op_degenerated(ShenandoahDegenPoint point); 730 void op_degenerated_fail(); 731 void op_degenerated_futile(); 732 733 void op_mark(); 734 void op_preclean(); 735 void op_cleanup(); 736 void op_evac(); 737 void op_updaterefs(); 738 void op_cleanup_bitmaps(); 739 void op_cleanup_traversal(); 740 void op_traversal(); 741 742 private: 743 void try_inject_alloc_failure(); 744 bool should_inject_alloc_failure(); 745 }; 746 747 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAP_HPP