Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

Virtualize native memory in Espresso
Adjustments were made such that all guest memory accesses now are going through this NativeMemory class.
Implemenations of NativeMemory include:
- Unsafe NativeMemory (it accesses the host memory and forwards it to the guest)
- ByteArray NativeMemory (Memory gets divided into chunks and every chunk holds an addressable byte-array)
- MemorySegmemt NativeMemory (Memory gets divided into chunks and every chunk holds an addressable MemorySegment)

Elia Trachsel added 3 commits December 10, 2025 11:05
An abstract NativeMemory class was added and linked as a field to NativeAccess. Moreover the newly added EspressoOption.nativeMemory enables selecting native memory implementations. Currently this is only available with the no-native backend since there needs to be strong synergy between Java and Native reads and writes to native memory.
Implemenations of NativeMemory include:
- Unsafe NativeMemory (it accesses the host memory and forwards it to the guest)
- ByteArray NativeMemory (Memory gets divided into chunks and every chunk holds an addressable byte-array)
- MemorySegmemt NativeMemory (Memory gets divided into chunks and every chunk holds an addressable MemorySegmemt)
Basically just makes EspressoLibs use the newly added NativeMemory interface. Meaning all function that involved off-heap accesses were rewritten.
Additionally the functionaily to read and write from certain address in TruffleIO was added.
Ensures that all memory operations in Espresso flow through the NativeMemory layer.
This mainly involves adapting Unsafe substitutions and the NativeUtils class. For the latter, we needed to ensure that all callers pass a NativeMemory instance to the called static methods. In most cases, this was straightforward as the caller had access to the context, but for the structs, it required some rewriting of the StructProcessor class.
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 10, 2025
@graalvmbot graalvmbot merged commit 6a98792 into master Dec 10, 2025
13 checks passed
@graalvmbot graalvmbot deleted the et/e/native_memory branch December 10, 2025 20:25
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.

1 participant