On Fri, 3 Mar 2023 16:39:41 GMT, Adam Sotona <asot...@openjdk.org> wrote:

>> This is root pull request with Classfile API implementation, tests and 
>> benchmarks initial drop into JDK.
>> 
>> Following pull requests consolidating JDK class files parsing, generating, 
>> and transforming 
>> ([JDK-8294957](https://bugs.openjdk.org/browse/JDK-8294957)) will chain to 
>> this one.
>> 
>> Classfile API development is tracked at:
>> https://github.com/openjdk/jdk-sandbox/tree/classfile-api-branch
>> 
>> Development branch of consolidated JDK class files parsing, generating, and 
>> transforming is at:
>> https://github.com/openjdk/jdk-sandbox/tree/classfile-api-dev-branch
>> 
>> Classfile API [JEP](https://bugs.openjdk.org/browse/JDK-8280389) and [online 
>> API 
>> documentation](https://htmlpreview.github.io/?https://raw.githubusercontent.com/openjdk/jdk-sandbox/classfile-api-javadoc-branch/doc/classfile-api/javadoc/java.base/jdk/internal/classfile/package-summary.html)
>>  is also available.
>> 
>> Please take you time to review this non-trivial JDK addition.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with three additional 
> commits since the last revision:
> 
>  - fixed AccessFlags javadoc
>  - TransformImpl.FakeXyzTransform renamed to UnresolvedXyzTransform
>  - removed obsolete generic parameter from AbstractDirectBuilder

src/java.base/share/classes/jdk/internal/classfile/impl/CodeImpl.java line 52:

> 50:     static final Instruction[] SINGLETON_INSTRUCTIONS = new 
> Instruction[256];
> 51: 
> 52:     static {

Can we loop through all `Opcode` values filter for `sizeIfFixed == 1` and 
switch on the kind? If so that would avoid the need for explicit lists and 
simplify the code.

src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java line 176:

> 174:     }
> 175: 
> 176:     public static long nextPowerOfTwo( long x ) {

If you like you can change the implementation to be:

x = -1 >>> Long.numberOfLeadingZeros(x - 1);
return x + 1;

See `ConcurrentHashMap`.

src/java.base/share/classes/jdk/internal/classfile/impl/Util.java line 84:

> 82:                     }
> 83:             }
> 84:         }

Suggestion:

        loop: for (int i = 1; i < type.length(); ++i) {
            switch (type.charAt(i)) {
                case '[':
                    bs.set(i);
                    while (type.charAt(++i) == '[')
                        ;
                    if (type.charAt(i) == 'L') {
                        while (type.charAt(++i) != ';')
                            ;
                    }
                    break;
                case ')':
                    break loop;
                default:
                    bs.set(i);
                    if (type.charAt(i) == 'L') {
                        while (type.charAt(++i) != ';')
                            ;
                    }
            }
        }

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

PR: https://git.openjdk.org/jdk/pull/10982

Reply via email to