Skip to content

Fix signedness error of max LOS size in C2#347

Closed
wks wants to merge 1 commit intommtk:jdk-11from
wks:fix/max_non_los_bytes_c2-jdk11
Closed

Fix signedness error of max LOS size in C2#347
wks wants to merge 1 commit intommtk:jdk-11from
wks:fix/max_non_los_bytes_c2-jdk11

Conversation

@wks
Copy link
Copy Markdown
Contributor

@wks wks commented Mar 18, 2026

The PlanConstraints::max_non_los_default_alloc_bytes constant is a usize and can be usize::MAX for some plans including NoGC. The C2 code erroneously considered it signed and did signed comparison against object sizes. Consequently, when allocating dynamically sized arrays, the C2-generated code always goes to the slow path. It slows down certain workloads (such as hsqldb and luindex in DaCapo 2006) by 20% in total time.

We fix this bug by always performing 64-bit unsigned comparison.

The `PlanConstraints::max_non_los_default_alloc_bytes` constant is a
`usize` and can be `usize::MAX` for some plans including NoGC.  The C2
code erroneously considered it signed and did signed comparison against
object sizes.  Consequently, when allocating dynamically sized arrays,
the C2-generated code always goes to the slow path.  It slows down
certain workloads (such as hsqldb and luindex in DaCapo 2006) by 20% in
total time.

We fix this bug by always performing 64-bit unsigned comparison.
@wks
Copy link
Copy Markdown
Contributor Author

wks commented Mar 19, 2026

Several DaCapo tests failed during "Fetch dacapo-23.9-RC3-chopin cache". It looks like some transient network error.

@wks wks requested a review from qinsoon March 21, 2026 01:01
@wks
Copy link
Copy Markdown
Contributor Author

wks commented Mar 23, 2026

We have used Mergify to backport the PR for jdk-21 to jdk-11.

#350

@wks wks closed this Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant