Commit 12243735 authored by Kenton Varda's avatar Kenton Varda

Rename section sizes to be slightly more intuitive.

parent 9da143f8
......@@ -936,8 +936,8 @@ private:
kj::strTree(
"CAPNP_DECLARE_STRUCT(\n"
" ", namespace_, "::", fullName, ", ", hexId, ",\n"
" ", structNode.getDataSectionWordSize(), ", ",
structNode.getPointerSectionSize(), ", ",
" ", structNode.getDataWordCount(), ", ",
structNode.getPointerCount(), ", ",
FIELD_SIZE_NAMES[static_cast<uint>(structNode.getPreferredListEncoding())],
");\n",
KJ_MAP(nestedTexts, n) { return kj::mv(n.capnpPrivateDecls); }),
......
......@@ -408,8 +408,8 @@ private:
return kj::strTree(
indent, "struct ", name,
" @0x", kj::hex(proto.getId()), genAnnotations(schema), " { # ",
structProto.getDataSectionWordSize() * 8, " bytes, ",
structProto.getPointerSectionSize(), " ptrs",
structProto.getDataWordCount() * 8, " bytes, ",
structProto.getPointerCount(), " ptrs",
structProto.getPreferredListEncoding() == schema::ElementSize::INLINE_COMPOSITE
? kj::strTree()
: kj::strTree(", packed as ", elementSizeName(structProto.getPreferredListEncoding())),
......
......@@ -910,8 +910,8 @@ public:
}
// And fill in the sizes.
structBuilder.setDataSectionWordSize(layout.getTop().dataWordCount);
structBuilder.setPointerSectionSize(layout.getTop().pointerCount);
structBuilder.setDataWordCount(layout.getTop().dataWordCount);
structBuilder.setPointerCount(layout.getTop().pointerCount);
structBuilder.setPreferredListEncoding(schema::ElementSize::INLINE_COMPOSITE);
if (layout.getTop().pointerCount == 0) {
......@@ -936,8 +936,8 @@ public:
for (auto& group: translator.groups) {
auto groupBuilder = group.get().getStruct();
groupBuilder.setDataSectionWordSize(structBuilder.getDataSectionWordSize());
groupBuilder.setPointerSectionSize(structBuilder.getPointerSectionSize());
groupBuilder.setDataWordCount(structBuilder.getDataWordCount());
groupBuilder.setPointerCount(structBuilder.getPointerCount());
groupBuilder.setPreferredListEncoding(structBuilder.getPreferredListEncoding());
}
}
......
......@@ -96,8 +96,8 @@ _::FieldSize elementSizeFor(schema::Type::Which elementType) {
inline _::StructSize structSizeFromSchema(StructSchema schema) {
auto node = schema.getProto().getStruct();
return _::StructSize(
node.getDataSectionWordSize() * WORDS,
node.getPointerSectionSize() * POINTERS,
node.getDataWordCount() * WORDS,
node.getPointerCount() * POINTERS,
static_cast<_::FieldSize>(node.getPreferredListEncoding()));
}
......
......@@ -240,8 +240,8 @@ private:
pointerCount = 1;
break;
case schema::ElementSize::INLINE_COMPOSITE:
dataSizeInBits = structNode.getDataSectionWordSize() * 64;
pointerCount = structNode.getPointerSectionSize();
dataSizeInBits = structNode.getDataWordCount() * 64;
pointerCount = structNode.getPointerCount();
break;
default:
FAIL_VALIDATE_SCHEMA("invalid preferredListEncoding");
......@@ -250,8 +250,8 @@ private:
break;
}
VALIDATE_SCHEMA(structNode.getDataSectionWordSize() == (dataSizeInBits + 63) / 64 &&
structNode.getPointerSectionSize() == pointerCount,
VALIDATE_SCHEMA(structNode.getDataWordCount() == (dataSizeInBits + 63) / 64 &&
structNode.getPointerCount() == pointerCount,
"struct size does not match preferredListEncoding");
auto fields = structNode.getFields();
......@@ -342,8 +342,8 @@ private:
// Require that the group's scope has at least the same size as the group, so that anyone
// constructing an instance of the outer scope can safely read/write the group.
loader.requireStructSize(scopeId, structNode.getDataSectionWordSize(),
structNode.getPointerSectionSize(),
loader.requireStructSize(scopeId, structNode.getDataWordCount(),
structNode.getPointerCount(),
structNode.getPreferredListEncoding());
// Require that the parent type is a struct.
......@@ -612,14 +612,14 @@ private:
void checkCompatibility(const schema::Node::Struct::Reader& structNode,
const schema::Node::Struct::Reader& replacement,
uint64_t scopeId, uint64_t replacementScopeId) {
if (replacement.getDataSectionWordSize() > structNode.getDataSectionWordSize()) {
if (replacement.getDataWordCount() > structNode.getDataWordCount()) {
replacementIsNewer();
} else if (replacement.getDataSectionWordSize() < structNode.getDataSectionWordSize()) {
} else if (replacement.getDataWordCount() < structNode.getDataWordCount()) {
replacementIsOlder();
}
if (replacement.getPointerSectionSize() > structNode.getPointerSectionSize()) {
if (replacement.getPointerCount() > structNode.getPointerCount()) {
replacementIsNewer();
} else if (replacement.getPointerSectionSize() < structNode.getPointerSectionSize()) {
} else if (replacement.getPointerCount() < structNode.getPointerCount()) {
replacementIsOlder();
}
......@@ -875,45 +875,45 @@ private:
switch (type.which()) {
case schema::Type::VOID:
structNode.setDataSectionWordSize(0);
structNode.setPointerSectionSize(0);
structNode.setDataWordCount(0);
structNode.setPointerCount(0);
structNode.setPreferredListEncoding(schema::ElementSize::EMPTY);
break;
case schema::Type::BOOL:
structNode.setDataSectionWordSize(1);
structNode.setPointerSectionSize(0);
structNode.setDataWordCount(1);
structNode.setPointerCount(0);
structNode.setPreferredListEncoding(schema::ElementSize::BIT);
break;
case schema::Type::INT8:
case schema::Type::UINT8:
structNode.setDataSectionWordSize(1);
structNode.setPointerSectionSize(0);
structNode.setDataWordCount(1);
structNode.setPointerCount(0);
structNode.setPreferredListEncoding(schema::ElementSize::BYTE);
break;
case schema::Type::INT16:
case schema::Type::UINT16:
case schema::Type::ENUM:
structNode.setDataSectionWordSize(1);
structNode.setPointerSectionSize(0);
structNode.setDataWordCount(1);
structNode.setPointerCount(0);
structNode.setPreferredListEncoding(schema::ElementSize::TWO_BYTES);
break;
case schema::Type::INT32:
case schema::Type::UINT32:
case schema::Type::FLOAT32:
structNode.setDataSectionWordSize(1);
structNode.setPointerSectionSize(0);
structNode.setDataWordCount(1);
structNode.setPointerCount(0);
structNode.setPreferredListEncoding(schema::ElementSize::FOUR_BYTES);
break;
case schema::Type::INT64:
case schema::Type::UINT64:
case schema::Type::FLOAT64:
structNode.setDataSectionWordSize(1);
structNode.setPointerSectionSize(0);
structNode.setDataWordCount(1);
structNode.setPointerCount(0);
structNode.setPreferredListEncoding(schema::ElementSize::EIGHT_BYTES);
break;
......@@ -923,8 +923,8 @@ private:
case schema::Type::STRUCT:
case schema::Type::INTERFACE:
case schema::Type::OBJECT:
structNode.setDataSectionWordSize(0);
structNode.setPointerSectionSize(1);
structNode.setDataWordCount(0);
structNode.setPointerCount(1);
structNode.setPreferredListEncoding(schema::ElementSize::POINTER);
break;
}
......@@ -1243,8 +1243,8 @@ kj::ArrayPtr<word> SchemaLoader::Impl::makeUncheckedNodeEnforcingSizeRequirement
if (iter != structSizeRequirements.end()) {
auto requirement = iter->second;
auto structNode = node.getStruct();
if (structNode.getDataSectionWordSize() < requirement.dataWordCount ||
structNode.getPointerSectionSize() < requirement.pointerCount ||
if (structNode.getDataWordCount() < requirement.dataWordCount ||
structNode.getPointerCount() < requirement.pointerCount ||
structNode.getPreferredListEncoding() < requirement.preferredListEncoding) {
return rewriteStructNodeWithSizes(node, requirement.dataWordCount,
requirement.pointerCount,
......@@ -1264,10 +1264,10 @@ kj::ArrayPtr<word> SchemaLoader::Impl::rewriteStructNodeWithSizes(
auto root = builder.getRoot<schema::Node>();
auto newStruct = root.getStruct();
newStruct.setDataSectionWordSize(kj::max(newStruct.getDataSectionWordSize(), dataWordCount));
newStruct.setPointerSectionSize(kj::max(newStruct.getPointerSectionSize(), pointerCount));
newStruct.setDataWordCount(kj::max(newStruct.getDataWordCount(), dataWordCount));
newStruct.setPointerCount(kj::max(newStruct.getPointerCount(), pointerCount));
if (newStruct.getDataSectionWordSize() + newStruct.getPointerSectionSize() >= 2) {
if (newStruct.getDataWordCount() + newStruct.getPointerCount() >= 2) {
newStruct.setPreferredListEncoding(schema::ElementSize::INLINE_COMPOSITE);
} else {
newStruct.setPreferredListEncoding(
......@@ -1283,8 +1283,8 @@ void SchemaLoader::Impl::applyStructSizeRequirement(
auto node = readMessageUnchecked<schema::Node>(raw->encodedNode);
auto structNode = node.getStruct();
if (structNode.getDataSectionWordSize() < dataWordCount ||
structNode.getPointerSectionSize() < pointerCount ||
if (structNode.getDataWordCount() < dataWordCount ||
structNode.getPointerCount() < pointerCount ||
structNode.getPreferredListEncoding() < preferredListEncoding) {
// Sizes need to be increased. Must rewrite.
kj::ArrayPtr<word> words = rewriteStructNodeWithSizes(
......
......@@ -72,8 +72,11 @@ struct Node {
file @6 :Void;
struct :group {
dataSectionWordSize @7 :UInt16;
pointerSectionSize @8 :UInt16;
dataWordCount @7 :UInt16;
# Size of the data section, in words.
pointerCount @8 :UInt16;
# Size of the pointer section, in pointers (which are one word each).
preferredListEncoding @9 :ElementSize;
# The preferred element size to use when encoding a list of this struct. If this is anything
......@@ -85,7 +88,7 @@ struct Node {
# some named union or group within a particular parent struct. This node's scopeId refers
# to the parent struct, which may itself be a union/group in yet another struct.
#
# All group nodes share the same dataSectionWordSize and pointerSectionSize as the top-level
# All group nodes share the same dataWordCount and pointerCount as the top-level
# struct, and their fields live in the same ordinal and offset spaces as all other fields in
# the struct.
#
......
......@@ -249,7 +249,7 @@ const ::capnp::_::RawSchema s_debf55bbfa0fc242 = {
0xdebf55bbfa0fc242, b_debf55bbfa0fc242.words, 46, d_debf55bbfa0fc242, m_debf55bbfa0fc242,
0, 2, i_debf55bbfa0fc242, nullptr, nullptr
};
static const ::capnp::_::AlignedData<127> b_9ea0b19b37fb4435 = {
static const ::capnp::_::AlignedData<125> b_9ea0b19b37fb4435 = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
53, 68, 251, 55, 155, 177, 160, 158,
24, 0, 0, 0, 1, 0, 5, 0,
......@@ -269,64 +269,62 @@ static const ::capnp::_::AlignedData<127> b_9ea0b19b37fb4435 = {
0, 0, 0, 0, 7, 0, 0, 0,
0, 0, 1, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
181, 0, 0, 0, 162, 0, 0, 0,
181, 0, 0, 0, 114, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
184, 0, 0, 0, 2, 0, 1, 0,
192, 0, 0, 0, 2, 0, 1, 0,
180, 0, 0, 0, 2, 0, 1, 0,
188, 0, 0, 0, 2, 0, 1, 0,
1, 0, 0, 0, 12, 0, 0, 0,
0, 0, 1, 0, 8, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
189, 0, 0, 0, 154, 0, 0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 13, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
221, 0, 0, 0, 58, 0, 0, 0,
213, 0, 0, 0, 58, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
216, 0, 0, 0, 2, 0, 1, 0,
236, 0, 0, 0, 2, 0, 1, 0,
100, 97, 116, 97, 83, 101, 99, 116,
105, 111, 110, 87, 111, 114, 100, 83,
105, 122, 101, 0, 0, 0, 0, 0,
208, 0, 0, 0, 2, 0, 1, 0,
228, 0, 0, 0, 2, 0, 1, 0,
100, 97, 116, 97, 87, 111, 114, 100,
67, 111, 117, 110, 116, 0, 0, 0,
7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
112, 111, 105, 110, 116, 101, 114, 83,
101, 99, 116, 105, 111, 110, 83, 105,
122, 101, 0, 0, 0, 0, 0, 0,
112, 111, 105, 110, 116, 101, 114, 67,
111, 117, 110, 116, 0, 0, 0, 0,
7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
......@@ -386,7 +384,7 @@ static const ::capnp::_::RawSchema* const d_9ea0b19b37fb4435[] = {
static const uint16_t m_9ea0b19b37fb4435[] = {0, 4, 5, 6, 3, 1, 2};
static const uint16_t i_9ea0b19b37fb4435[] = {0, 1, 2, 3, 4, 5, 6};
const ::capnp::_::RawSchema s_9ea0b19b37fb4435 = {
0x9ea0b19b37fb4435, b_9ea0b19b37fb4435.words, 127, d_9ea0b19b37fb4435, m_9ea0b19b37fb4435,
0x9ea0b19b37fb4435, b_9ea0b19b37fb4435.words, 125, d_9ea0b19b37fb4435, m_9ea0b19b37fb4435,
3, 7, i_9ea0b19b37fb4435, nullptr, nullptr
};
static const ::capnp::_::AlignedData<34> b_b54ab3364333f598 = {
......
......@@ -537,11 +537,11 @@ public:
return _reader.totalSize() / ::capnp::WORDS;
}
inline bool hasDataSectionWordSize() const;
inline ::uint16_t getDataSectionWordSize() const;
inline bool hasDataWordCount() const;
inline ::uint16_t getDataWordCount() const;
inline bool hasPointerSectionSize() const;
inline ::uint16_t getPointerSectionSize() const;
inline bool hasPointerCount() const;
inline ::uint16_t getPointerCount() const;
inline bool hasPreferredListEncoding() const;
inline ::capnp::schema::ElementSize getPreferredListEncoding() const;
......@@ -586,13 +586,13 @@ public:
inline size_t totalSizeInWords() { return asReader().totalSizeInWords(); }
inline bool hasDataSectionWordSize();
inline ::uint16_t getDataSectionWordSize();
inline void setDataSectionWordSize( ::uint16_t value);
inline bool hasDataWordCount();
inline ::uint16_t getDataWordCount();
inline void setDataWordCount( ::uint16_t value);
inline bool hasPointerSectionSize();
inline ::uint16_t getPointerSectionSize();
inline void setPointerSectionSize( ::uint16_t value);
inline bool hasPointerCount();
inline ::uint16_t getPointerCount();
inline void setPointerCount( ::uint16_t value);
inline bool hasPreferredListEncoding();
inline ::capnp::schema::ElementSize getPreferredListEncoding();
......@@ -2525,44 +2525,44 @@ inline void Node::NestedNode::Builder::setId( ::uint64_t value) {
0 * ::capnp::ELEMENTS, value);
}
inline bool Node::Struct::Reader::hasDataSectionWordSize() const {
inline bool Node::Struct::Reader::hasDataWordCount() const {
return _reader.hasDataField< ::uint16_t>(7 * ::capnp::ELEMENTS);
}
inline bool Node::Struct::Builder::hasDataSectionWordSize() {
inline bool Node::Struct::Builder::hasDataWordCount() {
return _builder.hasDataField< ::uint16_t>(7 * ::capnp::ELEMENTS);
}
inline ::uint16_t Node::Struct::Reader::getDataSectionWordSize() const {
inline ::uint16_t Node::Struct::Reader::getDataWordCount() const {
return _reader.getDataField< ::uint16_t>(
7 * ::capnp::ELEMENTS);
}
inline ::uint16_t Node::Struct::Builder::getDataSectionWordSize() {
inline ::uint16_t Node::Struct::Builder::getDataWordCount() {
return _builder.getDataField< ::uint16_t>(
7 * ::capnp::ELEMENTS);
}
inline void Node::Struct::Builder::setDataSectionWordSize( ::uint16_t value) {
inline void Node::Struct::Builder::setDataWordCount( ::uint16_t value) {
_builder.setDataField< ::uint16_t>(
7 * ::capnp::ELEMENTS, value);
}
inline bool Node::Struct::Reader::hasPointerSectionSize() const {
inline bool Node::Struct::Reader::hasPointerCount() const {
return _reader.hasDataField< ::uint16_t>(12 * ::capnp::ELEMENTS);
}
inline bool Node::Struct::Builder::hasPointerSectionSize() {
inline bool Node::Struct::Builder::hasPointerCount() {
return _builder.hasDataField< ::uint16_t>(12 * ::capnp::ELEMENTS);
}
inline ::uint16_t Node::Struct::Reader::getPointerSectionSize() const {
inline ::uint16_t Node::Struct::Reader::getPointerCount() const {
return _reader.getDataField< ::uint16_t>(
12 * ::capnp::ELEMENTS);
}
inline ::uint16_t Node::Struct::Builder::getPointerSectionSize() {
inline ::uint16_t Node::Struct::Builder::getPointerCount() {
return _builder.getDataField< ::uint16_t>(
12 * ::capnp::ELEMENTS);
}
inline void Node::Struct::Builder::setPointerSectionSize( ::uint16_t value) {
inline void Node::Struct::Builder::setPointerCount( ::uint16_t value) {
_builder.setDataField< ::uint16_t>(
12 * ::capnp::ELEMENTS, value);
}
......
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