RFR: 8368953: Document the reason why Serial/Parallel/G1 use zero as dirty card value [v2]

Thomas Schatzl tschatzl at openjdk.org
Tue Sep 30 13:15:58 UTC 2025


On Tue, 30 Sep 2025 13:12:45 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Hi all,
>> 
>>   please review this trivial change to document the reason for the dirty/clean card value selection.
>> 
>> Testing: local compilation
>> 
>> Thanks,
>>   Thomas
>
> Thomas Schatzl has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Update src/hotspot/share/gc/shared/cardTable.hpp
>  - Update src/hotspot/share/gc/shared/cardTable.hpp

src/hotspot/share/gc/shared/cardTable.hpp line 67:

> 65:   // barrier code by one instruction. Many architectures have a constant-zero
> 66:   // register that can be used for the store, so the dirty value does not need
> 67:   // to be explicitly loaded.

Suggestion:

  // We use 0x00 (zero) to represent dirty and 0xFF to represent clean because
  // this choice reduces the barrier code by one instruction on architectures with
  // a constant-zero register. On such architectures, the dirty value (0x00) is
  // directly accessible through the zero register, eliminating the need to load
  // the value explicitly and thereby saving one instruction

src/hotspot/share/gc/shared/cardTable.hpp line 68:

> 66:   // a constant-zero register. On such architectures, the dirty value (0x00) is
> 67:   // directly accessible through the zero register, eliminating the need to load
> 68:   // the value explicitly and thereby saving one instruction

Suggestion:

  // We use 0x00 (zero) to represent Dirty and 0xFF to represent Clean because
  // this choice reduces the barrier code by one instruction on architectures with
  // a constant-zero register. On such architectures, the Dirty value (0x00) is
  // directly accessible through the zero register, eliminating the need to load
  // the value explicitly and thereby saving one instruction

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27575#discussion_r2391389180
PR Review Comment: https://git.openjdk.org/jdk/pull/27575#discussion_r2391395335


More information about the hotspot-gc-dev mailing list