1 /*
  2  * Copyright (c) 2013, 2021, 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 "memory/metaspace.hpp"
 39 #include "services/memoryManager.hpp"
 40 #include "utilities/globalDefinitions.hpp"
 41 #include "utilities/stack.hpp"
 42 
 43 class ConcurrentGCTimer;
 44 class ObjectIterateScanRootClosure;
 45 class ShenandoahCollectorPolicy;
 46 class ShenandoahControlThread;
 47 class ShenandoahGCSession;
 48 class ShenandoahGCStateResetter;
 49 class ShenandoahHeuristics;
 50 class ShenandoahMarkingContext;
 51 class ShenandoahMode;
 52 class ShenandoahPhaseTimings;
 53 class ShenandoahHeap;
 54 class ShenandoahHeapRegion;
 55 class ShenandoahHeapRegionClosure;
 56 class ShenandoahCollectionSet;
 57 class ShenandoahFreeSet;
 58 class ShenandoahConcurrentMark;
 59 class ShenandoahFullGC;
 60 class ShenandoahMonitoringSupport;
 61 class ShenandoahPacer;
 62 class ShenandoahReferenceProcessor;
 63 class ShenandoahVerifier;
 64 class ShenandoahWorkGang;
 65 class SlidingForwarding;
 66 class VMStructs;
 67 
 68 // Used for buffering per-region liveness data.
 69 // Needed since ShenandoahHeapRegion uses atomics to update liveness.
 70 // The ShenandoahHeap array has max-workers elements, each of which is an array of
 71 // uint16_t * max_regions. The choice of uint16_t is not accidental:
 72 // there is a tradeoff between static/dynamic footprint that translates
 73 // into cache pressure (which is already high during marking), and
 74 // too many atomic updates. uint32_t is too large, uint8_t is too small.
 75 typedef uint16_t ShenandoahLiveData;
 76 #define SHENANDOAH_LIVEDATA_MAX ((ShenandoahLiveData)-1)
 77 
 78 class ShenandoahRegionIterator : public StackObj {
 79 private:
 80   ShenandoahHeap* _heap;
 81 
 82   shenandoah_padding(0);
 83   volatile size_t _index;
 84   shenandoah_padding(1);
 85 
 86   // No implicit copying: iterators should be passed by reference to capture the state
 87   NONCOPYABLE(ShenandoahRegionIterator);
 88 
 89 public:
 90   ShenandoahRegionIterator();
 91   ShenandoahRegionIterator(ShenandoahHeap* heap);
 92 
 93   // Reset iterator to default state
 94   void reset();
 95 
 96   // Returns next region, or NULL if there are no more regions.
 97   // This is multi-thread-safe.
 98   inline ShenandoahHeapRegion* next();
 99 
100   // This is *not* MT safe. However, in the absence of multithreaded access, it
101   // can be used to determine if there is more work to do.
102   bool has_next() const;
103 };
104 
105 class ShenandoahHeapRegionClosure : public StackObj {
106 public:
107   virtual void heap_region_do(ShenandoahHeapRegion* r) = 0;
108   virtual bool is_thread_safe() { return false; }
109 };
110 
111 typedef ShenandoahLock    ShenandoahHeapLock;
112 typedef ShenandoahLocker  ShenandoahHeapLocker;
113 typedef Stack<oop, mtGC>  ShenandoahScanObjectStack;
114 
115 // Shenandoah GC is low-pause concurrent GC that uses Brooks forwarding pointers
116 // to encode forwarding data. See BrooksPointer for details on forwarding data encoding.
117 // See ShenandoahControlThread for GC cycle structure.
118 //
119 class ShenandoahHeap : public CollectedHeap {
120   friend class ShenandoahAsserts;
121   friend class VMStructs;
122   friend class ShenandoahGCSession;
123   friend class ShenandoahGCStateResetter;
124   friend class ShenandoahParallelObjectIterator;
125   friend class ShenandoahSafepoint;
126   // Supported GC
127   friend class ShenandoahConcurrentGC;
128   friend class ShenandoahDegenGC;
129   friend class ShenandoahFullGC;
130   friend class ShenandoahUnload;
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 public:
145   static ShenandoahHeap* heap();
146 
147   const char* name()          const { return "Shenandoah"; }
148   ShenandoahHeap::Name kind() const { return CollectedHeap::Shenandoah; }
149 
150   ShenandoahHeap(ShenandoahCollectorPolicy* policy);
151   jint initialize();
152   void post_initialize();
153   void initialize_mode();
154   void initialize_heuristics();
155 
156   void initialize_serviceability();
157 
158   void print_on(outputStream* st)              const;
159   void print_extended_on(outputStream *st)     const;
160   void print_tracing_info()                    const;
161   void print_heap_regions_on(outputStream* st) const;
162 
163   void stop();
164 
165   void prepare_for_verify();
166   void verify(VerifyOption vo);
167 
168 // WhiteBox testing support.
169   bool supports_concurrent_gc_breakpoints() const {
170     return true;
171   }
172 
173 // ---------- Heap counters and metrics
174 //
175 private:
176            size_t _initial_size;
177            size_t _minimum_size;
178   volatile size_t _soft_max_size;
179   shenandoah_padding(0);
180   volatile size_t _used;
181   volatile size_t _committed;
182   volatile size_t _bytes_allocated_since_gc_start;
183   shenandoah_padding(1);
184 
185 public:
186   void increase_used(size_t bytes);
187   void decrease_used(size_t bytes);
188   void set_used(size_t bytes);
189 
190   void increase_committed(size_t bytes);
191   void decrease_committed(size_t bytes);
192   void increase_allocated(size_t bytes);
193 
194   size_t bytes_allocated_since_gc_start();
195   void reset_bytes_allocated_since_gc_start();
196 
197   size_t min_capacity()      const;
198   size_t max_capacity()      const;
199   size_t soft_max_capacity() const;
200   size_t initial_capacity()  const;
201   size_t capacity()          const;
202   size_t used()              const;
203   size_t committed()         const;
204 
205   void set_soft_max_capacity(size_t v);
206 
207 // ---------- Workers handling
208 //
209 private:
210   uint _max_workers;
211   ShenandoahWorkGang* _workers;
212   ShenandoahWorkGang* _safepoint_workers;
213 
214 public:
215   uint max_workers();
216   void assert_gc_workers(uint nworker) NOT_DEBUG_RETURN;
217 
218   WorkGang* workers() const;
219   WorkGang* safepoint_workers();
220 
221   void gc_threads_do(ThreadClosure* tcl) const;
222 
223 // ---------- Heap regions handling machinery
224 //
225 private:
226   MemRegion _heap_region;
227   bool      _heap_region_special;
228   size_t    _num_regions;
229   ShenandoahHeapRegion** _regions;
230   ShenandoahRegionIterator _update_refs_iterator;
231   SlidingForwarding* _forwarding;
232 
233 public:
234 
235   inline HeapWord* base() const { return _heap_region.start(); }
236 
237   inline size_t num_regions() const { return _num_regions; }
238   inline bool is_heap_region_special() { return _heap_region_special; }
239 
240   inline ShenandoahHeapRegion* const heap_region_containing(const void* addr) const;
241   inline size_t heap_region_index_containing(const void* addr) const;
242 
243   inline ShenandoahHeapRegion* const get_region(size_t region_idx) const;
244 
245   void heap_region_iterate(ShenandoahHeapRegionClosure* blk) const;
246   void parallel_heap_region_iterate(ShenandoahHeapRegionClosure* blk) const;
247 
248   SlidingForwarding* forwarding() const { return _forwarding; }
249 
250 // ---------- GC state machinery
251 //
252 // GC state describes the important parts of collector state, that may be
253 // used to make barrier selection decisions in the native and generated code.
254 // Multiple bits can be set at once.
255 //
256 // Important invariant: when GC state is zero, the heap is stable, and no barriers
257 // are required.
258 //
259 public:
260   enum GCStateBitPos {
261     // Heap has forwarded objects: needs LRB barriers.
262     HAS_FORWARDED_BITPOS   = 0,
263 
264     // Heap is under marking: needs SATB barriers.
265     MARKING_BITPOS    = 1,
266 
267     // Heap is under evacuation: needs LRB barriers. (Set together with HAS_FORWARDED)
268     EVACUATION_BITPOS = 2,
269 
270     // Heap is under updating: needs no additional barriers.
271     UPDATEREFS_BITPOS = 3,
272 
273     // Heap is under weak-reference/roots processing: needs weak-LRB barriers.
274     WEAK_ROOTS_BITPOS  = 4,
275   };
276 
277   enum GCState {
278     STABLE        = 0,
279     HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS,
280     MARKING       = 1 << MARKING_BITPOS,
281     EVACUATION    = 1 << EVACUATION_BITPOS,
282     UPDATEREFS    = 1 << UPDATEREFS_BITPOS,
283     WEAK_ROOTS    = 1 << WEAK_ROOTS_BITPOS,
284   };
285 
286 private:
287   ShenandoahSharedBitmap _gc_state;
288   ShenandoahSharedFlag   _degenerated_gc_in_progress;
289   ShenandoahSharedFlag   _full_gc_in_progress;
290   ShenandoahSharedFlag   _full_gc_move_in_progress;
291   ShenandoahSharedFlag   _progress_last_gc;
292   ShenandoahSharedFlag   _concurrent_strong_root_in_progress;
293 
294   void set_gc_state_all_threads(char state);
295   void set_gc_state_mask(uint mask, bool value);
296 
297 public:
298   char gc_state() const;
299   static address gc_state_addr();
300 
301   void set_concurrent_mark_in_progress(bool in_progress);
302   void set_evacuation_in_progress(bool in_progress);
303   void set_update_refs_in_progress(bool in_progress);
304   void set_degenerated_gc_in_progress(bool in_progress);
305   void set_full_gc_in_progress(bool in_progress);
306   void set_full_gc_move_in_progress(bool in_progress);
307   void set_has_forwarded_objects(bool cond);
308   void set_concurrent_strong_root_in_progress(bool cond);
309   void set_concurrent_weak_root_in_progress(bool cond);
310 
311   inline bool is_stable() const;
312   inline bool is_idle() const;
313   inline bool is_concurrent_mark_in_progress() const;
314   inline bool is_update_refs_in_progress() const;
315   inline bool is_evacuation_in_progress() const;
316   inline bool is_degenerated_gc_in_progress() const;
317   inline bool is_full_gc_in_progress() const;
318   inline bool is_full_gc_move_in_progress() const;
319   inline bool has_forwarded_objects() const;
320   inline bool is_gc_in_progress_mask(uint mask) const;
321   inline bool is_stw_gc_in_progress() const;
322   inline bool is_concurrent_strong_root_in_progress() const;
323   inline bool is_concurrent_weak_root_in_progress() const;
324 
325 private:
326   enum CancelState {
327     // Normal state. GC has not been cancelled and is open for cancellation.
328     // Worker threads can suspend for safepoint.
329     CANCELLABLE,
330 
331     // GC has been cancelled. Worker threads can not suspend for
332     // safepoint but must finish their work as soon as possible.
333     CANCELLED,
334 
335     // GC has not been cancelled and must not be cancelled. At least
336     // one worker thread checks for pending safepoint and may suspend
337     // if a safepoint is pending.
338     NOT_CANCELLED
339   };
340 
341   ShenandoahSharedEnumFlag<CancelState> _cancelled_gc;
342   bool try_cancel_gc();
343 
344 public:
345   static address cancelled_gc_addr();
346 
347   inline bool cancelled_gc() const;
348   inline bool check_cancelled_gc_and_yield(bool sts_active = true);
349 
350   inline void clear_cancelled_gc();
351 
352   void cancel_gc(GCCause::Cause cause);
353 
354 public:
355   // Elastic heap support
356   void entry_uncommit(double shrink_before, size_t shrink_until);
357   void op_uncommit(double shrink_before, size_t shrink_until);
358 
359 private:
360   // GC support
361   // Reset bitmap, prepare regions for new GC cycle
362   void prepare_gc();
363   void prepare_regions_and_collection_set(bool concurrent);
364   // Evacuation
365   void prepare_evacuation(bool concurrent);
366   void evacuate_collection_set(bool concurrent);
367   // Concurrent root processing
368   void prepare_concurrent_roots();
369   void finish_concurrent_roots();
370   // Concurrent class unloading support
371   void do_class_unloading();
372   // Reference updating
373   void prepare_update_heap_references(bool concurrent);
374   void update_heap_references(bool concurrent);
375   // Final update region states
376   void update_heap_region_states(bool concurrent);
377   void rebuild_free_set(bool concurrent);
378 
379   void rendezvous_threads();
380   void recycle_trash();
381 public:
382   void notify_gc_progress()    { _progress_last_gc.set();   }
383   void notify_gc_no_progress() { _progress_last_gc.unset(); }
384 
385 //
386 // Mark support
387 private:
388   ShenandoahControlThread*   _control_thread;
389   ShenandoahCollectorPolicy* _shenandoah_policy;
390   ShenandoahMode*            _gc_mode;
391   ShenandoahHeuristics*      _heuristics;
392   ShenandoahFreeSet*         _free_set;
393   ShenandoahPacer*           _pacer;
394   ShenandoahVerifier*        _verifier;
395 
396   ShenandoahPhaseTimings*    _phase_timings;
397 
398   ShenandoahControlThread*   control_thread()          { return _control_thread;    }
399 
400 public:
401   ShenandoahCollectorPolicy* shenandoah_policy() const { return _shenandoah_policy; }
402   ShenandoahMode*            mode()              const { return _gc_mode;           }
403   ShenandoahHeuristics*      heuristics()        const { return _heuristics;        }
404   ShenandoahFreeSet*         free_set()          const { return _free_set;          }
405   ShenandoahPacer*           pacer()             const { return _pacer;             }
406 
407   ShenandoahPhaseTimings*    phase_timings()     const { return _phase_timings;     }
408 
409   ShenandoahVerifier*        verifier();
410 
411 // ---------- VM subsystem bindings
412 //
413 private:
414   ShenandoahMonitoringSupport* _monitoring_support;
415   MemoryPool*                  _memory_pool;
416   GCMemoryManager              _stw_memory_manager;
417   GCMemoryManager              _cycle_memory_manager;
418   ConcurrentGCTimer*           _gc_timer;
419   SoftRefPolicy                _soft_ref_policy;
420 
421   // For exporting to SA
422   int                          _log_min_obj_alignment_in_bytes;
423 public:
424   ShenandoahMonitoringSupport* monitoring_support() { return _monitoring_support;    }
425   GCMemoryManager* cycle_memory_manager()           { return &_cycle_memory_manager; }
426   GCMemoryManager* stw_memory_manager()             { return &_stw_memory_manager;   }
427   SoftRefPolicy* soft_ref_policy()                  { return &_soft_ref_policy;      }
428 
429   GrowableArray<GCMemoryManager*> memory_managers();
430   GrowableArray<MemoryPool*> memory_pools();
431   MemoryUsage memory_usage();
432   GCTracer* tracer();
433   ConcurrentGCTimer* gc_timer() const;
434 
435 // ---------- Reference processing
436 //
437 private:
438   ShenandoahReferenceProcessor* const _ref_processor;
439 
440 public:
441   ShenandoahReferenceProcessor* ref_processor() { return _ref_processor; }
442 
443 // ---------- Class Unloading
444 //
445 private:
446   ShenandoahSharedFlag _unload_classes;
447   ShenandoahUnload     _unloader;
448 
449 public:
450   void set_unload_classes(bool uc);
451   bool unload_classes() const;
452 
453   // Perform STW class unloading and weak root cleaning
454   void parallel_cleaning(bool full_gc);
455 
456 private:
457   void stw_unload_classes(bool full_gc);
458   void stw_process_weak_roots(bool full_gc);
459   void stw_weak_refs(bool full_gc);
460 
461   // Heap iteration support
462   void scan_roots_for_iteration(ShenandoahScanObjectStack* oop_stack, ObjectIterateScanRootClosure* oops);
463   bool prepare_aux_bitmap_for_iteration();
464   void reclaim_aux_bitmap_for_iteration();
465 
466 // ---------- Generic interface hooks
467 // Minor things that super-interface expects us to implement to play nice with
468 // the rest of runtime. Some of the things here are not required to be implemented,
469 // and can be stubbed out.
470 //
471 public:
472   AdaptiveSizePolicy* size_policy() shenandoah_not_implemented_return(NULL);
473   bool is_maximal_no_gc() const shenandoah_not_implemented_return(false);
474 
475   bool is_in(const void* p) const;
476 
477   MemRegion reserved_region() const { return _reserved; }
478   bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }
479 
480   void collect(GCCause::Cause cause);
481   void do_full_collection(bool clear_all_soft_refs);
482 
483   // Used for parsing heap during error printing
484   HeapWord* block_start(const void* addr) const;
485   bool block_is_obj(const HeapWord* addr) const;
486   bool print_location(outputStream* st, void* addr) const;
487 
488   // Used for native heap walkers: heap dumpers, mostly
489   void object_iterate(ObjectClosure* cl);
490   // Parallel heap iteration support
491   virtual ParallelObjectIterator* parallel_object_iterator(uint workers);
492 
493   // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
494   void keep_alive(oop obj);
495 
496 // ---------- Safepoint interface hooks
497 //
498 public:
499   void safepoint_synchronize_begin();
500   void safepoint_synchronize_end();
501 
502 // ---------- Code roots handling hooks
503 //
504 public:
505   void register_nmethod(nmethod* nm);
506   void unregister_nmethod(nmethod* nm);
507   void flush_nmethod(nmethod* nm);
508   void verify_nmethod(nmethod* nm) {}
509 
510 // ---------- Pinning hooks
511 //
512 public:
513   // Shenandoah supports per-object (per-region) pinning
514   bool supports_object_pinning() const { return true; }
515 
516   oop pin_object(JavaThread* thread, oop obj);
517   void unpin_object(JavaThread* thread, oop obj);
518 
519   void sync_pinned_region_status();
520   void assert_pinned_region_status() NOT_DEBUG_RETURN;
521 
522 // ---------- Concurrent Stack Processing support
523 //
524 public:
525   bool uses_stack_watermark_barrier() const { return true; }
526 
527 // ---------- Allocation support
528 //
529 private:
530   HeapWord* allocate_memory_under_lock(ShenandoahAllocRequest& request, bool& in_new_region);
531   inline HeapWord* allocate_from_gclab(Thread* thread, size_t size);
532   HeapWord* allocate_from_gclab_slow(Thread* thread, size_t size);
533   HeapWord* allocate_new_gclab(size_t min_size, size_t word_size, size_t* actual_size);
534 
535 public:
536   HeapWord* allocate_memory(ShenandoahAllocRequest& request);
537   HeapWord* mem_allocate(size_t size, bool* what);
538   MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
539                                                size_t size,
540                                                Metaspace::MetadataType mdtype);
541 
542   void notify_mutator_alloc_words(size_t words, bool waste);
543 
544   HeapWord* allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size);
545   size_t tlab_capacity(Thread *thr) const;
546   size_t unsafe_max_tlab_alloc(Thread *thread) const;
547   size_t max_tlab_size() const;
548   size_t tlab_used(Thread* ignored) const;
549 
550   void ensure_parsability(bool retire_labs);
551 
552   void labs_make_parsable();
553   void tlabs_retire(bool resize);
554   void gclabs_retire(bool resize);
555 
556 // ---------- Marking support
557 //
558 private:
559   ShenandoahMarkingContext* _marking_context;
560   MemRegion  _bitmap_region;
561   MemRegion  _aux_bitmap_region;
562   MarkBitMap _verification_bit_map;
563   MarkBitMap _aux_bit_map;
564 
565   size_t _bitmap_size;
566   size_t _bitmap_regions_per_slice;
567   size_t _bitmap_bytes_per_slice;
568 
569   size_t _pretouch_heap_page_size;
570   size_t _pretouch_bitmap_page_size;
571 
572   bool _bitmap_region_special;
573   bool _aux_bitmap_region_special;
574 
575   ShenandoahLiveData** _liveness_cache;
576 
577 public:
578   inline ShenandoahMarkingContext* complete_marking_context() const;
579   inline ShenandoahMarkingContext* marking_context() const;
580   inline void mark_complete_marking_context();
581   inline void mark_incomplete_marking_context();
582 
583   template<class T>
584   inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl);
585 
586   template<class T>
587   inline void marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit);
588 
589   template<class T>
590   inline void marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit);
591 
592   void reset_mark_bitmap();
593 
594   // SATB barriers hooks
595   inline bool requires_marking(const void* entry) const;
596 
597   // Support for bitmap uncommits
598   bool commit_bitmap_slice(ShenandoahHeapRegion *r);
599   bool uncommit_bitmap_slice(ShenandoahHeapRegion *r);
600   bool is_bitmap_slice_committed(ShenandoahHeapRegion* r, bool skip_self = false);
601 
602   // Liveness caching support
603   ShenandoahLiveData* get_liveness_cache(uint worker_id);
604   void flush_liveness_cache(uint worker_id);
605 
606   size_t pretouch_heap_page_size() { return _pretouch_heap_page_size; }
607 
608 // ---------- Evacuation support
609 //
610 private:
611   ShenandoahCollectionSet* _collection_set;
612   ShenandoahEvacOOMHandler _oom_evac_handler;
613 
614 public:
615   static address in_cset_fast_test_addr();
616 
617   ShenandoahCollectionSet* collection_set() const { return _collection_set; }
618 
619   // Checks if object is in the collection set.
620   inline bool in_collection_set(oop obj) const;
621 
622   // Checks if location is in the collection set. Can be interior pointer, not the oop itself.
623   inline bool in_collection_set_loc(void* loc) const;
624 
625   // Evacuates object src. Returns the evacuated object, either evacuated
626   // by this thread, or by some other thread.
627   inline oop evacuate_object(oop src, Thread* thread);
628 
629   // Call before/after evacuation.
630   inline void enter_evacuation(Thread* t);
631   inline void leave_evacuation(Thread* t);
632 
633 // ---------- Helper functions
634 //
635 public:
636   template <class T>
637   inline void conc_update_with_forwarded(T* p);
638 
639   template <class T>
640   inline void update_with_forwarded(T* p);
641 
642   static inline oop cas_oop(oop n, narrowOop* addr, oop c);
643   static inline oop cas_oop(oop n, oop* addr, oop c);
644   static inline oop cas_oop(oop n, narrowOop* addr, narrowOop c);
645 
646   void trash_humongous_region_at(ShenandoahHeapRegion *r);
647 
648 private:
649   void trash_cset_regions();
650 
651 // ---------- Testing helpers functions
652 //
653 private:
654   ShenandoahSharedFlag _inject_alloc_failure;
655 
656   void try_inject_alloc_failure();
657   bool should_inject_alloc_failure();
658 };
659 
660 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP