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

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 631
d1605aabd0a1
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

     1 /*
     2  * Copyright 2002-2008 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 size_t PSPromotionLAB::filler_header_size;
    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   // Initialize after VM starts up because header_size depends on compressed
    45   // oops.
    46   filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
    48   // We can be initialized to a zero size!
    49   if (free() > 0) {
    50     if (ZapUnusedHeapArea) {
    51       debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
    52     }
    54     // NOTE! We need to allow space for a filler object.
    55     assert(lab.word_size() >= filler_header_size, "lab is too small");
    56     end = end - filler_header_size;
    57     set_end(end);
    59     _state = needs_flush;
    60   } else {
    61     _state = zero_size;
    62   }
    64   assert(this->top() <= this->end(), "pointers out of order");
    65 }
    67 // Fill all remaining lab space with an unreachable object.
    68 // The goal is to leave a contiguous parseable span of objects.
    69 void PSPromotionLAB::flush() {
    70   assert(_state != flushed, "Attempt to flush PLAB twice");
    71   assert(top() <= end(), "pointers out of order");
    73   // If we were initialized to a zero sized lab, there is
    74   // nothing to flush
    75   if (_state == zero_size)
    76     return;
    78   // PLAB's never allocate the last aligned_header_size
    79   // so they can always fill with an array.
    80   HeapWord* tlab_end = end() + filler_header_size;
    81   typeArrayOop filler_oop = (typeArrayOop) top();
    82   filler_oop->set_mark(markOopDesc::prototype());
    83   filler_oop->set_klass(Universe::intArrayKlassObj());
    84   const size_t array_length =
    85     pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
    86   assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
    87   filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));
    89 #ifdef ASSERT
    90   // Note that we actually DO NOT want to use the aligned header size!
    91   HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT);
    92   Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
    93 #endif
    95   set_bottom(NULL);
    96   set_end(NULL);
    97   set_top(NULL);
    99   _state = flushed;
   100 }
   102 bool PSPromotionLAB::unallocate_object(oop obj) {
   103   assert(Universe::heap()->is_in(obj), "Object outside heap");
   105   if (contains(obj)) {
   106     HeapWord* object_end = (HeapWord*)obj + obj->size();
   107     assert(object_end <= top(), "Object crosses promotion LAB boundary");
   109     if (object_end == top()) {
   110       set_top((HeapWord*)obj);
   111       return true;
   112     }
   113   }
   115   return false;
   116 }
   118 // Fill all remaining lab space with an unreachable object.
   119 // The goal is to leave a contiguous parseable span of objects.
   120 void PSOldPromotionLAB::flush() {
   121   assert(_state != flushed, "Attempt to flush PLAB twice");
   122   assert(top() <= end(), "pointers out of order");
   124   if (_state == zero_size)
   125     return;
   127   HeapWord* obj = top();
   129   PSPromotionLAB::flush();
   131   assert(_start_array != NULL, "Sanity");
   133   _start_array->allocate_block(obj);
   134 }
   136 #ifdef ASSERT
   138 bool PSYoungPromotionLAB::lab_is_valid(MemRegion lab) {
   139   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
   140   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   142   MutableSpace* to_space = heap->young_gen()->to_space();
   143   MemRegion used = to_space->used_region();
   144   if (used.contains(lab)) {
   145     return true;
   146   }
   148   return false;
   149 }
   151 bool PSOldPromotionLAB::lab_is_valid(MemRegion lab) {
   152   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
   153   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
   154   assert(_start_array->covered_region().contains(lab), "Sanity");
   156   PSOldGen* old_gen = heap->old_gen();
   157   MemRegion used = old_gen->object_space()->used_region();
   159   if (used.contains(lab)) {
   160     return true;
   161   }
   163   return false;
   164 }
   166 #endif /* ASSERT */

mercurial