get rid of struct list packing optimization
This commit is contained in:
parent
8599ffc7a7
commit
9c5b64b98b
4 changed files with 26 additions and 13 deletions
|
@ -1151,8 +1151,7 @@ private:
|
|||
kj::strTree(
|
||||
spaces(indent), " public static final org.capnproto.StructSize STRUCT_SIZE =\n",
|
||||
spaces(indent), " new org.capnproto.StructSize((short)", structNode.getDataWordCount(),
|
||||
",(short)", structNode.getPointerCount(),
|
||||
", org.capnproto.ElementSize.", FIELD_SIZE_NAMES[(int)structNode.getPreferredListEncoding()], ");\n"),
|
||||
",(short)", structNode.getPointerCount(), ");\n"),
|
||||
|
||||
spaces(indent), " public static final class Factory extends org.capnproto.StructFactory<Builder, Reader> {\n",
|
||||
spaces(indent),
|
||||
|
|
|
@ -24,12 +24,10 @@ package org.capnproto;
|
|||
public final class StructSize {
|
||||
public final short data; // number of words in data section
|
||||
public final short pointers; // number of words in pointer section
|
||||
public final byte preferredListEncoding; // a FieldSize
|
||||
|
||||
public StructSize(short data, short pointers, byte preferredListEncoding) {
|
||||
public StructSize(short data, short pointers) {
|
||||
this.data = data;
|
||||
this.pointers = pointers;
|
||||
this.preferredListEncoding = preferredListEncoding;
|
||||
}
|
||||
|
||||
public final int total() {
|
||||
|
|
|
@ -237,12 +237,6 @@ final class WireHelpers {
|
|||
SegmentBuilder segment,
|
||||
int elementCount,
|
||||
StructSize elementSize) {
|
||||
if (elementSize.preferredListEncoding != ElementSize.INLINE_COMPOSITE) {
|
||||
//# Small data-only struct. Allocate a list of primitives instead.
|
||||
return initListPointer(factory, refOffset, segment, elementCount,
|
||||
elementSize.preferredListEncoding);
|
||||
}
|
||||
|
||||
int wordsPerElement = elementSize.total();
|
||||
|
||||
//# Allocate the list, prefixed by a single WirePointer.
|
||||
|
@ -278,7 +272,7 @@ final class WireHelpers {
|
|||
}
|
||||
|
||||
//# We must verify that the pointer has the right size. Unlike
|
||||
//# in getWritableStructListReference(), we never need to
|
||||
//# in getWritableStructListPointer(), we never need to
|
||||
//# "upgrade" the data, because this method is called only for
|
||||
//# non-struct lists, and there is no allowed upgrade path *to*
|
||||
//# a non-struct list, only *from* them.
|
||||
|
@ -326,6 +320,28 @@ final class WireHelpers {
|
|||
StructSize elementSize,
|
||||
SegmentReader defaultSegment,
|
||||
int defaultOffset) {
|
||||
long origRef = WirePointer.get(origSegment.buffer, origRefOffset);
|
||||
int origRefTarget = WirePointer.target(origRefOffset, origRef);
|
||||
|
||||
if (WirePointer.isNull(origRef)) {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
//# We must verify that the pointer has the right size and potentially upgrade it if not.
|
||||
|
||||
FollowBuilderFarsResult resolved = followBuilderFars(origRef, origRefTarget, origSegment);
|
||||
if (WirePointer.kind(resolved.ref) != WirePointer.LIST) {
|
||||
throw new DecodeException("Called getList{Field,Element}() but existing pointer is not a list");
|
||||
}
|
||||
|
||||
byte oldSize = ListPointer.elementSize(resolved.ref);
|
||||
|
||||
if (oldSize == ElementSize.INLINE_COMPOSITE) {
|
||||
// ...
|
||||
} else {
|
||||
// ...
|
||||
}
|
||||
|
||||
throw new Error("getWritableStructListPointer is unimplemented");
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class LayoutSuite extends FunSuite {
|
|||
|
||||
val segment = new SegmentBuilder(buffer, new BuilderArena(BuilderArena.SUGGESTED_FIRST_SEGMENT_WORDS,
|
||||
BuilderArena.SUGGESTED_ALLOCATION_STRATEGY))
|
||||
val factory = new BareStructBuilder(new StructSize(2, 4, ElementSize.INLINE_COMPOSITE));
|
||||
val factory = new BareStructBuilder(new StructSize(2, 4));
|
||||
val builder = WireHelpers.initStructPointer(factory, 0, segment, factory.structSize());
|
||||
setupStruct(builder);
|
||||
checkStruct(builder);
|
||||
|
|
Loading…
Reference in a new issue