< prev index next >

src/share/vm/gc/g1/g1AllocRegion.cpp

Print this page
rev 13113 : imported patch 8181917-refactor-ul-logstream


   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/g1/g1AllocRegion.inline.hpp"
  27 #include "gc/g1/g1EvacStats.inline.hpp"
  28 #include "gc/g1/g1CollectedHeap.inline.hpp"


  29 #include "memory/resourceArea.hpp"
  30 #include "runtime/orderAccess.inline.hpp"
  31 
  32 G1CollectedHeap* G1AllocRegion::_g1h = NULL;
  33 HeapRegion* G1AllocRegion::_dummy_region = NULL;
  34 
  35 void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) {
  36   assert(_dummy_region == NULL, "should be set once");
  37   assert(dummy_region != NULL, "pre-condition");
  38   assert(dummy_region->free() == 0, "pre-condition");
  39 
  40   // Make sure that any allocation attempt on this region will fail
  41   // and will not trigger any asserts.
  42   assert(allocate(dummy_region, 1, false) == NULL, "should fail");
  43   assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
  44   assert(allocate(dummy_region, 1, true) == NULL, "should fail");
  45   assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
  46 
  47   _g1h = g1h;
  48   _dummy_region = dummy_region;


 194   trace("released");
 195   return (alloc_region == _dummy_region) ? NULL : alloc_region;
 196 }
 197 
 198 #ifndef PRODUCT
 199 void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) {
 200   // All the calls to trace that set either just the size or the size
 201   // and the result are considered part of detailed tracing and are
 202   // skipped during other tracing.
 203 
 204   Log(gc, alloc, region) log;
 205 
 206   if (!log.is_debug()) {
 207     return;
 208   }
 209 
 210   bool detailed_info = log.is_trace();
 211 
 212   if ((actual_word_size == 0 && result == NULL) || detailed_info) {
 213     ResourceMark rm;
 214     outputStream* out;
 215     if (detailed_info) {
 216       out = log.trace_stream();
 217     } else {
 218       out = log.debug_stream();
 219     }
 220 
 221     out->print("%s: %u ", _name, _count);
 222 
 223     if (_alloc_region == NULL) {
 224       out->print("NULL");
 225     } else if (_alloc_region == _dummy_region) {
 226       out->print("DUMMY");
 227     } else {
 228       out->print(HR_FORMAT, HR_FORMAT_PARAMS(_alloc_region));
 229     }
 230 
 231     out->print(" : %s", str);
 232 
 233     if (detailed_info) {
 234       if (result != NULL) {
 235         out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT,
 236                      min_word_size, desired_word_size, actual_word_size, p2i(result));
 237       } else if (min_word_size != 0) {
 238         out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size);
 239       }




   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/g1/g1AllocRegion.inline.hpp"
  27 #include "gc/g1/g1EvacStats.inline.hpp"
  28 #include "gc/g1/g1CollectedHeap.inline.hpp"
  29 #include "logging/log.hpp"
  30 #include "logging/logStream.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "runtime/orderAccess.inline.hpp"
  33 
  34 G1CollectedHeap* G1AllocRegion::_g1h = NULL;
  35 HeapRegion* G1AllocRegion::_dummy_region = NULL;
  36 
  37 void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) {
  38   assert(_dummy_region == NULL, "should be set once");
  39   assert(dummy_region != NULL, "pre-condition");
  40   assert(dummy_region->free() == 0, "pre-condition");
  41 
  42   // Make sure that any allocation attempt on this region will fail
  43   // and will not trigger any asserts.
  44   assert(allocate(dummy_region, 1, false) == NULL, "should fail");
  45   assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
  46   assert(allocate(dummy_region, 1, true) == NULL, "should fail");
  47   assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
  48 
  49   _g1h = g1h;
  50   _dummy_region = dummy_region;


 196   trace("released");
 197   return (alloc_region == _dummy_region) ? NULL : alloc_region;
 198 }
 199 
 200 #ifndef PRODUCT
 201 void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) {
 202   // All the calls to trace that set either just the size or the size
 203   // and the result are considered part of detailed tracing and are
 204   // skipped during other tracing.
 205 
 206   Log(gc, alloc, region) log;
 207 
 208   if (!log.is_debug()) {
 209     return;
 210   }
 211 
 212   bool detailed_info = log.is_trace();
 213 
 214   if ((actual_word_size == 0 && result == NULL) || detailed_info) {
 215     ResourceMark rm;
 216     LogStream ls_trace(log.trace());
 217     LogStream ls_debug(log.debug());
 218     outputStream* out = detailed_info ? &ls_trace : &ls_debug;



 219 
 220     out->print("%s: %u ", _name, _count);
 221 
 222     if (_alloc_region == NULL) {
 223       out->print("NULL");
 224     } else if (_alloc_region == _dummy_region) {
 225       out->print("DUMMY");
 226     } else {
 227       out->print(HR_FORMAT, HR_FORMAT_PARAMS(_alloc_region));
 228     }
 229 
 230     out->print(" : %s", str);
 231 
 232     if (detailed_info) {
 233       if (result != NULL) {
 234         out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT,
 235                      min_word_size, desired_word_size, actual_word_size, p2i(result));
 236       } else if (min_word_size != 0) {
 237         out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size);
 238       }


< prev index next >