RFR: 8337225: Demote maxStack and maxLocals from CodeModel to CodeAttribute
Adam Sotona
asotona at openjdk.org
Fri Jul 26 08:05:33 UTC 2024
On Thu, 25 Jul 2024 22:41:08 GMT, Chen Liang <liach at openjdk.org> wrote:
> As discussed in offline meeting, the max stack and locals information are part of the code attribute and not meaningful for buffered code elements. Computation would be costly and these see no real usage during transformations. Thus, the proposed solution is to move these APIs to be CodeAttribute specific, as this is already how all these APIs' users are using.
>
> Also removed useless `Writable` on buffered models, and fixed `BufferedMethodBuilder::code` implementation.
src/java.base/share/classes/jdk/internal/classfile/impl/BufferedCodeBuilder.java line 67:
> 65: this.maxLocals = Util.maxLocals(methodInfo.methodFlags(), methodInfo.methodTypeSymbol());
> 66: if (original != null)
> 67: this.maxLocals = Math.max(this.maxLocals, original.maxLocals());
`original::maxLocals`set the counter for `CodeBuilder::allocateLocal`
By restricting calculation of maxLocals to "origin instanceof CodeAttribute" may cause invalid locals allocations for chained code builders. The number might not be exposed in the API, however we need to know it internally.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20338#discussion_r1692669453
More information about the core-libs-dev
mailing list