null-check in G1KeepAliveClosure::do_oop() - needed?

Tony Printezis tprintezis at twitter.com
Mon Sep 8 14:19:16 UTC 2014


Hi all,

I was a bit perplexed by the following code:

class G1KeepAliveClosure: public OopClosure {
   ...
   void do_oop(oop* p) {
     oop obj = *p;

     G1CollectedHeap::in_cset_state_t cset_state = _g1->in_cset_state(obj);
     if (obj == NULL || cset_state == G1CollectedHeap::InNeither) {
       return;
     }

Is the NULL check needed (can obj actually be NULL)? If it is, why is it 
done after the look-up in in_cset_state()? And is in_cset_state() 
actually robust wrt obj being NULL?

Tony

-- 
Tony Printezis | JVM/GC Engineer / VM Team | Twitter

@TonyPrintezis
tprintezis at twitter.com




More information about the hotspot-gc-dev mailing list