Skip to content

Commit 9bcd269

Browse files
committed
8257221: C2: RegMask::is_bound_set split set handling broken since JDK-8221404
Reviewed-by: kvn, neliasso
1 parent 222e943 commit 9bcd269

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

src/hotspot/share/opto/regmask.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ bool RegMask::is_bound_set(const unsigned int size) const {
319319
if ((all & ~(bit-1)) != _RM_UP[i])
320320
return false; // Found many bits, so fail
321321
i++; // Skip iteration forward and check high part
322-
// The lower (BitsPerWord - size) bits should be 1 since it is split case.
323-
uintptr_t set = (bit >> (BitsPerWord - bit_index)) - 1;
322+
// The lower bits should be 1 since it is split case.
323+
uintptr_t set = (bit >> (BitsPerWord - size)) - 1;
324324
if (i > _hwm || _RM_UP[i] != set)
325325
return false; // Require expected low bits in next word
326326
}

test/hotspot/gtest/opto/test_regmask.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#include "precompiled.hpp"
26+
#include "opto/opcodes.hpp"
2627
#include "opto/regmask.hpp"
2728
#include "unittest.hpp"
2829

@@ -146,11 +147,52 @@ TEST_VM(RegMask, is_bound1) {
146147
ASSERT_FALSE(rm.is_bound1());
147148
for (int i = 0; i < RegMask::CHUNK_SIZE - 1; i++) {
148149
rm.Insert(i);
149-
ASSERT_TRUE(rm.is_bound1());
150+
ASSERT_TRUE(rm.is_bound1()) << "Index " << i;
151+
ASSERT_TRUE(rm.is_bound(Op_RegI)) << "Index " << i;
150152
contains_expected_num_of_registers(rm, 1);
151153
rm.Remove(i);
152154
}
153155
// AllStack bit does not count as a bound register
154156
rm.set_AllStack();
155157
ASSERT_FALSE(rm.is_bound1());
156158
}
159+
160+
TEST_VM(RegMask, is_bound_pair) {
161+
RegMask rm;
162+
ASSERT_TRUE(rm.is_bound_pair());
163+
for (int i = 0; i < RegMask::CHUNK_SIZE - 2; i++) {
164+
rm.Insert(i);
165+
rm.Insert(i + 1);
166+
ASSERT_TRUE(rm.is_bound_pair()) << "Index " << i;
167+
ASSERT_TRUE(rm.is_bound_set(2)) << "Index " << i;
168+
ASSERT_TRUE(rm.is_bound(Op_RegI)) << "Index " << i;
169+
contains_expected_num_of_registers(rm, 2);
170+
rm.Clear();
171+
}
172+
// A pair with the AllStack bit does not count as a bound pair
173+
rm.Clear();
174+
rm.Insert(RegMask::CHUNK_SIZE - 2);
175+
rm.Insert(RegMask::CHUNK_SIZE - 1);
176+
ASSERT_FALSE(rm.is_bound_pair());
177+
}
178+
179+
TEST_VM(RegMask, is_bound_set) {
180+
RegMask rm;
181+
for (int size = 1; size <= 16; size++) {
182+
ASSERT_TRUE(rm.is_bound_set(size));
183+
for (int i = 0; i < RegMask::CHUNK_SIZE - size; i++) {
184+
for (int j = i; j < i + size; j++) {
185+
rm.Insert(j);
186+
}
187+
ASSERT_TRUE(rm.is_bound_set(size)) << "Size " << size << " Index " << i;
188+
contains_expected_num_of_registers(rm, size);
189+
rm.Clear();
190+
}
191+
// A set with the AllStack bit does not count as a bound set
192+
for (int j = RegMask::CHUNK_SIZE - size; j < RegMask::CHUNK_SIZE; j++) {
193+
rm.Insert(j);
194+
}
195+
ASSERT_FALSE(rm.is_bound_set(size));
196+
rm.Clear();
197+
}
198+
}

0 commit comments

Comments
 (0)