How does ZGC process objects newly created during concurrent marking?

Stefan Karlsson stefan.karlsson at oracle.com
Mon Feb 24 19:07:53 UTC 2020


Hi Ralph,

On 2020-02-24 19:12, raell at web.de wrote:
> Hi,
>
> I'm just curious how ZGC processes objects, that are newly created during concurrent marking:
>
> Suppose concurrent marking is running, and after object x has been marked, the mutator executes
> x.f = new Object();
>
> How does ZGC process this case?
> Are the new objects implicitly considered live by using a TAMS (as Shenandoah does)?

We don't use a TAMS, instead we track if ZPages (heap regions) are 
allocated/reused before or after the last mark start. Objects in pages 
allocated after mark start are considered live.

You can see the code for that here:

https://hg.openjdk.java.net/jdk/jdk/file/d33754052039/src/hotspot/share/gc/z/zMark.cpp#l318

bool ZMark::try_mark_object(ZMarkCache* cache, uintptr_t addr, bool 
finalizable) {  ZPage* const page = _page_table->get(addr);
if (page->is_allocating()) {
// Newly allocated objects are implicitly marked
return false;
} 
https://hg.openjdk.java.net/jdk/jdk/file/d33754052039/src/hotspot/share/gc/z/zPage.inline.hpp 
inline bool ZPage::is_allocating() const { return _seqnum == 
ZGlobalSeqNum; } When marking starts we update the ZGlobalSeqNum: 
https://hg.openjdk.java.net/jdk/jdk/file/d33754052039/src/hotspot/share/gc/z/zMark.cpp 

void ZMark::prepare_mark() { // Increment global sequence number to 
invalidate // marking information for all pages. ZGlobalSeqNum++; And 
when pages are allocated/reused we set its _seqnum; 
https://hg.openjdk.java.net/jdk/jdk/file/d33754052039/src/hotspot/share/gc/z/zPage.cpp 
void ZPage::reset() {
_seqnum = ZGlobalSeqNum; HTH, StefanK

> Thank you very much!
>
> Ralph



More information about the zgc-dev mailing list