< 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 PreservedMark elem = _stack.pop();
 38     elem.set_mark();
 39   }
 40   assert_empty();
 41 }
 42 
 43 void PreservedMarks::adjust_preserved_mark(PreservedMark* elem) {
 44   oop obj = elem->get_oop();
 45   if (obj->is_forwarded()) {
 46     elem->set_oop(obj->forwardee());
 47   }
 48 }
 49 
 50 void PreservedMarks::adjust_during_full_gc() {
 51   StackIterator<PreservedMark, mtGC> iter(_stack);
 52   while (!iter.is_empty()) {
 53     PreservedMark* elem = iter.next_addr();
 54     adjust_preserved_mark(elem);
 55   }
 56 }
 57 
 58 void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) {
 59   const size_t stack_size = size();
 60   restore();
 61   // Only do the atomic add if the size is > 0.
 62   if (stack_size > 0) {
 63     Atomic::add(total_size_addr, stack_size);
 64   }
 65 }
 66 

  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 PreservedMark elem = _stack.pop();
 39     elem.set_mark();
 40   }
 41   assert_empty();
 42 }
 43 
 44 void PreservedMarks::adjust_preserved_mark(PreservedMark* elem) {
 45   oop obj = elem->get_oop();
 46   if (SlidingForwarding::is_forwarded(obj)) {
 47     elem->set_oop(SlidingForwarding::forwardee(obj));
 48   }
 49 }
 50 
 51 void PreservedMarks::adjust_during_full_gc() {
 52   StackIterator<PreservedMark, mtGC> iter(_stack);
 53   while (!iter.is_empty()) {
 54     PreservedMark* elem = iter.next_addr();
 55     adjust_preserved_mark(elem);
 56   }
 57 }
 58 
 59 void PreservedMarks::restore_and_increment(volatile size_t* const total_size_addr) {
 60   const size_t stack_size = size();
 61   restore();
 62   // Only do the atomic add if the size is > 0.
 63   if (stack_size > 0) {
 64     Atomic::add(total_size_addr, stack_size);
 65   }
 66 }
 67 
< prev index next >