582
583 // Non product verification and debugging.
584 #ifndef PRODUCT
585 // Support for PromotionFailureALot. Return true if it's time to cause a
586 // promotion failure. The no-argument version uses
587 // this->_promotion_failure_alot_count as the counter.
588 inline bool promotion_should_fail(volatile size_t* count);
589 inline bool promotion_should_fail();
590
591 // Reset the PromotionFailureALot counters. Should be called at the end of a
592 // GC in which promotion failure occurred.
593 inline void reset_promotion_should_fail(volatile size_t* count);
594 inline void reset_promotion_should_fail();
595 #endif // #ifndef PRODUCT
596
597 #ifdef ASSERT
598 static int fired_fake_oom() {
599 return (CIFireOOMAt > 1 && _fire_out_of_memory_count >= CIFireOOMAt);
600 }
601 #endif
602
603 public:
604 // Copy the current allocation context statistics for the specified contexts.
605 // For each context in contexts, set the corresponding entries in the totals
606 // and accuracy arrays to the current values held by the statistics. Each
607 // array should be of length len.
608 // Returns true if there are more stats available.
609 virtual bool copy_allocation_context_stats(const jint* contexts,
610 jlong* totals,
611 jbyte* accuracy,
612 jint len) {
613 return false;
614 }
615
616 };
617
618 // Class to set and reset the GC cause for a CollectedHeap.
619
620 class GCCauseSetter : StackObj {
621 CollectedHeap* _heap;
622 GCCause::Cause _previous_cause;
623 public:
624 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) {
625 assert(SafepointSynchronize::is_at_safepoint(),
626 "This method manipulates heap state without locking");
627 _heap = heap;
628 _previous_cause = _heap->gc_cause();
629 _heap->set_gc_cause(cause);
630 }
631
632 ~GCCauseSetter() {
633 assert(SafepointSynchronize::is_at_safepoint(),
634 "This method manipulates heap state without locking");
635 _heap->set_gc_cause(_previous_cause);
|
582
583 // Non product verification and debugging.
584 #ifndef PRODUCT
585 // Support for PromotionFailureALot. Return true if it's time to cause a
586 // promotion failure. The no-argument version uses
587 // this->_promotion_failure_alot_count as the counter.
588 inline bool promotion_should_fail(volatile size_t* count);
589 inline bool promotion_should_fail();
590
591 // Reset the PromotionFailureALot counters. Should be called at the end of a
592 // GC in which promotion failure occurred.
593 inline void reset_promotion_should_fail(volatile size_t* count);
594 inline void reset_promotion_should_fail();
595 #endif // #ifndef PRODUCT
596
597 #ifdef ASSERT
598 static int fired_fake_oom() {
599 return (CIFireOOMAt > 1 && _fire_out_of_memory_count >= CIFireOOMAt);
600 }
601 #endif
602 };
603
604 // Class to set and reset the GC cause for a CollectedHeap.
605
606 class GCCauseSetter : StackObj {
607 CollectedHeap* _heap;
608 GCCause::Cause _previous_cause;
609 public:
610 GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) {
611 assert(SafepointSynchronize::is_at_safepoint(),
612 "This method manipulates heap state without locking");
613 _heap = heap;
614 _previous_cause = _heap->gc_cause();
615 _heap->set_gc_cause(cause);
616 }
617
618 ~GCCauseSetter() {
619 assert(SafepointSynchronize::is_at_safepoint(),
620 "This method manipulates heap state without locking");
621 _heap->set_gc_cause(_previous_cause);
|