< prev index next >

src/hotspot/share/gc/g1/g1FullGCOopClosures.inline.hpp

Print this page
rev 49289 : 8199735: Mark word updates need to use Access API
   1 /*
   2  * Copyright (c) 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_G1_G1FULLGCOOPCLOSURES_INLINE_HPP
  26 #define SHARE_VM_GC_G1_G1FULLGCOOPCLOSURES_INLINE_HPP
  27 
  28 #include "gc/g1/g1Allocator.hpp"
  29 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
  30 #include "gc/g1/g1FullGCMarker.inline.hpp"
  31 #include "gc/g1/g1FullGCOopClosures.hpp"
  32 #include "gc/g1/heapRegionRemSet.hpp"
  33 #include "memory/iterator.inline.hpp"

  34 
  35 template <typename T>
  36 inline void G1MarkAndPushClosure::do_oop_nv(T* p) {
  37   _marker->mark_and_push(p);
  38 }
  39 
  40 inline bool G1MarkAndPushClosure::do_metadata_nv() {
  41   return true;
  42 }
  43 
  44 inline void G1MarkAndPushClosure::do_klass_nv(Klass* k) {
  45   _marker->follow_klass(k);
  46 }
  47 
  48 inline void G1MarkAndPushClosure::do_cld_nv(ClassLoaderData* cld) {
  49   _marker->follow_cld(cld);
  50 }
  51 
  52 template <class T> inline oop G1AdjustClosure::adjust_pointer(T* p) {
  53   T heap_oop = oopDesc::load_heap_oop(p);
  54   if (oopDesc::is_null(heap_oop)) {
  55     // NULL reference, return NULL.
  56     return NULL;
  57   }
  58 
  59   oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  60   assert(Universe::heap()->is_in(obj), "should be in heap");
  61   if (G1ArchiveAllocator::is_archive_object(obj)) {
  62     // Never forwarding archive objects, return current reference.
  63     return obj;
  64   }
  65 
  66   oop forwardee = obj->forwardee();
  67   if (forwardee == NULL) {
  68     // Not forwarded, return current reference.
  69     assert(obj->mark() == markOopDesc::prototype_for_object(obj) || // Correct mark
  70            obj->mark()->must_be_preserved(obj) || // Will be restored by PreservedMarksSet
  71            (UseBiasedLocking && obj->has_bias_pattern()), // Will be restored by BiasedLocking
  72            "Must have correct prototype or be preserved, obj: " PTR_FORMAT ", mark: " PTR_FORMAT ", prototype: " PTR_FORMAT,
  73            p2i(obj), p2i(obj->mark()), p2i(markOopDesc::prototype_for_object(obj)));
  74     return obj;
  75   }
  76 
  77   // Forwarded, update and return new reference.
  78   assert(Universe::heap()->is_in_reserved(forwardee), "should be in object space");
  79   oopDesc::encode_store_heap_oop_not_null(p, forwardee);
  80   return forwardee;
  81 }
  82 
  83 template <class T>
  84 inline void G1AdjustAndRebuildClosure::add_reference(T* from_field, oop reference, uint worker_id) {
  85   if (HeapRegion::is_in_same_region(from_field, reference)) {
  86     return;
  87   }
  88   _g1h->heap_region_containing(reference)->rem_set()->add_reference(from_field, worker_id);
  89 }
  90 
  91 inline size_t G1AdjustAndRebuildClosure::calculate_compaction_delta(oop current, oop forwardee) {
  92   return pointer_delta((HeapWord*)forwardee, (HeapWord*)current);
  93 }


   1 /*
   2  * Copyright (c) 2017, 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_G1_G1FULLGCOOPCLOSURES_INLINE_HPP
  26 #define SHARE_VM_GC_G1_G1FULLGCOOPCLOSURES_INLINE_HPP
  27 
  28 #include "gc/g1/g1Allocator.hpp"
  29 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
  30 #include "gc/g1/g1FullGCMarker.inline.hpp"
  31 #include "gc/g1/g1FullGCOopClosures.hpp"
  32 #include "gc/g1/heapRegionRemSet.hpp"
  33 #include "memory/iterator.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 
  36 template <typename T>
  37 inline void G1MarkAndPushClosure::do_oop_nv(T* p) {
  38   _marker->mark_and_push(p);
  39 }
  40 
  41 inline bool G1MarkAndPushClosure::do_metadata_nv() {
  42   return true;
  43 }
  44 
  45 inline void G1MarkAndPushClosure::do_klass_nv(Klass* k) {
  46   _marker->follow_klass(k);
  47 }
  48 
  49 inline void G1MarkAndPushClosure::do_cld_nv(ClassLoaderData* cld) {
  50   _marker->follow_cld(cld);
  51 }
  52 
  53 template <class T> inline oop G1AdjustClosure::adjust_pointer(T* p) {
  54   T heap_oop = oopDesc::load_heap_oop(p);
  55   if (oopDesc::is_null(heap_oop)) {
  56     // NULL reference, return NULL.
  57     return NULL;
  58   }
  59 
  60   oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  61   assert(Universe::heap()->is_in(obj), "should be in heap");
  62   if (G1ArchiveAllocator::is_archive_object(obj)) {
  63     // Never forwarding archive objects, return current reference.
  64     return obj;
  65   }
  66 
  67   oop forwardee = obj->forwardee();
  68   if (forwardee == NULL) {
  69     // Not forwarded, return current reference.
  70     assert(obj->mark_raw() == markOopDesc::prototype_for_object(obj) || // Correct mark
  71            obj->mark_raw()->must_be_preserved(obj) || // Will be restored by PreservedMarksSet
  72            (UseBiasedLocking && obj->has_bias_pattern_raw()), // Will be restored by BiasedLocking
  73            "Must have correct prototype or be preserved, obj: " PTR_FORMAT ", mark: " PTR_FORMAT ", prototype: " PTR_FORMAT,
  74            p2i(obj), p2i(obj->mark_raw()), p2i(markOopDesc::prototype_for_object(obj)));
  75     return obj;
  76   }
  77 
  78   // Forwarded, update and return new reference.
  79   assert(Universe::heap()->is_in_reserved(forwardee), "should be in object space");
  80   oopDesc::encode_store_heap_oop_not_null(p, forwardee);
  81   return forwardee;
  82 }
  83 
  84 template <class T>
  85 inline void G1AdjustAndRebuildClosure::add_reference(T* from_field, oop reference, uint worker_id) {
  86   if (HeapRegion::is_in_same_region(from_field, reference)) {
  87     return;
  88   }
  89   _g1h->heap_region_containing(reference)->rem_set()->add_reference(from_field, worker_id);
  90 }
  91 
  92 inline size_t G1AdjustAndRebuildClosure::calculate_compaction_delta(oop current, oop forwardee) {
  93   return pointer_delta((HeapWord*)forwardee, (HeapWord*)current);
  94 }


< prev index next >