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

Albert Mingkun Yang ayang at openjdk.org
Tue Sep 30 12:47:46 UTC 2025


On Tue, 30 Sep 2025 11:43:10 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

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

> 62:   inline size_t compute_byte_map_size(size_t num_bytes);
> 63: 
> 64:   // We use 0x00 (zero) as "dirty" and 0xff as "clean" because this reduces the

I think the first sentence can be a bit misleading -- it should be quantified to "certain architectures". This saving-by-one-instruction is not universal.

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_r2391293974


More information about the hotspot-gc-dev mailing list