Remove getFirstChildExists
Once we know the type, for Node3 and higher we know the first child exists anyway
This commit is contained in:
@@ -1413,24 +1413,23 @@ TaggedNodePointer getChildGeq(Node *self, int child) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *getFirstChild(Node0 *) { return nullptr; }
|
TaggedNodePointer getFirstChild(Node0 *) { return nullptr; }
|
||||||
Node *getFirstChild(Node3 *self) {
|
TaggedNodePointer getFirstChild(Node3 *self) {
|
||||||
__builtin_prefetch(self->children[1]);
|
__builtin_prefetch(self->children[1]);
|
||||||
return self->numChildren == 0 ? nullptr : self->children[0];
|
return self->children[0];
|
||||||
}
|
}
|
||||||
Node *getFirstChild(Node16 *self) {
|
TaggedNodePointer getFirstChild(Node16 *self) {
|
||||||
__builtin_prefetch(self->children[1]);
|
__builtin_prefetch(self->children[1]);
|
||||||
return self->numChildren == 0 ? nullptr : self->children[0];
|
return self->children[0];
|
||||||
}
|
}
|
||||||
Node *getFirstChild(Node48 *self) {
|
TaggedNodePointer getFirstChild(Node48 *self) {
|
||||||
int index = self->index[self->bitSet.firstSetGeq(0)];
|
return self->children[self->index[self->bitSet.firstSetGeq(0)]];
|
||||||
return index < 0 ? nullptr : self->children[index];
|
|
||||||
}
|
}
|
||||||
Node *getFirstChild(Node256 *self) {
|
TaggedNodePointer getFirstChild(Node256 *self) {
|
||||||
return self->children[self->bitSet.firstSetGeq(0)];
|
return self->children[self->bitSet.firstSetGeq(0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *getFirstChild(Node *self) {
|
TaggedNodePointer getFirstChild(Node *self) {
|
||||||
// Only require that the node-specific overloads are covered
|
// Only require that the node-specific overloads are covered
|
||||||
// GCOVR_EXCL_START
|
// GCOVR_EXCL_START
|
||||||
switch (self->getType()) {
|
switch (self->getType()) {
|
||||||
@@ -1450,46 +1449,6 @@ Node *getFirstChild(Node *self) {
|
|||||||
// GCOVR_EXCL_STOP
|
// GCOVR_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
// Precondition: self has a child
|
|
||||||
TaggedNodePointer getFirstChildExists(Node3 *self) {
|
|
||||||
assert(self->numChildren > 0);
|
|
||||||
return self->children[0];
|
|
||||||
}
|
|
||||||
// Precondition: self has a child
|
|
||||||
TaggedNodePointer getFirstChildExists(Node16 *self) {
|
|
||||||
assert(self->numChildren > 0);
|
|
||||||
return self->children[0];
|
|
||||||
}
|
|
||||||
// Precondition: self has a child
|
|
||||||
TaggedNodePointer getFirstChildExists(Node48 *self) {
|
|
||||||
return self->children[self->index[self->bitSet.firstSetGeq(0)]];
|
|
||||||
}
|
|
||||||
// Precondition: self has a child
|
|
||||||
TaggedNodePointer getFirstChildExists(Node256 *self) {
|
|
||||||
return self->children[self->bitSet.firstSetGeq(0)];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Precondition: self has a child
|
|
||||||
TaggedNodePointer getFirstChildExists(Node *self) {
|
|
||||||
// Only require that the node-specific overloads are covered
|
|
||||||
// GCOVR_EXCL_START
|
|
||||||
switch (self->getType()) {
|
|
||||||
case Type_Node0:
|
|
||||||
__builtin_unreachable();
|
|
||||||
case Type_Node3:
|
|
||||||
return getFirstChildExists(static_cast<Node3 *>(self));
|
|
||||||
case Type_Node16:
|
|
||||||
return getFirstChildExists(static_cast<Node16 *>(self));
|
|
||||||
case Type_Node48:
|
|
||||||
return getFirstChildExists(static_cast<Node48 *>(self));
|
|
||||||
case Type_Node256:
|
|
||||||
return getFirstChildExists(static_cast<Node256 *>(self));
|
|
||||||
default:
|
|
||||||
__builtin_unreachable();
|
|
||||||
}
|
|
||||||
// GCOVR_EXCL_STOP
|
|
||||||
}
|
|
||||||
|
|
||||||
// self must not be the root
|
// self must not be the root
|
||||||
void maybeDecreaseCapacity(Node *&self, WriteContext *writeContext,
|
void maybeDecreaseCapacity(Node *&self, WriteContext *writeContext,
|
||||||
ConflictSet::Impl *impl);
|
ConflictSet::Impl *impl);
|
||||||
@@ -1779,7 +1738,7 @@ Node *nextLogical(Node *node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !node->entryPresent; node = getFirstChildExists(node)) {
|
for (; !node->entryPresent; node = getFirstChild(node)) {
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@@ -2827,7 +2786,7 @@ bool checkRangeStartsWith(NodeT *nTyped, TrivialSpan key, int begin, int end,
|
|||||||
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
||||||
|
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
for (; !n->entryPresent; n = getFirstChild(n)) {
|
||||||
}
|
}
|
||||||
return n->entry.rangeVersion <= readVersion;
|
return n->entry.rangeVersion <= readVersion;
|
||||||
}
|
}
|
||||||
@@ -3284,7 +3243,7 @@ PRESERVE_NONE void down_left_spine(Job *job, Context *context) {
|
|||||||
job->setResult(n->entry.rangeVersion <= job->readVersion);
|
job->setResult(n->entry.rangeVersion <= job->readVersion);
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
auto child = getFirstChildExists(n);
|
auto child = getFirstChild(n);
|
||||||
job->n = child;
|
job->n = child;
|
||||||
__builtin_prefetch(job->n);
|
__builtin_prefetch(job->n);
|
||||||
job->continuation = downLeftSpineTable[child.getType()];
|
job->continuation = downLeftSpineTable[child.getType()];
|
||||||
@@ -3379,7 +3338,7 @@ template <class NodeT> void iter(Job *job, Context *context) {
|
|||||||
job->setResult(n->entry.pointVersion <= job->readVersion);
|
job->setResult(n->entry.pointVersion <= job->readVersion);
|
||||||
MUSTTAIL return complete(job, context);
|
MUSTTAIL return complete(job, context);
|
||||||
}
|
}
|
||||||
auto c = getFirstChildExists(n);
|
auto c = getFirstChild(n);
|
||||||
job->n = c;
|
job->n = c;
|
||||||
job->continuation = downLeftSpineTable[c.getType()];
|
job->continuation = downLeftSpineTable[c.getType()];
|
||||||
__builtin_prefetch(job->n);
|
__builtin_prefetch(job->n);
|
||||||
@@ -3903,7 +3862,7 @@ void left_side_down_left_spine(Job *job, Context *context) {
|
|||||||
}
|
}
|
||||||
MUSTTAIL return done_left_side_iter(job, context);
|
MUSTTAIL return done_left_side_iter(job, context);
|
||||||
}
|
}
|
||||||
auto c = getFirstChildExists(n);
|
auto c = getFirstChild(n);
|
||||||
job->n = c;
|
job->n = c;
|
||||||
job->continuation = leftSideDownLeftSpineTable[c.getType()];
|
job->continuation = leftSideDownLeftSpineTable[c.getType()];
|
||||||
__builtin_prefetch(job->n);
|
__builtin_prefetch(job->n);
|
||||||
@@ -4566,7 +4525,7 @@ bool checkPointRead(Node *n, const TrivialSpan key,
|
|||||||
if (n->entryPresent) {
|
if (n->entryPresent) {
|
||||||
return n->entry.pointVersion <= readVersion;
|
return n->entry.pointVersion <= readVersion;
|
||||||
}
|
}
|
||||||
n = getFirstChildExists(n);
|
n = getFirstChild(n);
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4620,7 +4579,7 @@ bool checkPointRead(Node *n, const TrivialSpan key,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
for (; !n->entryPresent; n = getFirstChild(n)) {
|
||||||
}
|
}
|
||||||
return n->entry.rangeVersion <= readVersion;
|
return n->entry.rangeVersion <= readVersion;
|
||||||
}
|
}
|
||||||
@@ -4695,7 +4654,7 @@ bool checkPrefixRead(Node *n, const TrivialSpan key,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
for (; !n->entryPresent; n = getFirstChild(n)) {
|
||||||
}
|
}
|
||||||
return n->entry.rangeVersion <= readVersion;
|
return n->entry.rangeVersion <= readVersion;
|
||||||
}
|
}
|
||||||
@@ -4782,7 +4741,7 @@ bool checkRangeLeftSide(Node *n, TrivialSpan key, int prefixLen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
for (; !n->entryPresent; n = getFirstChild(n)) {
|
||||||
}
|
}
|
||||||
return n->entry.rangeVersion <= readVersion;
|
return n->entry.rangeVersion <= readVersion;
|
||||||
}
|
}
|
||||||
@@ -4878,7 +4837,7 @@ backtrack:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
for (; !n->entryPresent; n = getFirstChild(n)) {
|
||||||
}
|
}
|
||||||
return n->entry.rangeVersion <= readVersion;
|
return n->entry.rangeVersion <= readVersion;
|
||||||
}
|
}
|
||||||
@@ -5651,7 +5610,7 @@ Node *firstGeqLogical(Node *n, const TrivialSpan key) {
|
|||||||
if (n->entryPresent) {
|
if (n->entryPresent) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
n = getFirstChildExists(n);
|
n = getFirstChild(n);
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5696,7 +5655,7 @@ Node *firstGeqLogical(Node *n, const TrivialSpan key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
downLeftSpine:
|
downLeftSpine:
|
||||||
for (; !n->entryPresent; n = getFirstChildExists(n)) {
|
for (; !n->entryPresent; n = getFirstChild(n)) {
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user