Skip to content

Change return type of TR_FrontEnd::getStringUTF8Length to int32_t - #7620

Merged
jdmpapin merged 1 commit into
eclipse-omr:masterfrom
hzongaro:long-utf8-string-length
Feb 18, 2025
Merged

jdmpapin merged 1 commit into
eclipse-omr:masterfrom
hzongaro:long-utf8-string-length

Conversation

@hzongaro

Copy link
Copy Markdown
Contributor

A String object that might consist of up to 231-1 chars could require up to three times as many bytes as chars to be encoded in UTF-8. The current return type of getUTF8StringLength - intptr_t - is unable to correctly represent all valid lengths in 32-bit mode.

This change makes the return type of the existing TR_FrontEnd::getStringUTF8Length method int32_t. It must only be used in situations where it is known that the UTF-8 encoded length of the String will not exceed 231-1 bytes.

This change also introduces a new getUTF8StringUnabbreviatedLength method whose return type of uint64_t is able to represent all possible UTF-8 encoded string lengths.

@hzongaro

Copy link
Copy Markdown
Contributor Author

@jdmpapin, may I ask you to review this change along with the corresponding downstream changes in OpenJ9 pull request eclipse-openj9/openj9#21005?

A String object that might consist of up to 2^31-1 chars could require
up to three times as many bytes as chars to be encoded in UTF-8.  The
current return type of getUTF8StringLength - intptr_t - is unable to
correctly represent all valid lengths in 32-bit mode.

This change makes the return type of the existing
TR_FrontEnd::getStringUTF8Length method int32_t.  It must only be used
in situations where it is known that the UTF-8 encoded length of the
String will not exceed 2^31-1 bytes.

This change also introduces a new getUTF8StringUnabbreviatedLength
method whose return type of uint64_t is able to represent all possible
UTF-8 encoded string lengths.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
@hzongaro
hzongaro force-pushed the long-utf8-string-length branch from 066d695 to 4906d18 Compare February 3, 2025 14:10
@jdmpapin

Copy link
Copy Markdown
Contributor

Jenkins build all

@jdmpapin
jdmpapin merged commit a8427e4 into eclipse-omr:master Feb 18, 2025
@hzongaro
hzongaro deleted the long-utf8-string-length branch February 9, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants