On Thu, 18 Dec 2025 17:15:35 GMT, Mikhail Ablakatov <[email protected]> wrote:
> > Wouldn't it be better to move the whole CodeBlob header out of the code > > cache? Instead of nmethod having a _hdr pointer, CodeBlob would be in > > malloc space and have a _code pointer into the CodeCache. > > It might be possible to move both `CodeBlob` and `nmethod` data to the > C-heap. We'd still need something like an `_hdr` pointer, since JVM resolves > a `CodeBlob` from a method/stub entry point using [`CodeBlob* > CodeCache::find_blob(void* > start)`](https://github.com/openjdk/jdk/blob/7a7e7c9ae11cb124c14d5d2d3b7e2f5649205106/src/hotspot/share/code/codeCache.cpp#L640). > So if we move every member field to the C-heap, we store a pointer to that > data right before a method/stub entry point in the CodeCache and that's it. A > `_code` pointer pointing from the C-heap into the CodeCache may not be > necessary at all. > > That said, this would require moving data for other `CodeBlob` subclasses > (`AdapterBlob`, `ExceptionBlob`, etc.) to the C-heap, which would > significantly broaden the scope of this patch. > > @Bhavana-Kilambi , what do you thing? Is this something you've considered? That could be feasible, we might need to store two pointers - 1. An off-heap `CodeBlob` field - `_code` pointing to the start of its CodeHeap block. Boundary accessors in `CodeBlob` like `code_begin()`, `code_end()`, `data_begin()` etc would derive from this pointer 2. A tiny back-pointer at the start of each `CodeHeap` block that holds the owning `CodeBlob*`. This might be needed by `CodeCache::find_blob(void* start)` to return the off-heap `CodeBlob*` However, I do agree with @mikabl-arm that this significantly broadens the scope of this patch. Moving the entire `CodeBlob` object out of the CodeCache touches every blob subtype, SA, any code that walks/iterates through all blobs in the code cache etc. From what we have observed, a considerable part of the `CodeCache` is occupied mainly by the non-profiled and profiled nmethods. Thus, the goal of this patch is to reduce the footprint of the nmethod object first (to make them as compact as possible), without changing the global lookup paths. Would it be okay for us to keep the current scope of this patch to move the nmethod header to off-heap memory and maybe create a new RFE to explore moving CodeBlob header to off-heap memory? ------------- PR Comment: https://git.openjdk.org/jdk/pull/28866#issuecomment-3682508777
