Address more missing coverage
cc #3. Found some non-trivial dead code this time!
This commit is contained in:
@@ -1243,15 +1243,11 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl,
|
|||||||
(parent->numChildren - (nodeIndex + 1)));
|
(parent->numChildren - (nodeIndex + 1)));
|
||||||
|
|
||||||
--parent->numChildren;
|
--parent->numChildren;
|
||||||
if (parent->numChildren == 0 && !parent->entryPresent &&
|
assert(parent->numChildren > 0 || parent->entryPresent);
|
||||||
parent->parent != nullptr) {
|
const bool update = result == dontInvalidate;
|
||||||
return erase(parent, allocators, impl, dontInvalidate);
|
maybeDownsize<Type_Node3>(parent, allocators, impl, result);
|
||||||
} else {
|
if (update) {
|
||||||
const bool update = result == dontInvalidate;
|
dontInvalidate = result;
|
||||||
maybeDownsize<Type_Node3>(parent, allocators, impl, result);
|
|
||||||
if (update) {
|
|
||||||
dontInvalidate = result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Type_Node16: {
|
case Type_Node16: {
|
||||||
@@ -1266,16 +1262,16 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl,
|
|||||||
(parent->numChildren - (nodeIndex + 1)));
|
(parent->numChildren - (nodeIndex + 1)));
|
||||||
|
|
||||||
--parent->numChildren;
|
--parent->numChildren;
|
||||||
if (parent->numChildren == 0 && !parent->entryPresent &&
|
|
||||||
parent->parent != nullptr) {
|
// By kMinChildrenNode16
|
||||||
return erase(parent, allocators, impl, dontInvalidate);
|
assert(parent->numChildren > 0);
|
||||||
} else {
|
|
||||||
const bool update = result == dontInvalidate;
|
const bool update = result == dontInvalidate;
|
||||||
maybeDownsize<Type_Node16>(parent, allocators, impl, result);
|
maybeDownsize<Type_Node16>(parent, allocators, impl, result);
|
||||||
if (update) {
|
if (update) {
|
||||||
dontInvalidate = result;
|
dontInvalidate = result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case Type_Node48: {
|
case Type_Node48: {
|
||||||
auto *parent48 = static_cast<Node48 *>(parent);
|
auto *parent48 = static_cast<Node48 *>(parent);
|
||||||
@@ -1293,15 +1289,14 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
--parent->numChildren;
|
--parent->numChildren;
|
||||||
if (parent->numChildren == 0 && !parent->entryPresent &&
|
|
||||||
parent->parent != nullptr) {
|
// By kMinChildrenNode48
|
||||||
return erase(parent, allocators, impl, dontInvalidate);
|
assert(parent->numChildren > 0);
|
||||||
} else {
|
|
||||||
const bool update = result == dontInvalidate;
|
const bool update = result == dontInvalidate;
|
||||||
maybeDownsize<Type_Node48>(parent, allocators, impl, result);
|
maybeDownsize<Type_Node48>(parent, allocators, impl, result);
|
||||||
if (update) {
|
if (update) {
|
||||||
dontInvalidate = result;
|
dontInvalidate = result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Type_Node256: {
|
case Type_Node256: {
|
||||||
@@ -1310,15 +1305,14 @@ Node *erase(Node *self, NodeAllocators *allocators, ConflictSet::Impl *impl,
|
|||||||
parent256->children[parentsIndex].child = nullptr;
|
parent256->children[parentsIndex].child = nullptr;
|
||||||
|
|
||||||
--parent->numChildren;
|
--parent->numChildren;
|
||||||
if (parent->numChildren == 0 && !parent->entryPresent &&
|
|
||||||
parent->parent != nullptr) {
|
// By kMinChildrenNode256
|
||||||
return erase(parent, allocators, impl, dontInvalidate);
|
assert(parent->numChildren > 0);
|
||||||
} else {
|
|
||||||
const bool update = result == dontInvalidate;
|
const bool update = result == dontInvalidate;
|
||||||
maybeDownsize<Type_Node256>(parent, allocators, impl, result);
|
maybeDownsize<Type_Node256>(parent, allocators, impl, result);
|
||||||
if (update) {
|
if (update) {
|
||||||
dontInvalidate = result;
|
dontInvalidate = result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
default: // GCOVR_EXCL_LINE
|
default: // GCOVR_EXCL_LINE
|
||||||
@@ -1358,7 +1352,7 @@ constexpr int kUnrollFactor = 4;
|
|||||||
bool compareStride(const uint8_t *ap, const uint8_t *bp) {
|
bool compareStride(const uint8_t *ap, const uint8_t *bp) {
|
||||||
#if defined(HAS_ARM_NEON)
|
#if defined(HAS_ARM_NEON)
|
||||||
static_assert(kStride == 64);
|
static_assert(kStride == 64);
|
||||||
uint8x16_t x[4];
|
uint8x16_t x[4]; // GCOVR_EXCL_LINE
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
x[i] = vceqq_u8(vld1q_u8(ap + i * 16), vld1q_u8(bp + i * 16));
|
x[i] = vceqq_u8(vld1q_u8(ap + i * 16), vld1q_u8(bp + i * 16));
|
||||||
}
|
}
|
||||||
@@ -1368,7 +1362,7 @@ bool compareStride(const uint8_t *ap, const uint8_t *bp) {
|
|||||||
uint64_t(-1);
|
uint64_t(-1);
|
||||||
#elif defined(HAS_AVX)
|
#elif defined(HAS_AVX)
|
||||||
static_assert(kStride == 64);
|
static_assert(kStride == 64);
|
||||||
__m128i x[4];
|
__m128i x[4]; // GCOVR_EXCL_LINE
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
x[i] = _mm_cmpeq_epi8(_mm_loadu_si128((__m128i *)(ap + i * 16)),
|
x[i] = _mm_cmpeq_epi8(_mm_loadu_si128((__m128i *)(ap + i * 16)),
|
||||||
_mm_loadu_si128((__m128i *)(bp + i * 16)));
|
_mm_loadu_si128((__m128i *)(bp + i * 16)));
|
||||||
@@ -1387,7 +1381,7 @@ bool compareStride(const uint8_t *ap, const uint8_t *bp) {
|
|||||||
int firstNeqStride(const uint8_t *ap, const uint8_t *bp) {
|
int firstNeqStride(const uint8_t *ap, const uint8_t *bp) {
|
||||||
#if defined(HAS_AVX)
|
#if defined(HAS_AVX)
|
||||||
static_assert(kStride == 64);
|
static_assert(kStride == 64);
|
||||||
uint64_t c[kStride / 16];
|
uint64_t c[kStride / 16]; // GCOVR_EXCL_LINE
|
||||||
for (int i = 0; i < kStride; i += 16) {
|
for (int i = 0; i < kStride; i += 16) {
|
||||||
const auto a = _mm_loadu_si128((__m128i *)(ap + i));
|
const auto a = _mm_loadu_si128((__m128i *)(ap + i));
|
||||||
const auto b = _mm_loadu_si128((__m128i *)(bp + i));
|
const auto b = _mm_loadu_si128((__m128i *)(bp + i));
|
||||||
@@ -1422,6 +1416,7 @@ int firstNeqStride(const uint8_t *ap, const uint8_t *bp) {
|
|||||||
|
|
||||||
int longestCommonPrefix(const uint8_t *ap, const uint8_t *bp, int cl) {
|
int longestCommonPrefix(const uint8_t *ap, const uint8_t *bp, int cl) {
|
||||||
assume(cl >= 0);
|
assume(cl >= 0);
|
||||||
|
printf("cl: %d\n", cl);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
@@ -1429,18 +1424,6 @@ int longestCommonPrefix(const uint8_t *ap, const uint8_t *bp, int cl) {
|
|||||||
goto bytes;
|
goto bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimistic early return
|
|
||||||
{
|
|
||||||
uint64_t a;
|
|
||||||
uint64_t b;
|
|
||||||
memcpy(&a, ap, 8);
|
|
||||||
memcpy(&b, bp, 8);
|
|
||||||
const auto mismatched = a ^ b;
|
|
||||||
if (mismatched) {
|
|
||||||
return std::countr_zero(mismatched) / 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// kStride * kUnrollCount at a time
|
// kStride * kUnrollCount at a time
|
||||||
end = cl & ~(kStride * kUnrollFactor - 1);
|
end = cl & ~(kStride * kUnrollFactor - 1);
|
||||||
while (i < end) {
|
while (i < end) {
|
||||||
@@ -1468,8 +1451,8 @@ int longestCommonPrefix(const uint8_t *ap, const uint8_t *bp, int cl) {
|
|||||||
// word at a time
|
// word at a time
|
||||||
end = cl & ~(sizeof(uint64_t) - 1);
|
end = cl & ~(sizeof(uint64_t) - 1);
|
||||||
while (i < end) {
|
while (i < end) {
|
||||||
uint64_t a;
|
uint64_t a; // GCOVR_EXCL_LINE
|
||||||
uint64_t b;
|
uint64_t b; // GCOVR_EXCL_LINE
|
||||||
memcpy(&a, ap, 8);
|
memcpy(&a, ap, 8);
|
||||||
memcpy(&b, bp, 8);
|
memcpy(&b, bp, 8);
|
||||||
const auto mismatched = a ^ b;
|
const auto mismatched = a ^ b;
|
||||||
@@ -1624,7 +1607,7 @@ int64_t maxBetweenExclusive(Node *n, int begin, int end) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (n->getType()) {
|
switch (n->getType()) {
|
||||||
case Type_Node0:
|
case Type_Node0: // GCOVR_EXCL_LINE
|
||||||
// We would have returned above, after not finding a child
|
// We would have returned above, after not finding a child
|
||||||
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
||||||
case Type_Node3: {
|
case Type_Node3: {
|
||||||
@@ -1687,7 +1670,7 @@ Vector<uint8_t> getSearchPath(Arena &arena, Node *n) {
|
|||||||
}
|
}
|
||||||
std::reverse(result.begin(), result.end());
|
std::reverse(result.begin(), result.end());
|
||||||
return result;
|
return result;
|
||||||
}
|
} // GCOVR_EXCL_LINE
|
||||||
|
|
||||||
// Return true if the max version among all keys that start with key + [child],
|
// Return true if the max version among all keys that start with key + [child],
|
||||||
// where begin < child < end, is <= readVersion
|
// where begin < child < end, is <= readVersion
|
||||||
|
19
script_tests/long-common-prefix.txt
Normal file
19
script_tests/long-common-prefix.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
begin aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaa
|
||||||
|
rangeread
|
||||||
|
check
|
||||||
|
|
||||||
|
begin aaaaaaaaaa
|
||||||
|
end aaaaaaabaa
|
||||||
|
rangeread
|
||||||
|
check
|
Reference in New Issue
Block a user