--- a/src/hotspot/share/gc/shared/collectedHeap.cpp Thu Mar 15 21:24:10 2018 +0100
+++ b/src/hotspot/share/gc/shared/collectedHeap.cpp Thu Mar 15 21:29:36 2018 +0100
@@ -586,6 +586,41 @@
initialize_serviceability();
}
+#ifndef PRODUCT
+
+bool CollectedHeap::promotion_should_fail(volatile size_t* count) {
+ // Access to count is not atomic; the value does not have to be exact.
+ if (PromotionFailureALot) {
+ const size_t gc_num = total_collections();
+ const size_t elapsed_gcs = gc_num - _promotion_failure_alot_gc_number;
+ if (elapsed_gcs >= PromotionFailureALotInterval) {
+ // Test for unsigned arithmetic wrap-around.
+ if (++*count >= PromotionFailureALotCount) {
+ *count = 0;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool CollectedHeap::promotion_should_fail() {
+ return promotion_should_fail(&_promotion_failure_alot_count);
+}
+
+void CollectedHeap::reset_promotion_should_fail(volatile size_t* count) {
+ if (PromotionFailureALot) {
+ _promotion_failure_alot_gc_number = total_collections();
+ *count = 0;
+ }
+}
+
+void CollectedHeap::reset_promotion_should_fail() {
+ reset_promotion_should_fail(&_promotion_failure_alot_count);
+}
+
+#endif // #ifndef PRODUCT
+
oop CollectedHeap::pin_object(JavaThread* thread, oop o) {
Handle handle(thread, o);
GCLocker::lock_critical(thread);