Commit c7e3722b authored by Kenton Varda's avatar Kenton Varda
parent 608d7ed7
......@@ -119,60 +119,69 @@ struct WirePointer {
// -----------------------------------------------------------------
// Part of pointer that depends on the kind.
union {
uint32_t upper32Bits;
// Note: Originally StructRef, ListRef, and FarRef were unnamed types, but this somehow
// tickled a bug in GCC:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58192
struct StructRef {
WireValue<WordCount16> dataSize;
WireValue<WirePointerCount16> ptrCount;
inline WordCount wordSize() const {
return dataSize.get() + ptrCount.get() * WORDS_PER_POINTER;
}
struct {
WireValue<WordCount16> dataSize;
WireValue<WirePointerCount16> ptrCount;
KJ_ALWAYS_INLINE(void set(WordCount ds, WirePointerCount rc)) {
dataSize.set(ds);
ptrCount.set(rc);
}
KJ_ALWAYS_INLINE(void set(StructSize size)) {
dataSize.set(size.data);
ptrCount.set(size.pointers);
}
};
inline WordCount wordSize() const {
return dataSize.get() + ptrCount.get() * WORDS_PER_POINTER;
}
struct ListRef {
WireValue<uint32_t> elementSizeAndCount;
KJ_ALWAYS_INLINE(void set(WordCount ds, WirePointerCount rc)) {
dataSize.set(ds);
ptrCount.set(rc);
}
KJ_ALWAYS_INLINE(void set(StructSize size)) {
dataSize.set(size.data);
ptrCount.set(size.pointers);
}
} structRef;
// Also covers capabilities.
KJ_ALWAYS_INLINE(FieldSize elementSize() const) {
return static_cast<FieldSize>(elementSizeAndCount.get() & 7);
}
KJ_ALWAYS_INLINE(ElementCount elementCount() const) {
return (elementSizeAndCount.get() >> 3) * ELEMENTS;
}
KJ_ALWAYS_INLINE(WordCount inlineCompositeWordCount() const) {
return elementCount() * (1 * WORDS / ELEMENTS);
}
struct {
WireValue<uint32_t> elementSizeAndCount;
KJ_ALWAYS_INLINE(void set(FieldSize es, ElementCount ec)) {
KJ_DREQUIRE(ec < (1 << 29) * ELEMENTS, "Lists are limited to 2**29 elements.");
elementSizeAndCount.set(((ec / ELEMENTS) << 3) | static_cast<int>(es));
}
KJ_ALWAYS_INLINE(FieldSize elementSize() const) {
return static_cast<FieldSize>(elementSizeAndCount.get() & 7);
}
KJ_ALWAYS_INLINE(ElementCount elementCount() const) {
return (elementSizeAndCount.get() >> 3) * ELEMENTS;
}
KJ_ALWAYS_INLINE(WordCount inlineCompositeWordCount() const) {
return elementCount() * (1 * WORDS / ELEMENTS);
}
KJ_ALWAYS_INLINE(void setInlineComposite(WordCount wc)) {
KJ_DREQUIRE(wc < (1 << 29) * WORDS, "Inline composite lists are limited to 2**29 words.");
elementSizeAndCount.set(((wc / WORDS) << 3) |
static_cast<int>(FieldSize::INLINE_COMPOSITE));
}
};
KJ_ALWAYS_INLINE(void set(FieldSize es, ElementCount ec)) {
KJ_DREQUIRE(ec < (1 << 29) * ELEMENTS, "Lists are limited to 2**29 elements.");
elementSizeAndCount.set(((ec / ELEMENTS) << 3) | static_cast<int>(es));
}
struct FarRef {
WireValue<SegmentId> segmentId;
KJ_ALWAYS_INLINE(void setInlineComposite(WordCount wc)) {
KJ_DREQUIRE(wc < (1 << 29) * WORDS, "Inline composite lists are limited to 2**29 words.");
elementSizeAndCount.set(((wc / WORDS) << 3) |
static_cast<int>(FieldSize::INLINE_COMPOSITE));
}
} listRef;
KJ_ALWAYS_INLINE(void set(SegmentId si)) {
segmentId.set(si);
}
};
struct {
WireValue<SegmentId> segmentId;
union {
uint32_t upper32Bits;
KJ_ALWAYS_INLINE(void set(SegmentId si)) {
segmentId.set(si);
}
} farRef;
StructRef structRef;
// Also covers capabilities.
ListRef listRef;
FarRef farRef;
};
KJ_ALWAYS_INLINE(bool isNull() const) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment