Tagged pointers

This commit is contained in:
2024-10-10 10:17:06 -07:00
parent 3739ccaaf2
commit 7abb129f03

View File

@@ -250,11 +250,12 @@ struct TaggedNodePointer {
/*implicit*/ TaggedNodePointer(Node *n);
private:
TaggedNodePointer(struct Node *p, Type) : p((uintptr_t)p) {
TaggedNodePointer(struct Node *p, Type t) : p((uintptr_t)p) {
assert((this->p & 7) == 0);
this->p |= t;
assume(p != 0);
}
uintptr_t withoutType() const { return p; }
uintptr_t withoutType() const { return p & ~uintptr_t(7); }
uintptr_t p;
};
@@ -288,7 +289,7 @@ TaggedNodePointer::TaggedNodePointer(Node *n)
Type TaggedNodePointer::getType() {
assert(p != 0);
return ((Node *)p)->getType();
return Type(p & uintptr_t(7));
}
constexpr int kNodeCopyBegin = offsetof(Node, entry);