[code-reflection] RFR: Code model attribute hard-coded [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Dec 4 11:15:57 UTC 2024


On Wed, 4 Dec 2024 11:01:39 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> This is yet another experimental serialization of code model into a custom method attribute.
>> It is based on #282 with all the ops tagged and hard-coded and a bit better utilization of constant pool.
>> 
>> Compiled size of the BytecodeTest class (with text-encoded code models) is 127531 bytes, CP contains 1612 entries.
>> Cleaned size of the class (removed text-encoded code models and their static initialization) is 39044 bytes, CP contains 1277 entries.
>> Size with models encoded in custom attributes is 57206 bytes, CP contains 1452 entries.
>> 
>> Proportional size of the custom attributes vs. text-encoded fields is 21% (52% of the CP entries).
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   code cleanup

src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/CodeModelAttribute.java line 37:

> 35: public class CodeModelAttribute extends CustomAttribute<CodeModelAttribute>{
> 36: 
> 37:     enum Tag {

In terms of maintenance, I wonder if there could be a way to connect the tag more directly to the op classes. E.g. so that if an op is added/removed, we may rely on static checks to detect that our reading/writing logic needs updating.

But maybe that works already: after all, the writing logic does a switch on the `op` instance - if that switch is made exhaustive, we could prevent mistakes when new ops are added. (when ops are removed, the mistake will be detected more easily, as the serialization code will refer to no longer existing classes).

-------------

PR Review Comment: https://git.openjdk.org/babylon/pull/290#discussion_r1869262885


More information about the babylon-dev mailing list