Compare commits
4 Commits
e4a77c88d8
...
edb76feadf
Author | SHA1 | Date | |
---|---|---|---|
edb76feadf | |||
2eea70f063 | |||
be3032e2f3 | |||
b34d559c02 |
@@ -263,7 +263,7 @@ struct MemManager {
|
||||
if (next == firstUnaddressable) {
|
||||
mprotectSafe(base + firstUnaddressable, kUpsizeBytes,
|
||||
PROT_READ | PROT_WRITE);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(base + firstUnaddressable, kUpsizeBytes);
|
||||
VALGRIND_MAKE_MEM_NOACCESS(base + firstUnaddressable, kUpsizeBytes);
|
||||
firstUnaddressable += kUpsizeNodes;
|
||||
#if SHOW_MEMORY
|
||||
mmapBytes = getBytes();
|
||||
@@ -278,6 +278,7 @@ struct MemManager {
|
||||
}
|
||||
}
|
||||
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(base + next, sizeof(Node));
|
||||
return next++;
|
||||
}
|
||||
|
||||
@@ -954,7 +955,10 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
||||
if (engulfLeft && engulfRight) {
|
||||
insert({next->getKey(), next->keyLen}, {}, /*endRange*/ true, copy);
|
||||
if (found) {
|
||||
remove(iter);
|
||||
move<std::memory_order_relaxed, false>(copy, latestVersion);
|
||||
// Point to the same entry as iter pointed to, but it's not
|
||||
// invalidated
|
||||
remove(copy);
|
||||
}
|
||||
} else if (engulfLeft) {
|
||||
assert(found);
|
||||
@@ -963,6 +967,10 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
||||
/*endRange*/ true, iter);
|
||||
} else if (engulfRight) {
|
||||
insert({m.param1, m.param1Len}, {}, /*endRange*/ false, iter);
|
||||
move<std::memory_order_relaxed, true>(iter, latestVersion);
|
||||
assert(iter.searchPathSize() > 0 &&
|
||||
mm.base[iter.backNode()].entry == next);
|
||||
insert({next->getKey(), next->keyLen}, {}, /*endRange*/ true, iter);
|
||||
} else {
|
||||
insert({m.param1, m.param1Len}, {{nullptr, -1}}, /*endRange*/ false,
|
||||
iter);
|
||||
@@ -1200,8 +1208,8 @@ VersionedMap::Iterator::operator*() const {
|
||||
return impl->mutations[impl->mutationIndex];
|
||||
}
|
||||
|
||||
void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
||||
const Entry *next) {
|
||||
void materializeMutations(VersionedMap::Iterator::Impl *impl,
|
||||
const Entry *prev) {
|
||||
if (prev == nullptr) {
|
||||
Finger copy;
|
||||
impl->finger.copyTo(copy);
|
||||
@@ -1212,14 +1220,6 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
||||
assert(!impl->map->mm.base[impl->finger.backNode()].entry->clearTo());
|
||||
}
|
||||
}
|
||||
if (next == nullptr) {
|
||||
Finger copy;
|
||||
impl->finger.copyTo(copy);
|
||||
impl->map->move<std::memory_order_acquire, true>(copy, impl->version);
|
||||
if (copy.searchPathSize() > 0) {
|
||||
next = impl->map->mm.base[copy.backNode()].entry;
|
||||
}
|
||||
}
|
||||
|
||||
const auto &entry = *impl->map->mm.base[impl->finger.backNode()].entry;
|
||||
impl->mutationCount = 0;
|
||||
@@ -1234,7 +1234,6 @@ void materializeMutations(VersionedMap::Iterator::Impl *impl, const Entry *prev,
|
||||
}
|
||||
if (entry.pointMutation()) {
|
||||
if (entry.valLen < 0 /* pointClear */) {
|
||||
assert(next == nullptr || !next->clearTo());
|
||||
impl->mutations[impl->mutationCount++] = {
|
||||
entry.getKey(), nullptr, entry.keyLen, 0,
|
||||
VersionedMap::Clear, entry.pointVersion};
|
||||
@@ -1260,7 +1259,7 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator++() {
|
||||
if (impl->finger.searchPathSize() == 0) {
|
||||
break;
|
||||
}
|
||||
materializeMutations(impl, &entry, nullptr);
|
||||
materializeMutations(impl, &entry);
|
||||
} while (impl->mutationCount == 0);
|
||||
impl->mutationIndex = 0;
|
||||
|
||||
@@ -1294,13 +1293,11 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator--() {
|
||||
impl->finger.push(c, true);
|
||||
}
|
||||
|
||||
const Entry *next = nullptr;
|
||||
for (;;) {
|
||||
materializeMutations(impl, nullptr, next);
|
||||
materializeMutations(impl, nullptr);
|
||||
if (impl->mutationCount > 0) {
|
||||
break;
|
||||
}
|
||||
next = impl->map->mm.base[impl->finger.backNode()].entry;
|
||||
impl->map->move<std::memory_order_acquire, false>(impl->finger,
|
||||
impl->version);
|
||||
}
|
||||
@@ -1309,13 +1306,12 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator--() {
|
||||
}
|
||||
|
||||
do {
|
||||
const Entry *entry = impl->map->mm.base[impl->finger.backNode()].entry;
|
||||
impl->map->move<std::memory_order_acquire, false>(impl->finger,
|
||||
impl->version);
|
||||
if (impl->finger.searchPathSize() == 0) {
|
||||
break;
|
||||
}
|
||||
materializeMutations(impl, nullptr, entry);
|
||||
materializeMutations(impl, nullptr);
|
||||
} while (impl->mutationCount == 0);
|
||||
impl->mutationIndex = impl->mutationCount - 1;
|
||||
return *this;
|
||||
@@ -1390,7 +1386,7 @@ void VersionedMap::Impl::StepwiseFirstGeq::end() {
|
||||
if (finger.searchPathSize() == 0) {
|
||||
break;
|
||||
} else {
|
||||
materializeMutations(iterator->impl, prev, nullptr);
|
||||
materializeMutations(iterator->impl, prev);
|
||||
for (int j = 0; j < iterator->impl->mutationCount; ++j) {
|
||||
if (geq(iterator->impl->mutations[j], *key)) {
|
||||
iterator->impl->mutationIndex = j;
|
||||
@@ -1542,7 +1538,7 @@ VersionedMap::Iterator VersionedMap::begin(int64_t version) const {
|
||||
const Entry *prev = nullptr;
|
||||
for (;;) {
|
||||
if (result.impl->finger.searchPathSize() > 0) {
|
||||
materializeMutations(result.impl, prev, nullptr);
|
||||
materializeMutations(result.impl, prev);
|
||||
if (result.impl->mutationCount > 0) {
|
||||
break;
|
||||
}
|
||||
@@ -1682,4 +1678,4 @@ int main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
// GCOVR_EXCL_STOP
|
||||
// GCOVR_EXCL_STOP
|
||||
|
Reference in New Issue
Block a user