< prev index next >

src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp

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  *


  95 
  96 void G1FullGCCompactionPoint::forward(oop object, size_t size) {
  97   assert(_current_region != NULL, "Must have been initialized");
  98 
  99   // Ensure the object fit in the current region.
 100   while (!object_will_fit(size)) {
 101     switch_region();
 102   }
 103 
 104   // Store a forwarding pointer if the object should be moved.
 105   if ((HeapWord*)object != _compaction_top) {
 106     object->forward_to(oop(_compaction_top));
 107   } else {
 108     if (object->forwardee() != NULL) {
 109       // Object should not move but mark-word is used so it looks like the
 110       // object is forwarded. Need to clear the mark and it's no problem
 111       // since it will be restored by preserved marks. There is an exception
 112       // with BiasedLocking, in this case forwardee() will return NULL
 113       // even if the mark-word is used. This is no problem since
 114       // forwardee() will return NULL in the compaction phase as well.
 115       object->init_mark();
 116     } else {
 117       // Make sure object has the correct mark-word set or that it will be
 118       // fixed when restoring the preserved marks.
 119       assert(object->mark() == markOopDesc::prototype_for_object(object) || // Correct mark
 120              object->mark()->must_be_preserved(object) || // Will be restored by PreservedMarksSet
 121              (UseBiasedLocking && object->has_bias_pattern()), // Will be restored by BiasedLocking
 122              "should have correct prototype obj: " PTR_FORMAT " mark: " PTR_FORMAT " prototype: " PTR_FORMAT,
 123              p2i(object), p2i(object->mark()), p2i(markOopDesc::prototype_for_object(object)));
 124     }
 125     assert(object->forwardee() == NULL, "should be forwarded to NULL");
 126   }
 127 
 128   // Update compaction values.
 129   _compaction_top += size;
 130   if (_compaction_top > _threshold) {
 131     _threshold = _current_region->cross_threshold(_compaction_top - size, _compaction_top);
 132   }
 133 }
 134 
 135 void G1FullGCCompactionPoint::add(HeapRegion* hr) {
 136   _compaction_regions->append(hr);
 137 }
 138 
 139 void G1FullGCCompactionPoint::merge(G1FullGCCompactionPoint* other) {
 140    _compaction_regions->appendAll(other->regions());
 141 }
 142 
 143 HeapRegion* G1FullGCCompactionPoint::remove_last() {
   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  *


  95 
  96 void G1FullGCCompactionPoint::forward(oop object, size_t size) {
  97   assert(_current_region != NULL, "Must have been initialized");
  98 
  99   // Ensure the object fit in the current region.
 100   while (!object_will_fit(size)) {
 101     switch_region();
 102   }
 103 
 104   // Store a forwarding pointer if the object should be moved.
 105   if ((HeapWord*)object != _compaction_top) {
 106     object->forward_to(oop(_compaction_top));
 107   } else {
 108     if (object->forwardee() != NULL) {
 109       // Object should not move but mark-word is used so it looks like the
 110       // object is forwarded. Need to clear the mark and it's no problem
 111       // since it will be restored by preserved marks. There is an exception
 112       // with BiasedLocking, in this case forwardee() will return NULL
 113       // even if the mark-word is used. This is no problem since
 114       // forwardee() will return NULL in the compaction phase as well.
 115       object->init_mark_raw();
 116     } else {
 117       // Make sure object has the correct mark-word set or that it will be
 118       // fixed when restoring the preserved marks.
 119       assert(object->mark_raw() == markOopDesc::prototype_for_object(object) || // Correct mark
 120              object->mark_raw()->must_be_preserved(object) || // Will be restored by PreservedMarksSet
 121              (UseBiasedLocking && object->has_bias_pattern_raw()), // Will be restored by BiasedLocking
 122              "should have correct prototype obj: " PTR_FORMAT " mark: " PTR_FORMAT " prototype: " PTR_FORMAT,
 123              p2i(object), p2i(object->mark_raw()), p2i(markOopDesc::prototype_for_object(object)));
 124     }
 125     assert(object->forwardee() == NULL, "should be forwarded to NULL");
 126   }
 127 
 128   // Update compaction values.
 129   _compaction_top += size;
 130   if (_compaction_top > _threshold) {
 131     _threshold = _current_region->cross_threshold(_compaction_top - size, _compaction_top);
 132   }
 133 }
 134 
 135 void G1FullGCCompactionPoint::add(HeapRegion* hr) {
 136   _compaction_regions->append(hr);
 137 }
 138 
 139 void G1FullGCCompactionPoint::merge(G1FullGCCompactionPoint* other) {
 140    _compaction_regions->appendAll(other->regions());
 141 }
 142 
 143 HeapRegion* G1FullGCCompactionPoint::remove_last() {
< prev index next >