hotspot/src/share/vm/oops/instanceRefKlass.cpp
changeset 20282 7f9cbdf89af2
parent 15482 470d0b0c09f1
child 24424 2658d7834c6e
equal deleted inserted replaced
20281:e4d33bd980c4 20282:7f9cbdf89af2
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    49 void specialized_oop_follow_contents(InstanceRefKlass* ref, oop obj) {
    49 void specialized_oop_follow_contents(InstanceRefKlass* ref, oop obj) {
    50   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
    50   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
    51   T heap_oop = oopDesc::load_heap_oop(referent_addr);
    51   T heap_oop = oopDesc::load_heap_oop(referent_addr);
    52   debug_only(
    52   debug_only(
    53     if(TraceReferenceGC && PrintGCDetails) {
    53     if(TraceReferenceGC && PrintGCDetails) {
    54       gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
    54       gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (void *)obj);
    55     }
    55     }
    56   )
    56   )
    57   if (!oopDesc::is_null(heap_oop)) {
    57   if (!oopDesc::is_null(heap_oop)) {
    58     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
    58     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
    59     if (!referent->is_gc_marked() &&
    59     if (!referent->is_gc_marked() &&
    60         MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) {
    60         MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) {
    61       // reference was discovered, referent will be traversed later
    61       // reference was discovered, referent will be traversed later
    62       ref->InstanceKlass::oop_follow_contents(obj);
    62       ref->InstanceKlass::oop_follow_contents(obj);
    63       debug_only(
    63       debug_only(
    64         if(TraceReferenceGC && PrintGCDetails) {
    64         if(TraceReferenceGC && PrintGCDetails) {
    65           gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
    65           gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, (void *)obj);
    66         }
    66         }
    67       )
    67       )
    68       return;
    68       return;
    69     } else {
    69     } else {
    70       // treat referent as normal oop
    70       // treat referent as normal oop
    71       debug_only(
    71       debug_only(
    72         if(TraceReferenceGC && PrintGCDetails) {
    72         if(TraceReferenceGC && PrintGCDetails) {
    73           gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, obj);
    73           gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, (void *)obj);
    74         }
    74         }
    75       )
    75       )
    76       MarkSweep::mark_and_push(referent_addr);
    76       MarkSweep::mark_and_push(referent_addr);
    77     }
    77     }
    78   }
    78   }
   128                                      oop obj) {
   128                                      oop obj) {
   129   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
   129   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
   130   T heap_oop = oopDesc::load_heap_oop(referent_addr);
   130   T heap_oop = oopDesc::load_heap_oop(referent_addr);
   131   debug_only(
   131   debug_only(
   132     if(TraceReferenceGC && PrintGCDetails) {
   132     if(TraceReferenceGC && PrintGCDetails) {
   133       gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
   133       gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (void *)obj);
   134     }
   134     }
   135   )
   135   )
   136   if (!oopDesc::is_null(heap_oop)) {
   136   if (!oopDesc::is_null(heap_oop)) {
   137     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
   137     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
   138     if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
   138     if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
   140           discover_reference(obj, ref->reference_type())) {
   140           discover_reference(obj, ref->reference_type())) {
   141       // reference already enqueued, referent will be traversed later
   141       // reference already enqueued, referent will be traversed later
   142       ref->InstanceKlass::oop_follow_contents(cm, obj);
   142       ref->InstanceKlass::oop_follow_contents(cm, obj);
   143       debug_only(
   143       debug_only(
   144         if(TraceReferenceGC && PrintGCDetails) {
   144         if(TraceReferenceGC && PrintGCDetails) {
   145           gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
   145           gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, (void *)obj);
   146         }
   146         }
   147       )
   147       )
   148       return;
   148       return;
   149     } else {
   149     } else {
   150       // treat referent as normal oop
   150       // treat referent as normal oop
   151       debug_only(
   151       debug_only(
   152         if(TraceReferenceGC && PrintGCDetails) {
   152         if(TraceReferenceGC && PrintGCDetails) {
   153           gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, obj);
   153           gclog_or_tty->print_cr("       Non NULL normal " INTPTR_FORMAT, (void *)obj);
   154         }
   154         }
   155       )
   155       )
   156       PSParallelCompact::mark_and_push(cm, referent_addr);
   156       PSParallelCompact::mark_and_push(cm, referent_addr);
   157     }
   157     }
   158   }
   158   }