Skip to content

[GR-73160] [GR-73874] [GR-74022] [GR-74023] Porting ImageHeapPrimitiveArray for Terminus#13188

Open
graalvmbot wants to merge 1 commit intomasterfrom
d-kozak/GR-73160/image-heap-primitive-array-terminus-refactor
Open

[GR-73160] [GR-73874] [GR-74022] [GR-74023] Porting ImageHeapPrimitiveArray for Terminus#13188
graalvmbot wants to merge 1 commit intomasterfrom
d-kozak/GR-73160/image-heap-primitive-array-terminus-refactor

Conversation

@graalvmbot
Copy link
Collaborator

This PR refactors ImageHeapPrimitiveArray to be Terminus-compliant. The copy of the array created by PrimitiveArrayData is now represented by a JavaConstant living in the guest and the usages have been updated to operate on the JavaConstant instead of the raw array.

As a side task, this PR also introduces VMAccess.readPrimitiveArrayUnaligned,VMAccess.createPrimitiveArray, and EspressoExternalSnippetReflectionProvider.forObject(Object) for primitive arrays, which were helpful to achieving the goal of the PR and should also be useful in general.


Automated PR Summary

This PR ports the ImageHeapPrimitiveArray infrastructure for the Terminus project, refactoring its implementation to store array data as JavaConstant instead of raw primitive arrays. The changes fully migrate array creation, manipulation, serialization, and deserialization logic to operate on the JavaConstant abstraction, improving consistency and compatibility with shared image heap approaches.

Key Changes:

  • Replaces usage of raw primitive arrays in ImageHeapPrimitiveArray with JavaConstant to represent the snapshot of primitive array data.
  • Updates array cloning, serialization, deserialization, and element access logic to use JavaConstant methods (readArrayElement, asArrayConstant, etc.).
  • Refactors HeapSnapshotVerifier, ImageHeapScanner, NativeImageHeapWriter, and SVMImageLayerLoader to use the new representation when reading, writing, or patching primitive arrays.
  • Fixes all relevant code paths, such as copying array data and setting elements, to operate via the meta-level representation rather than direct Java arrays.
  • Adds/refactors array unwrapping logic in the image heap writer to construct primitive arrays for serialization using the new JavaConstant representation.

Jira Issue Resolution:

  • GR-73160 — Fully addressed
    The ticket requires refactoring ImageHeapPrimitiveArray$PrimitiveArrayData to avoid holding raw array references and switch to using JavaConstant. This PR fully implements that change, updating all affected array instantiation, access, patching, and serialization logic to work with JavaConstant as the authoritative primitive array data. The migration is completed across platform and image heap infrastructure.

Source: System Prompt | User Template

As a side task, introduce VMAccess#createPrimitiveArray, readPrimitiveArrayUnaligned, and EspressoExternalSnippetReflectionProvider#forObject
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants