-
Notifications
You must be signed in to change notification settings - Fork 44
Introduce list/set/map constant support #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In other words, this means there's constant pool overhead in each class that uses this mechanism, due to condy, but it's fixed regardless of how many collections/elements are used. Right? |
Looks reasonable on the first sight. |
More or less. Each collection needs one constant pool entry for the collection itself (as of my most recent code). A certain amount of constant pool entries are used by the bootstrap method(s), but those only need to be generated once (per collection type) even if many collections are used in the same class. That's basically it. |
@@ -60,7 +99,7 @@ public abstract sealed class TypeCreatorImpl extends AnnotatableCreatorImpl impl | |||
List<Consumer<BlockCreator>> postInits = List.of(); | |||
private List<Signature.ClassTypeSig> interfaceSigs = List.of(); | |||
private int flags; | |||
private boolean hasLambdaBootstrap; | |||
private int bootstraps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an EnumSet
would work the same here, but we can keep it manual.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I reviewed the condy bootstraps in detail, but overall LGTM.
Introduce two features:
List
/Set
/Map
plain constants (good for less than ~30 elements)List
/Set
/Map
ofString
specifically (no other constant types)The constants are implemented in terms of condy.
The plain constants are a bit greedy with the constant pool. The amount of slots will amortize towards one slot per entry if enough are used, but for smaller collections it could be 2-3 slots per entry. Nevertheless these could be quite handy in certain circumstances where you have a small fixed set of, say, classes that you only use in one or two places and you don't want to go through the ceremony of setting up a field for it.
The resource-backed collections are unbounded in maximum size, however they will take up several constant pool slots (amortizing to 1 per collection if enough are used in one file).