src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.cpp

Fri, 28 Mar 2008 23:35:42 -0700

author
jcoomes
date
Fri, 28 Mar 2008 23:35:42 -0700
changeset 514
82db0859acbe
parent 435
a61af66fc99e
child 548
ba764ed4b6f2
permissions
-rw-r--r--

6642862: Code cache allocation fails with large pages after 6588638
Reviewed-by: apetrusenko

     1 /*
     2  * Copyright 2002-2006 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_psPromotionLAB.cpp.incl"
    28 const size_t PSPromotionLAB::filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
    30 // This is the shared initialization code. It sets up the basic pointers,
    31 // and allows enough extra space for a filler object. We call a virtual
    32 // method, "lab_is_valid()" to handle the different asserts the old/young
    33 // labs require.
    34 void PSPromotionLAB::initialize(MemRegion lab) {
    35   assert(lab_is_valid(lab), "Sanity");
    37   HeapWord* bottom = lab.start();
    38   HeapWord* end    = lab.end();
    40   set_bottom(bottom);
    41   set_end(end);
    42   set_top(bottom);
    44   // We can be initialized to a zero size!
    45   if (free() > 0) {
    46     if (ZapUnusedHeapArea) {
    47       debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
    48     }
    50     // NOTE! We need to allow space for a filler object.
    51     assert(lab.word_size() >= filler_header_size, "lab is too small");
    52     end = end - filler_header_size;
    53     set_end(end);
    55     _state = needs_flush;
    56   } else {
    57     _state = zero_size;
    58   }
    60   assert(this->top() <= this->end(), "pointers out of order");
    61 }
    63 // Fill all remaining lab space with an unreachable object.
    64 // The goal is to leave a contiguous parseable span of objects.
    65 void PSPromotionLAB::flush() {
    66   assert(_state != flushed, "Attempt to flush PLAB twice");
    67   assert(top() <= end(), "pointers out of order");
    69   // If we were initialized to a zero sized lab, there is
    70   // nothing to flush
    71   if (_state == zero_size)
    72     return;
    74   // PLAB's never allocate the last aligned_header_size
    75   // so they can always fill with an array.
    76   HeapWord* tlab_end = end() + filler_header_size;
    77   typeArrayOop filler_oop = (typeArrayOop) top();
    78   filler_oop->set_mark(markOopDesc::prototype());
    79   filler_oop->set_klass(Universe::intArrayKlassObj());
    80   const size_t array_length =
    81     pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
    82   assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
    83   filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));
    85 #ifdef ASSERT
    86   // Note that we actually DO NOT want to use the aligned header size!
    87   HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT);
    88   Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
    89 #endif
    91   set_bottom(NULL);
    92   set_end(NULL);
    93   set_top(NULL);
    95   _state = flushed;
    96 }
    98 bool PSPromotionLAB::unallocate_object(oop obj) {
    99   assert(Universe::heap()->is_in(obj), "Object outside heap");
   101   if (contains(obj)) {
   102     HeapWord* object_end = (HeapWord*)obj + obj->size();
   103     assert(object_end <= top(), "Object crosses promotion LAB boundary");
   105     if (object_end == top()) {
   106       set_top((HeapWord*)obj);
   107       return true;
   108     }
   109   }
   111   return false;
   112 }
   114 // Fill all remaining lab space with an unreachable object.
   115 // The goal is to leave a contiguous parseable span of objects.
   116 void PSOldPromotionLAB::flush() {
   117   assert(_state != flushed, "Attempt to flush PLAB twice");
   118   assert(top() <= end(), "pointers out of order");
   120   if (_state == zero_size)
   121     return;
   123   HeapWord* obj = top();
   125   PSPromotionLAB::flush();
   127   assert(_start_array != NULL, "Sanity");
   129   _start_array->allocate_block(obj);
   130 }
   132 #ifdef ASSERT
   134 bool PSYoungPromotionLAB::lab_is_valid(MemRegion lab) {
   135   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
   136   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   138   MutableSpace* to_space = heap->young_gen()->to_space();
   139   MemRegion used = to_space->used_region();
   140   if (used.contains(lab)) {
   141     return true;
   142   }
   144   return false;
   145 }
   147 bool PSOldPromotionLAB::lab_is_valid(MemRegion lab) {
   148   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
   149   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   150   assert(_start_array->covered_region().contains(lab), "Sanity");
   152   PSOldGen* old_gen = heap->old_gen();
   153   MemRegion used = old_gen->object_space()->used_region();
   155   if (used.contains(lab)) {
   156     return true;
   157   }
   159   return false;
   160 }
   162 #endif /* ASSERT */

mercurial