RFR: 8357060: [premain] assert(left >= right) failed: avoid underflow [v2]
Ashutosh Mehra
asmehra at openjdk.org
Sat May 17 02:16:23 UTC 2025
> This PR fixes a few things in the premain:
> 1. When storing metadata in aot code cache, `AOTCacheAccess::delta_from_shared_address_base` was incorrectly using `SharedBaseAddress` for computing the offset. It should be using `MetaspaceShared::requested_base_address` because we convert the input address to the requested address.
> 2. Fixing the above issue results in crash in C1 and C2 compiled code during production run because CompressedKlassPointer::base() value was hardcoded in the generated code. In mainline we emit relocation for `CompressedKlassPointer::base()`. This patch adds the same changes to premain. In addition to that, it also modifies `MacroAssembler::decode_and_move_klass_not_null` and `MacroAssembler::encode_and_move_klass_not_null` which are used by C2 compiled code.
> 3. Fixing 2 reveals another problem when preload the code. `AOTCodeEntry::_method` can be invalid if the AOT Cache gets mapped to different address than the "requested" address, and can result in crash when accessing `AOTCodeEntry::_method` during preload. Fix is to store the offset of the `AOTCodeEntry::_method` and use the offset on load to get the correct Method pointer.
> 4. While working on this issue, I realized archived `AOTCodeCache::compile_nmethod` is using archived nmethod to print the assembly. This results in crash as archived nmethod has some state cleaned up. Updated `AOTCodeCache::compile_nmethod` to fix this issue.
Ashutosh Mehra has updated the pull request incrementally with two additional commits since the last revision:
- Fix compile failure in zero variant
Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
- Add methods in AOTCacheAccess to convert offset to appropriate metadata pointer
Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
-------------
Changes:
- all: https://git.openjdk.org/leyden/pull/68/files
- new: https://git.openjdk.org/leyden/pull/68/files/799f6fd2..82567bab
Webrevs:
- full: https://webrevs.openjdk.org/?repo=leyden&pr=68&range=01
- incr: https://webrevs.openjdk.org/?repo=leyden&pr=68&range=00-01
Stats: 23 lines in 3 files changed: 11 ins; 7 del; 5 mod
Patch: https://git.openjdk.org/leyden/pull/68.diff
Fetch: git fetch https://git.openjdk.org/leyden.git pull/68/head:pull/68
PR: https://git.openjdk.org/leyden/pull/68
More information about the leyden-dev
mailing list