Skip to content

JDK-8304884: Update Bytecodes data to be mostly compile time constants#13179

Closed
jcking wants to merge 6 commits intoopenjdk:masterfrom
jcking:bytecodes-static
Closed

JDK-8304884: Update Bytecodes data to be mostly compile time constants#13179
jcking wants to merge 6 commits intoopenjdk:masterfrom
jcking:bytecodes-static

Conversation

@jcking
Copy link
Contributor

@jcking jcking commented Mar 24, 2023

Change uses a few tricks to make most of the data in Bytecodes compile time constant, avoiding the overhead during VM initialization. Bytecodes:_flags likely can be made compile time constant as well using constexpr tricks, but that is out of scope for this specific PR.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8304884: Update Bytecodes data to be mostly compile time constants

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13179/head:pull/13179
$ git checkout pull/13179

Update a local copy of the PR:
$ git checkout pull/13179
$ git pull https://git.openjdk.org/jdk.git pull/13179/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13179

View PR using the GUI difftool:
$ git pr show -t 13179

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13179.diff

jcking added 2 commits March 24, 2023 09:08
Signed-off-by: Justin King <jcking@google.com>
Signed-off-by: Justin King <jcking@google.com>
@bridgekeeper
Copy link

bridgekeeper bot commented Mar 24, 2023

👋 Welcome back jcking! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 24, 2023
@openjdk
Copy link

openjdk bot commented Mar 24, 2023

@jcking The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Mar 24, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 24, 2023

Webrevs

@TheShermanTanker
Copy link
Contributor

Not a review, but I want to point out that Bytecodes::_flags is declared as a jchar and defined as an unsigned short, might probably be helpful and less confusing to make it an unsigned short in both places. No comment on the other changes

Signed-off-by: Justin King <jcking@google.com>
@jcking
Copy link
Contributor Author

jcking commented Mar 24, 2023

Not a review, but I want to point out that Bytecodes::_flags is declared as a jchar and defined as an unsigned short, might probably be helpful and less confusing to make it an unsigned short in both places. No comment on the other changes

Switched to jcharin both places.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable. Some suggested changes.

#undef BYTECODE_JAVA_CODE
};

jchar Bytecodes::_flags[(1<<BitsPerByte)*2];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not _flags[Bytecodes::number_of_codes] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be Bytecodes::number_of_codes * 2. Two entry per byte-code. One for the normal format and one for wide. Wasn't sure if it was safe or some code was relying on there being exactly 512 entries even if bytecode count is less than 256.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this was put in (JDK-6939207) the flags were arranged so that the two forms were at index N and N+256 rather than index N and N+number_of_codes. That seems to remain the case today - just grep for 1<<BitsPerByte

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see.

jcking added 2 commits March 24, 2023 15:54
Signed-off-by: Justin King <jcking@google.com>
Signed-off-by: Justin King <jcking@google.com>
@jcking
Copy link
Contributor Author

jcking commented Mar 24, 2023

/reviewers 2

@openjdk
Copy link

openjdk bot commented Mar 24, 2023

@jcking
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes seem okay - unfortunately a lot of noise in the PR diff that obscures actual changes.

A couple of queries.

Thanks.

}
};

#define STRING_SIZE(string) StringLiteralSize::invoke(string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you simply use:

#define STRING_SIZE(string) (sizeof(string) - 1)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, due to nullptr for the wide_format. That was my first instinct as well, then I saw nullptr.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see.

Signed-off-by: Justin King <jcking@google.com>
Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good.

#undef BYTECODE_JAVA_CODE
};

jchar Bytecodes::_flags[(1<<BitsPerByte)*2];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see.

@openjdk
Copy link

openjdk bot commented Mar 27, 2023

@jcking This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8304884: Update Bytecodes data to be mostly compile time constants

Reviewed-by: coleenp, dholmes

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 31 new commits pushed to the master branch:

  • 4f625c0: 8304543: Modernize debugging jvm args in test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/value/value004.java
  • 426025a: 8303526: Changing "arbitrary" Name.compareTo() ordering breaks the regression suite
  • 6aec6f3: 8304931: vm/concepts/methods/methods001/methods00101m1/methods00101m1 failures with already pending exception
  • 63ce88b: 8304147: JVM crash during shutdown when dumping dynamic archive
  • 554bccf: 8304448: Kitchensink failed: assert(!thread->is_in_any_VTMS_transition()) failed: class prepare events are not allowed in any VTMS transition
  • 3b88b2a: 8304761: Update IANA Language Subtag Registry to Version 2023-03-22
  • f8e8fc7: 8177352: Calendar.getDisplayName(s) in non-lenient mode inconsistent, does not match spec
  • 14b970d: 8296656: java.lang.NoClassDefFoundError exception on running fully legitimate code
  • 80e2d52: 8302558: Editable JComboBox's popup blocks user from seeing characters in Aqua look and feel
  • 6c3b10f: 8303485: Replacing os.name for operating system customization
  • ... and 21 more: https://git.openjdk.org/jdk/compare/f96aee74010476a850175f7012c196e40a31c188...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 27, 2023
@jcking
Copy link
Contributor Author

jcking commented Mar 28, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Mar 28, 2023

Going to push as commit 32ef452.
Since your change was applied there have been 39 commits pushed to the master branch:

  • 927e674: 8300977: Retire java.io.ExpiringCache
  • c90699e: 8304989: unnecessary dash in @param gives double-dash in docs
  • 395a4ce: 8304591: (fs) UnixPath.stringValue need not be volatile
  • 60640a2: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream
  • cddaf68: 8304962: sun/net/www/http/KeepAliveCache/B5045306.java: java.lang.RuntimeException: Failed: Initial Keep Alive Connection is not being reused
  • a06f461: 8303214: Typo in java.util.Collections#synchronizedNavigableMap javadoc
  • 7987ad4: 8304412: Serial: Refactor old generation cards update after Full GC
  • 3c4cd50: 8304963: HttpServer closes connection after processing HEAD after JDK-7026262
  • 4f625c0: 8304543: Modernize debugging jvm args in test/hotspot/jtreg/vmTestbase/nsk/jdi/Argument/value/value004.java
  • 426025a: 8303526: Changing "arbitrary" Name.compareTo() ordering breaks the regression suite
  • ... and 29 more: https://git.openjdk.org/jdk/compare/f96aee74010476a850175f7012c196e40a31c188...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 28, 2023
@openjdk openjdk bot closed this Mar 28, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 28, 2023
@openjdk
Copy link

openjdk bot commented Mar 28, 2023

@jcking Pushed as commit 32ef452.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants