Skip to content

Removes unnecessary zero init on new arrays - #24189

Merged
hzongaro merged 1 commit into
eclipse-openj9:masterfrom
IBMJimmyk:stringskipZeroInit
Jun 30, 2026
Merged

Removes unnecessary zero init on new arrays#24189
hzongaro merged 1 commit into
eclipse-openj9:masterfrom
IBMJimmyk:stringskipZeroInit

Conversation

@IBMJimmyk

Copy link
Copy Markdown
Contributor

Removes zero initialization for trusted String methods that are known never to read elements that were not initialized. This includes:

java_lang_String_encode8859_1
java_lang_String_encodeASCII
java_lang_String_encodeUTF8_UTF16
java_lang_String_init_int_String_int_String_String java_lang_String_init_String_char
java_lang_String_newStringUTF8NoRepl
java_lang_String_repeat
java_lang_StringLatin1_replace_CharSequence
java_lang_StringLatin1_toBytes
java_lang_StringLatin1_toBytes_III
java_lang_StringLatin1_toChars
java_lang_StringLatin1_toLowerCase
java_lang_StringLatin1_toUpperCase
java_lang_StringUTF16_compress_BII
java_lang_StringUTF16_compress_CII
java_lang_StringUTF16_compress_III
java_lang_StringUTF16_replace_CharSequence
java_lang_StringUTF16_toBytes_C
java_lang_StringUTF16_toBytesSup
java_lang_StringUTF16_toChars

The zero initialization can be restored by setting the TR_DisableStringZeroInitSkips envvar.

Cleans up formatting for code related to recognized String methods to make it easier to read.

@IBMJimmyk
IBMJimmyk force-pushed the stringskipZeroInit branch from 343f916 to 3f5fdf1 Compare June 19, 2026 20:12
@IBMJimmyk IBMJimmyk changed the title WIP: Removes unnecessary zero init on new arrays Removes unnecessary zero init on new arrays Jun 19, 2026
@IBMJimmyk

Copy link
Copy Markdown
Contributor Author

@hzongaro Can you take a look when you get the chance?

@vijaysun-omr This may be of interest to you.

@hzongaro
hzongaro self-requested a review June 26, 2026 17:39
@hzongaro hzongaro self-assigned this Jun 26, 2026

@hzongaro hzongaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall, I think the changes look good.

In the process of reviewing, I tripped across some code in TR_J9ByteCodeIlGenerator:: that marks some calls to Arrays.copyOf as not requiring zero initialization. I wonder whether any of the methods in String, StringLatin1 or StringUTF16 that you've identified could also be be included there.

That doesn't necessarily need to be resolved as part of this pull request. It could be investigated as a follow up item.

Comment thread runtime/compiler/il/J9MethodSymbol.cpp Outdated
@IBMJimmyk
IBMJimmyk force-pushed the stringskipZeroInit branch from 3f5fdf1 to a98557d Compare June 29, 2026 20:13

@hzongaro hzongaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it looks good. May I ask you to revise the commit comment to reflect the changes to the environment variables?

I will go ahead and approve this change in the meanwhile.

Removes zero initialization for trusted String methods that are known
never to read elements that were not initialized. This includes:

java_lang_String_encode8859_1
java_lang_String_encodeASCII
java_lang_String_encodeUTF8_UTF16
java_lang_String_init_int_String_int_String_String
java_lang_String_init_String_char
java_lang_String_newStringUTF8NoRepl
java_lang_String_repeat
java_lang_StringLatin1_replace_CharSequence
java_lang_StringLatin1_toBytes
java_lang_StringLatin1_toBytes_III
java_lang_StringLatin1_toChars
java_lang_StringLatin1_toLowerCase
java_lang_StringLatin1_toUpperCase
java_lang_StringUTF16_compress_BII
java_lang_StringUTF16_compress_CII
java_lang_StringUTF16_compress_III
java_lang_StringUTF16_replace_CharSequence
java_lang_StringUTF16_toBytes_C
java_lang_StringUTF16_toBytesSup
java_lang_StringUTF16_toChars

The zero initialization can be restored by setting the
TR_DisableStringZeroInitSkipsSet2 envvar.

The envvar TR_DisableStringZeroInitSkipsSet1 has also been added as an
option to disable the pre existing zero initialization skips.

Cleans up formatting for code related to recognized String methods to
make it easier to read.

Signed-off-by: jimmyk <jimmyk@ca.ibm.com>
@IBMJimmyk
IBMJimmyk force-pushed the stringskipZeroInit branch from a98557d to 277a032 Compare June 29, 2026 20:58
@IBMJimmyk

Copy link
Copy Markdown
Contributor Author

I fixed the commit message.

@hzongaro

Copy link
Copy Markdown
Member

Jenkins test sanity.functional,sanity.openjdk all jdk8,jdk11,jdk21

@hzongaro

Copy link
Copy Markdown
Member

Looks like sanity.functional s390x_linux testing was aborted. Restarting. . . .

Jenkins test sanity.functional zlinux jdk21

@hzongaro

Copy link
Copy Markdown
Member

@IBMJimmyk, may I ask you to have a look through the test failures to ensure they are all known issues?

@IBMJimmyk

Copy link
Copy Markdown
Contributor Author

I can try looking at the failures.

@IBMJimmyk

Copy link
Copy Markdown
Contributor Author

The sanity.functional failures are all SCC related that look like this failure:
#22758

I am still looking at the openjdk failures.

@IBMJimmyk

Copy link
Copy Markdown
Contributor Author

The openjdk failures look exactly like these two:
#17743
#14692

@hzongaro I've checked all of the failures and they are all existing issues.

@hzongaro

Copy link
Copy Markdown
Member

I've checked all of the failures and they are all existing issues.

Thank you!

As all failures are due to known issues, I will merge this change.

@hzongaro
hzongaro merged commit 0cbd3a9 into eclipse-openj9:master Jun 30, 2026
72 of 76 checks passed
@IBMJimmyk
IBMJimmyk deleted the stringskipZeroInit branch July 3, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants