2929#include " gc/shenandoah/shenandoahOldGeneration.hpp"
3030#include " gc/shenandoah/shenandoahThreadLocalData.hpp"
3131
32+ #define SKIP_IF_NOT_SHENANDOAH () \
33+ if (!(UseShenandoahGC && ShenandoahHeap::heap()->mode ()->is_generational())) { \
34+ tty->print_cr (" skipped (run with -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational)" ); \
35+ return ; \
36+ }
37+
38+
3239class ShenandoahOldGenerationTest : public ::testing::Test {
3340protected:
3441 static const size_t INITIAL_PLAB_SIZE;
@@ -42,10 +49,7 @@ class ShenandoahOldGenerationTest : public ::testing::Test {
4249 }
4350
4451 void SetUp () override {
45- if (!(UseShenandoahGC && ShenandoahHeap::heap ()->mode ()->is_generational ())) {
46- GTEST_SKIP () << " Test must be run with -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational" ;
47- return ;
48- }
52+ SKIP_IF_NOT_SHENANDOAH ();
4953
5054 ShenandoahHeap::heap ()->lock ()->lock (false );
5155
@@ -85,42 +89,48 @@ const size_t ShenandoahOldGenerationTest::INITIAL_PLAB_SIZE = 42;
8589const size_t ShenandoahOldGenerationTest::INITIAL_PLAB_PROMOTED = 128 ;
8690
8791TEST_VM_F (ShenandoahOldGenerationTest, test_can_promote) {
92+ SKIP_IF_NOT_SHENANDOAH ();
8893 EXPECT_TRUE (old->can_promote (128 * HeapWordSize)) << " Should have room to promote" ;
8994 EXPECT_FALSE (old->can_promote (384 * HeapWordSize)) << " Should not have room to promote" ;
9095}
9196
9297TEST_VM_F (ShenandoahOldGenerationTest, test_can_allocate_plab_for_promotion) {
98+ SKIP_IF_NOT_SHENANDOAH ();
9399 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab (128 , 128 );
94100 EXPECT_TRUE (old->can_allocate (req)) << " Should have room to promote" ;
95101}
96102
97103TEST_VM_F (ShenandoahOldGenerationTest, test_can_allocate_plab_for_evacuation) {
104+ SKIP_IF_NOT_SHENANDOAH ();
98105 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab (384 , 384 );
99106 EXPECT_FALSE (old->can_promote (req.size () * HeapWordSize)) << " No room for promotions" ;
100107 EXPECT_TRUE (old->can_allocate (req)) << " Should have room to evacuate" ;
101108}
102109
103110TEST_VM_F (ShenandoahOldGenerationTest, test_cannot_allocate_plab) {
111+ SKIP_IF_NOT_SHENANDOAH ();
104112 // Simulate having exhausted the evacuation reserve when request is too big to be promoted
105113 old->set_evacuation_reserve (0 );
106114 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab (384 , 384 );
107115 EXPECT_FALSE (old->can_allocate (req)) << " No room for promotions or evacuations" ;
108116}
109117
110118TEST_VM_F (ShenandoahOldGenerationTest, test_can_allocate_for_shared_evacuation) {
119+ SKIP_IF_NOT_SHENANDOAH ();
111120 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc (768 , ShenandoahAffiliation::OLD_GENERATION, false );
112121 EXPECT_FALSE (old->can_promote (req.size () * HeapWordSize)) << " No room for promotion" ;
113122 EXPECT_TRUE (old->can_allocate (req)) << " Should have room to evacuate shared (even though evacuation reserve is smaller than request)" ;
114123}
115124
116125TEST_VM_F (ShenandoahOldGenerationTest, test_cannot_allocate_for_shared_promotion) {
126+ SKIP_IF_NOT_SHENANDOAH ();
117127 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc (768 , ShenandoahAffiliation::OLD_GENERATION, true );
118128 EXPECT_FALSE (old->can_promote (req.size () * HeapWordSize)) << " No room for promotion" ;
119129 EXPECT_FALSE (old->can_allocate (req)) << " No room to promote, should fall back to evacuation in young gen" ;
120130}
121131
122132TEST_VM_F (ShenandoahOldGenerationTest, test_expend_promoted) {
123-
133+ SKIP_IF_NOT_SHENANDOAH ();
124134 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab (128 , 128 );
125135
126136 // simulate the allocation
@@ -139,6 +149,7 @@ TEST_VM_F(ShenandoahOldGenerationTest, test_expend_promoted) {
139149}
140150
141151TEST_VM_F (ShenandoahOldGenerationTest, test_actual_size_exceeds_promotion_reserve) {
152+ SKIP_IF_NOT_SHENANDOAH ();
142153 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_plab (128 , 128 );
143154
144155 // simulate an allocation that exceeds the promotion reserve after allocation
@@ -156,6 +167,7 @@ TEST_VM_F(ShenandoahOldGenerationTest, test_actual_size_exceeds_promotion_reserv
156167}
157168
158169TEST_VM_F (ShenandoahOldGenerationTest, test_shared_expends_promoted_but_does_not_change_plab) {
170+ SKIP_IF_NOT_SHENANDOAH ();
159171 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc (128 , ShenandoahAffiliation::OLD_GENERATION, true );
160172 req.set_actual_size (128 );
161173 size_t actual_size = req.actual_size () * HeapWordSize;
@@ -171,6 +183,7 @@ TEST_VM_F(ShenandoahOldGenerationTest, test_shared_expends_promoted_but_does_not
171183}
172184
173185TEST_VM_F (ShenandoahOldGenerationTest, test_shared_evacuation_has_no_side_effects) {
186+ SKIP_IF_NOT_SHENANDOAH ();
174187 ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc (128 , ShenandoahAffiliation::OLD_GENERATION, false );
175188 req.set_actual_size (128 );
176189
@@ -183,3 +196,5 @@ TEST_VM_F(ShenandoahOldGenerationTest, test_shared_evacuation_has_no_side_effect
183196 EXPECT_EQ (plab_size (), INITIAL_PLAB_SIZE) << " Not a plab, should not have touched plab" ;
184197 EXPECT_FALSE (promotions_enabled ());
185198}
199+
200+ #undef SKIP_IF_NOT_SHENANDOAH
0 commit comments