RFR: 8377554: Load card table base and other values via AOTRuntimeConstants in AOT code

Andrew Dinn adinn at openjdk.org
Tue Feb 24 10:00:14 UTC 2026


On Tue, 24 Feb 2026 05:33:55 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Generated stubs and nmethods embed some runtime-derived constants, such as the card table base, directly into code as instruction operands. AOT code generation cannot rely on these constants being valid between the assembly run and a production run and adjusting the constants at load time is not currently supported. So, instead AOT generation must employ code which loads the constants from a table whose address can be relocated at load time.
>
> src/hotspot/cpu/x86/gc/shared/cardTableBarrierSetAssembler_x86.cpp line 151:
> 
>> 149:   if (AOTCodeCache::is_on_for_dump()) {
>> 150:     __ movptr(rscratch, ExternalAddress(AOTRuntimeConstants::card_table_address()));
>> 151:     __ movq(rscratch, rscratch);
> 
> So why do you need this `movq`? I saw you pushed it to fix some issue. What was wrong?

AOTRuntimeConstants::card_table_address() returns the address of the field in the static AOTRuntimeConstants object where the card table address (byte_map_base) is stored. So,

    __ movptr(rscratch, ExternalAddress(AOTRuntimeConstants::card_table_address()));

simply loads the  address of that field into `rscratch`. We need to load via that address to obtain the actual card table address.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29884#discussion_r2845743733


More information about the hotspot-dev mailing list