< prev index next >

src/share/vm/memory/genMarkSweep.cpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2014, 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  *


 142 
 143   // Update heap occupancy information which is used as
 144   // input to soft ref clearing policy at the next gc.
 145   Universe::update_heap_info_at_gc();
 146 
 147   // Update time of last gc for all generations we collected
 148   // (which currently is all the generations in the heap).
 149   // We need to use a monotonically non-decreasing time in ms
 150   // or we will see time-warp warnings and os::javaTimeMillis()
 151   // does not guarantee monotonicity.
 152   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
 153   gch->update_time_of_last_gc(now);
 154 
 155   gch->trace_heap_after_gc(_gc_tracer);
 156 }
 157 
 158 void GenMarkSweep::allocate_stacks() {
 159   GenCollectedHeap* gch = GenCollectedHeap::heap();
 160   // Scratch request on behalf of oldest generation; will do no
 161   // allocation.
 162   ScratchBlock* scratch = gch->gather_scratch(gch->_gens[gch->_n_gens-1], 0);
 163 
 164   // $$$ To cut a corner, we'll only use the first scratch block, and then
 165   // revert to malloc.
 166   if (scratch != NULL) {
 167     _preserved_count_max =
 168       scratch->num_words * HeapWordSize / sizeof(PreservedMark);
 169   } else {
 170     _preserved_count_max = 0;
 171   }
 172 
 173   _preserved_marks = (PreservedMark*)scratch;
 174   _preserved_count = 0;
 175 }
 176 
 177 
 178 void GenMarkSweep::deallocate_stacks() {
 179   if (!UseG1GC) {
 180     GenCollectedHeap* gch = GenCollectedHeap::heap();
 181     gch->release_scratch();
 182   }


   1 /*
   2  * Copyright (c) 2001, 2015, 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  *


 142 
 143   // Update heap occupancy information which is used as
 144   // input to soft ref clearing policy at the next gc.
 145   Universe::update_heap_info_at_gc();
 146 
 147   // Update time of last gc for all generations we collected
 148   // (which currently is all the generations in the heap).
 149   // We need to use a monotonically non-decreasing time in ms
 150   // or we will see time-warp warnings and os::javaTimeMillis()
 151   // does not guarantee monotonicity.
 152   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
 153   gch->update_time_of_last_gc(now);
 154 
 155   gch->trace_heap_after_gc(_gc_tracer);
 156 }
 157 
 158 void GenMarkSweep::allocate_stacks() {
 159   GenCollectedHeap* gch = GenCollectedHeap::heap();
 160   // Scratch request on behalf of oldest generation; will do no
 161   // allocation.
 162   ScratchBlock* scratch = gch->gather_scratch(gch->get_gen(gch->_n_gens-1), 0);
 163 
 164   // $$$ To cut a corner, we'll only use the first scratch block, and then
 165   // revert to malloc.
 166   if (scratch != NULL) {
 167     _preserved_count_max =
 168       scratch->num_words * HeapWordSize / sizeof(PreservedMark);
 169   } else {
 170     _preserved_count_max = 0;
 171   }
 172 
 173   _preserved_marks = (PreservedMark*)scratch;
 174   _preserved_count = 0;
 175 }
 176 
 177 
 178 void GenMarkSweep::deallocate_stacks() {
 179   if (!UseG1GC) {
 180     GenCollectedHeap* gch = GenCollectedHeap::heap();
 181     gch->release_scratch();
 182   }


< prev index next >