src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp

Print this page


   1 /*
   2  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 







  25 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
  26   assert (!oopDesc::is_null(*p), "null weak reference?");
  27   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  28   // weak references are sometimes scanned twice; must check
  29   // that to-space doesn't already contain this object
  30   if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
  31     // we need to ensure that it is copied (see comment in
  32     // ParScanClosure::do_oop_work).
  33     klassOop objK = obj->klass();
  34     markOop m = obj->mark();
  35     oop new_obj;
  36     if (m->is_marked()) { // Contains forwarding pointer.
  37       new_obj = ParNewGeneration::real_forwardee(obj);
  38     } else {
  39       size_t obj_sz = obj->size_given_klass(objK->klass_part());
  40       new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
  41                                                                 obj, obj_sz, m);
  42     }
  43     oopDesc::encode_store_heap_oop_not_null(p, new_obj);
  44   }


  90         if (root_scan) {
  91           // This may have pushed an object.  If we have a root
  92           // category with a lot of roots, can't let the queue get too
  93           // full:
  94           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
  95         }
  96       }
  97       if (gc_barrier) {
  98         // Now call parent closure
  99         par_do_barrier(p);
 100       }
 101     }
 102   }
 103 }
 104 
 105 inline void ParScanWithBarrierClosure::do_oop_nv(oop* p)       { ParScanClosure::do_oop_work(p, true, false); }
 106 inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
 107 
 108 inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p)       { ParScanClosure::do_oop_work(p, false, false); }
 109 inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }


   1 /*
   2  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP
  27 
  28 #include "gc_implementation/parNew/parNewGeneration.hpp"
  29 #include "gc_implementation/parNew/parOopClosures.hpp"
  30 #include "memory/cardTableRS.hpp"
  31 
  32 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
  33   assert (!oopDesc::is_null(*p), "null weak reference?");
  34   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  35   // weak references are sometimes scanned twice; must check
  36   // that to-space doesn't already contain this object
  37   if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
  38     // we need to ensure that it is copied (see comment in
  39     // ParScanClosure::do_oop_work).
  40     klassOop objK = obj->klass();
  41     markOop m = obj->mark();
  42     oop new_obj;
  43     if (m->is_marked()) { // Contains forwarding pointer.
  44       new_obj = ParNewGeneration::real_forwardee(obj);
  45     } else {
  46       size_t obj_sz = obj->size_given_klass(objK->klass_part());
  47       new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
  48                                                                 obj, obj_sz, m);
  49     }
  50     oopDesc::encode_store_heap_oop_not_null(p, new_obj);
  51   }


  97         if (root_scan) {
  98           // This may have pushed an object.  If we have a root
  99           // category with a lot of roots, can't let the queue get too
 100           // full:
 101           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 102         }
 103       }
 104       if (gc_barrier) {
 105         // Now call parent closure
 106         par_do_barrier(p);
 107       }
 108     }
 109   }
 110 }
 111 
 112 inline void ParScanWithBarrierClosure::do_oop_nv(oop* p)       { ParScanClosure::do_oop_work(p, true, false); }
 113 inline void ParScanWithBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, true, false); }
 114 
 115 inline void ParScanWithoutBarrierClosure::do_oop_nv(oop* p)       { ParScanClosure::do_oop_work(p, false, false); }
 116 inline void ParScanWithoutBarrierClosure::do_oop_nv(narrowOop* p) { ParScanClosure::do_oop_work(p, false, false); }
 117 
 118 #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PAROOPCLOSURES_INLINE_HPP