JDK-8239003 : [lworld] C2 should respect larval state when scalarizing
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: repo-valhalla
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2020-02-13
  • Updated: 2025-05-12
  • Resolved: 2025-05-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaResolved
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Currently, Unsafe.makePrivateBuffer returns an inline type. As a result, C2 attempts scalarization which leads to incorrect results.

We would need to:
- Make sure private buffers are never scalarized (also not in safepoints)
- Be careful when removing redundant allocations to not replace larval buffer allocations by "normal" buffer allocations
- Make sure the Unsafe.get*/put* operations have an effect
- Scalarize only after finishPrivateBuffer

This manifests, for example, with TestIntrinsics when being executed with -XX:DisableIntrinsic=_putInt because the call to Unsafe.putInt has no effect on the scalarized inline type.

Also, code like this currently crashes C2's typesystem:
    MyValue incrementAndCheckUnsafe() {
        MyValue vt = U.makePrivateBuffer(this);
        U.putInt(vt, X_OFFSET, x + 1);
        U.putInt(vt, Y_OFFSET, y + 1);
        return vt;
    }

This also manifests with tests being executed with -XX:+DeoptimizeALot.
Comments
I'm tentatively closing this as duplicate of JDK-8335256 as discussed in the corresponding PR. Please re-open (or preferably file a new bug) if there are issues left.
12-05-2025

A pull request was submitted for review. URL: https://git.openjdk.org/valhalla/pull/964 Date: 2023-12-20 13:34:08 +0000
20-12-2023

See "// TODO 8239003" in the code
14-09-2022

TestIntrinsics.java currently disables DeoptimizeALot. We should re-enable it once this is fixed.
24-01-2022