< prev index next >

src/hotspot/share/gc/cms/parOopClosures.inline.hpp

Print this page
rev 49289 : 8199735: Mark word updates need to use Access API
   1 /*
   2  * Copyright (c) 2007, 2017, 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_CMS_PAROOPCLOSURES_INLINE_HPP
  26 #define SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP
  27 
  28 #include "gc/cms/cmsHeap.hpp"
  29 #include "gc/cms/parNewGeneration.hpp"
  30 #include "gc/cms/parOopClosures.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genOopClosures.inline.hpp"
  33 #include "logging/log.hpp"
  34 #include "logging/logStream.hpp"

  35 
  36 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
  37   assert (!oopDesc::is_null(*p), "null weak reference?");
  38   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  39   // weak references are sometimes scanned twice; must check
  40   // that to-space doesn't already contain this object
  41   if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
  42     // we need to ensure that it is copied (see comment in
  43     // ParScanClosure::do_oop_work).
  44     Klass* objK = obj->klass();
  45     markOop m = obj->mark();
  46     oop new_obj;
  47     if (m->is_marked()) { // Contains forwarding pointer.
  48       new_obj = ParNewGeneration::real_forwardee(obj);
  49     } else {
  50       size_t obj_sz = obj->size_given_klass(objK);
  51       new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
  52                                                                 obj, obj_sz, m);
  53     }
  54     oopDesc::encode_store_heap_oop_not_null(p, new_obj);
  55   }
  56 }
  57 
  58 inline void ParScanWeakRefClosure::do_oop_nv(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
  59 inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
  60 
  61 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
  62   assert(generation()->is_in_reserved(p), "expected ref in generation");
  63   assert(!oopDesc::is_null(*p), "expected non-null object");
  64   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  65   // If p points to a younger generation, mark the card.


  90         oop obj = oop(sp->block_start(p));
  91         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  92         log.error("Object: " PTR_FORMAT, p2i((void *)obj));
  93         log.error("-------");
  94         LogStream ls(log.error());
  95         obj->print_on(&ls);
  96         log.error("-----");
  97         log.error("Heap:");
  98         log.error("-----");
  99         heap->print_on(&ls);
 100         ShouldNotReachHere();
 101       }
 102 #endif
 103       // OK, we need to ensure that it is copied.
 104       // We read the klass and mark in this order, so that we can reliably
 105       // get the size of the object: if the mark we read is not a
 106       // forwarding pointer, then the klass is valid: the klass is only
 107       // overwritten with an overflow next pointer after the object is
 108       // forwarded.
 109       Klass* objK = obj->klass();
 110       markOop m = obj->mark();
 111       oop new_obj;
 112       if (m->is_marked()) { // Contains forwarding pointer.
 113         new_obj = ParNewGeneration::real_forwardee(obj);
 114         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 115         log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
 116                                         "forwarded ",
 117                                         new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
 118       } else {
 119         size_t obj_sz = obj->size_given_klass(objK);
 120         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
 121         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 122         if (root_scan) {
 123           // This may have pushed an object.  If we have a root
 124           // category with a lot of roots, can't let the queue get too
 125           // full:
 126           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 127         }
 128       }
 129       if (is_scanning_a_cld()) {
 130         do_cld_barrier();
   1 /*
   2  * Copyright (c) 2007, 2018, 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_CMS_PAROOPCLOSURES_INLINE_HPP
  26 #define SHARE_VM_GC_CMS_PAROOPCLOSURES_INLINE_HPP
  27 
  28 #include "gc/cms/cmsHeap.hpp"
  29 #include "gc/cms/parNewGeneration.hpp"
  30 #include "gc/cms/parOopClosures.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genOopClosures.inline.hpp"
  33 #include "logging/log.hpp"
  34 #include "logging/logStream.hpp"
  35 #include "oops/oop.inline.hpp"
  36 
  37 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
  38   assert (!oopDesc::is_null(*p), "null weak reference?");
  39   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  40   // weak references are sometimes scanned twice; must check
  41   // that to-space doesn't already contain this object
  42   if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
  43     // we need to ensure that it is copied (see comment in
  44     // ParScanClosure::do_oop_work).
  45     Klass* objK = obj->klass();
  46     markOop m = obj->mark_raw();
  47     oop new_obj;
  48     if (m->is_marked()) { // Contains forwarding pointer.
  49       new_obj = ParNewGeneration::real_forwardee(obj);
  50     } else {
  51       size_t obj_sz = obj->size_given_klass(objK);
  52       new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
  53                                                                 obj, obj_sz, m);
  54     }
  55     oopDesc::encode_store_heap_oop_not_null(p, new_obj);
  56   }
  57 }
  58 
  59 inline void ParScanWeakRefClosure::do_oop_nv(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
  60 inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
  61 
  62 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
  63   assert(generation()->is_in_reserved(p), "expected ref in generation");
  64   assert(!oopDesc::is_null(*p), "expected non-null object");
  65   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  66   // If p points to a younger generation, mark the card.


  91         oop obj = oop(sp->block_start(p));
  92         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  93         log.error("Object: " PTR_FORMAT, p2i((void *)obj));
  94         log.error("-------");
  95         LogStream ls(log.error());
  96         obj->print_on(&ls);
  97         log.error("-----");
  98         log.error("Heap:");
  99         log.error("-----");
 100         heap->print_on(&ls);
 101         ShouldNotReachHere();
 102       }
 103 #endif
 104       // OK, we need to ensure that it is copied.
 105       // We read the klass and mark in this order, so that we can reliably
 106       // get the size of the object: if the mark we read is not a
 107       // forwarding pointer, then the klass is valid: the klass is only
 108       // overwritten with an overflow next pointer after the object is
 109       // forwarded.
 110       Klass* objK = obj->klass();
 111       markOop m = obj->mark_raw();
 112       oop new_obj;
 113       if (m->is_marked()) { // Contains forwarding pointer.
 114         new_obj = ParNewGeneration::real_forwardee(obj);
 115         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 116         log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
 117                                         "forwarded ",
 118                                         new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
 119       } else {
 120         size_t obj_sz = obj->size_given_klass(objK);
 121         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
 122         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 123         if (root_scan) {
 124           // This may have pushed an object.  If we have a root
 125           // category with a lot of roots, can't let the queue get too
 126           // full:
 127           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 128         }
 129       }
 130       if (is_scanning_a_cld()) {
 131         do_cld_barrier();
< prev index next >