< prev index next >

src/hotspot/share/gc/shared/preservedMarks.cpp

Print this page

  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 #include "precompiled.hpp"
 26 #include "gc/shared/preservedMarks.inline.hpp"

 27 #include "gc/shared/workgroup.hpp"
 28 #include "memory/allocation.inline.hpp"
 29 #include "memory/resourceArea.hpp"
 30 #include "oops/oop.inline.hpp"
 31 #include "runtime/atomic.hpp"
 32 #include "utilities/macros.hpp"
 33 
 34 void PreservedMarks::restore() {
 35   while (!_stack.is_empty()) {
 36     const OopAndMarkWord elem = _stack.pop();
 37     elem.set_mark();
 38   }
 39   assert_empty();
 40 }
 41 
 42 void PreservedMarks::adjust_during_full_gc() {

 43   StackIterator<OopAndMarkWord, mtGC> iter(_stack);
 44   while (!iter.is_empty()) {
 45     OopAndMarkWord* elem = iter.next_addr();
 46 
 47     oop obj = elem->get_oop();
 48     if (obj->is_forwarded()) {
 49       elem->set_oop(obj->forwardee());
 50     }
 51   }
 52 }
 53 








 54 void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) {
 55   const size_t stack_size = size();
 56   restore();
 57   // Only do the atomic add if the size is > 0.
 58   if (stack_size > 0) {
 59     Atomic::add(total_size_addr, stack_size);
 60   }
 61 }
 62 
 63 #ifndef PRODUCT
 64 void PreservedMarks::assert_empty() {
 65   assert(_stack.is_empty(), "stack expected to be empty, size = " SIZE_FORMAT,
 66          _stack.size());
 67   assert(_stack.cache_size() == 0,
 68          "stack expected to have no cached segments, cache size = " SIZE_FORMAT,
 69          _stack.cache_size());
 70 }
 71 #endif // ndef PRODUCT
 72 
 73 void RemoveForwardedPointerClosure::do_object(oop obj) {

  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 #include "precompiled.hpp"
 26 #include "gc/shared/preservedMarks.inline.hpp"
 27 #include "gc/shared/slidingForwarding.inline.hpp"
 28 #include "gc/shared/workgroup.hpp"
 29 #include "memory/allocation.inline.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "oops/oop.inline.hpp"
 32 #include "runtime/atomic.hpp"
 33 #include "utilities/macros.hpp"
 34 
 35 void PreservedMarks::restore() {
 36   while (!_stack.is_empty()) {
 37     const OopAndMarkWord elem = _stack.pop();
 38     elem.set_mark();
 39   }
 40   assert_empty();
 41 }
 42 
 43 template <bool ALT_FWD>
 44 void PreservedMarks::adjust_during_full_gc_impl() {
 45   StackIterator<OopAndMarkWord, mtGC> iter(_stack);
 46   while (!iter.is_empty()) {
 47     OopAndMarkWord* elem = iter.next_addr();
 48 
 49     oop obj = elem->get_oop();
 50     if (SlidingForwarding::is_forwarded(obj)) {
 51       elem->set_oop(SlidingForwarding::forwardee<ALT_FWD>(obj));
 52     }
 53   }
 54 }
 55 
 56 void PreservedMarks::adjust_during_full_gc() {
 57   if (UseAltGCForwarding) {
 58     adjust_during_full_gc_impl<true>();
 59   } else {
 60     adjust_during_full_gc_impl<false>();
 61   }
 62 }
 63 
 64 void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) {
 65   const size_t stack_size = size();
 66   restore();
 67   // Only do the atomic add if the size is > 0.
 68   if (stack_size > 0) {
 69     Atomic::add(total_size_addr, stack_size);
 70   }
 71 }
 72 
 73 #ifndef PRODUCT
 74 void PreservedMarks::assert_empty() {
 75   assert(_stack.is_empty(), "stack expected to be empty, size = " SIZE_FORMAT,
 76          _stack.size());
 77   assert(_stack.cache_size() == 0,
 78          "stack expected to have no cached segments, cache size = " SIZE_FORMAT,
 79          _stack.cache_size());
 80 }
 81 #endif // ndef PRODUCT
 82 
 83 void RemoveForwardedPointerClosure::do_object(oop obj) {
< prev index next >