< 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/workerThread.hpp"
 28 #include "gc/shared/workerUtils.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 void PreservedMarks::adjust_during_full_gc() {
 44   StackIterator<OopAndMarkWord, mtGC> iter(_stack);
 45   while (!iter.is_empty()) {
 46     OopAndMarkWord* elem = iter.next_addr();
 47 
 48     oop obj = elem->get_oop();
 49     if (obj->is_forwarded()) {
 50       elem->set_oop(obj->forwardee());
 51     }
 52   }
 53 }
 54 












 55 void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) {
 56   const size_t stack_size = size();
 57   restore();
 58   // Only do the atomic add if the size is > 0.
 59   if (stack_size > 0) {
 60     Atomic::add(total_size_addr, stack_size);
 61   }
 62 }
 63 
 64 #ifndef PRODUCT
 65 void PreservedMarks::assert_empty() {
 66   assert(_stack.is_empty(), "stack expected to be empty, size = " SIZE_FORMAT,
 67          _stack.size());
 68   assert(_stack.cache_size() == 0,
 69          "stack expected to have no cached segments, cache size = " SIZE_FORMAT,
 70          _stack.cache_size());
 71 }
 72 #endif // ndef PRODUCT
 73 
 74 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/workerThread.hpp"
 29 #include "gc/shared/workerUtils.hpp"
 30 #include "memory/allocation.inline.hpp"
 31 #include "memory/resourceArea.hpp"
 32 #include "oops/oop.inline.hpp"
 33 #include "runtime/atomic.hpp"
 34 #include "utilities/macros.hpp"
 35 
 36 void PreservedMarks::restore() {
 37   while (!_stack.is_empty()) {
 38     const OopAndMarkWord elem = _stack.pop();
 39     elem.set_mark();
 40   }
 41   assert_empty();
 42 }
 43 
 44 // TODO: This method is unused, except in the gunit test. Change the test
 45 // to exercise the updated method below instead, and remove this one.
 46 void PreservedMarks::adjust_during_full_gc() {
 47   StackIterator<OopAndMarkWord, mtGC> iter(_stack);
 48   while (!iter.is_empty()) {
 49     OopAndMarkWord* elem = iter.next_addr();
 50 
 51     oop obj = elem->get_oop();
 52     if (obj->is_forwarded()) {
 53       elem->set_oop(obj->forwardee());
 54     }
 55   }
 56 }
 57 
 58 void PreservedMarks::adjust_during_full_gc(const SlidingForwarding* const forwarding) {
 59   StackIterator<OopAndMarkWord, mtGC> iter(_stack);
 60   while (!iter.is_empty()) {
 61     OopAndMarkWord* elem = iter.next_addr();
 62 
 63     oop obj = elem->get_oop();
 64     if (obj->is_forwarded()) {
 65       elem->set_oop(forwarding->forwardee(obj));
 66     }
 67   }
 68 }
 69 
 70 void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) {
 71   const size_t stack_size = size();
 72   restore();
 73   // Only do the atomic add if the size is > 0.
 74   if (stack_size > 0) {
 75     Atomic::add(total_size_addr, stack_size);
 76   }
 77 }
 78 
 79 #ifndef PRODUCT
 80 void PreservedMarks::assert_empty() {
 81   assert(_stack.is_empty(), "stack expected to be empty, size = " SIZE_FORMAT,
 82          _stack.size());
 83   assert(_stack.cache_size() == 0,
 84          "stack expected to have no cached segments, cache size = " SIZE_FORMAT,
 85          _stack.cache_size());
 86 }
 87 #endif // ndef PRODUCT
 88 
 89 void RemoveForwardedPointerClosure::do_object(oop obj) {
< prev index next >