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

duke@435 1 /*
duke@435 2 * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_psPromotionLAB.cpp.incl"
duke@435 27
duke@435 28 const size_t PSPromotionLAB::filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
duke@435 29
duke@435 30 // This is the shared initialization code. It sets up the basic pointers,
duke@435 31 // and allows enough extra space for a filler object. We call a virtual
duke@435 32 // method, "lab_is_valid()" to handle the different asserts the old/young
duke@435 33 // labs require.
duke@435 34 void PSPromotionLAB::initialize(MemRegion lab) {
duke@435 35 assert(lab_is_valid(lab), "Sanity");
duke@435 36
duke@435 37 HeapWord* bottom = lab.start();
duke@435 38 HeapWord* end = lab.end();
duke@435 39
duke@435 40 set_bottom(bottom);
duke@435 41 set_end(end);
duke@435 42 set_top(bottom);
duke@435 43
duke@435 44 // We can be initialized to a zero size!
duke@435 45 if (free() > 0) {
duke@435 46 if (ZapUnusedHeapArea) {
duke@435 47 debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
duke@435 48 }
duke@435 49
duke@435 50 // NOTE! We need to allow space for a filler object.
duke@435 51 assert(lab.word_size() >= filler_header_size, "lab is too small");
duke@435 52 end = end - filler_header_size;
duke@435 53 set_end(end);
duke@435 54
duke@435 55 _state = needs_flush;
duke@435 56 } else {
duke@435 57 _state = zero_size;
duke@435 58 }
duke@435 59
duke@435 60 assert(this->top() <= this->end(), "pointers out of order");
duke@435 61 }
duke@435 62
duke@435 63 // Fill all remaining lab space with an unreachable object.
duke@435 64 // The goal is to leave a contiguous parseable span of objects.
duke@435 65 void PSPromotionLAB::flush() {
duke@435 66 assert(_state != flushed, "Attempt to flush PLAB twice");
duke@435 67 assert(top() <= end(), "pointers out of order");
duke@435 68
duke@435 69 // If we were initialized to a zero sized lab, there is
duke@435 70 // nothing to flush
duke@435 71 if (_state == zero_size)
duke@435 72 return;
duke@435 73
duke@435 74 // PLAB's never allocate the last aligned_header_size
duke@435 75 // so they can always fill with an array.
duke@435 76 HeapWord* tlab_end = end() + filler_header_size;
duke@435 77 typeArrayOop filler_oop = (typeArrayOop) top();
duke@435 78 filler_oop->set_mark(markOopDesc::prototype());
duke@435 79 filler_oop->set_klass(Universe::intArrayKlassObj());
duke@435 80 const size_t array_length =
duke@435 81 pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
duke@435 82 assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
duke@435 83 filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));
duke@435 84
duke@435 85 #ifdef ASSERT
duke@435 86 // Note that we actually DO NOT want to use the aligned header size!
duke@435 87 HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT);
duke@435 88 Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
duke@435 89 #endif
duke@435 90
duke@435 91 set_bottom(NULL);
duke@435 92 set_end(NULL);
duke@435 93 set_top(NULL);
duke@435 94
duke@435 95 _state = flushed;
duke@435 96 }
duke@435 97
duke@435 98 bool PSPromotionLAB::unallocate_object(oop obj) {
duke@435 99 assert(Universe::heap()->is_in(obj), "Object outside heap");
duke@435 100
duke@435 101 if (contains(obj)) {
duke@435 102 HeapWord* object_end = (HeapWord*)obj + obj->size();
duke@435 103 assert(object_end <= top(), "Object crosses promotion LAB boundary");
duke@435 104
duke@435 105 if (object_end == top()) {
duke@435 106 set_top((HeapWord*)obj);
duke@435 107 return true;
duke@435 108 }
duke@435 109 }
duke@435 110
duke@435 111 return false;
duke@435 112 }
duke@435 113
duke@435 114 // Fill all remaining lab space with an unreachable object.
duke@435 115 // The goal is to leave a contiguous parseable span of objects.
duke@435 116 void PSOldPromotionLAB::flush() {
duke@435 117 assert(_state != flushed, "Attempt to flush PLAB twice");
duke@435 118 assert(top() <= end(), "pointers out of order");
duke@435 119
duke@435 120 if (_state == zero_size)
duke@435 121 return;
duke@435 122
duke@435 123 HeapWord* obj = top();
duke@435 124
duke@435 125 PSPromotionLAB::flush();
duke@435 126
duke@435 127 assert(_start_array != NULL, "Sanity");
duke@435 128
duke@435 129 _start_array->allocate_block(obj);
duke@435 130 }
duke@435 131
duke@435 132 #ifdef ASSERT
duke@435 133
duke@435 134 bool PSYoungPromotionLAB::lab_is_valid(MemRegion lab) {
duke@435 135 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 136 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 137
duke@435 138 MutableSpace* to_space = heap->young_gen()->to_space();
duke@435 139 MemRegion used = to_space->used_region();
duke@435 140 if (used.contains(lab)) {
duke@435 141 return true;
duke@435 142 }
duke@435 143
duke@435 144 return false;
duke@435 145 }
duke@435 146
duke@435 147 bool PSOldPromotionLAB::lab_is_valid(MemRegion lab) {
duke@435 148 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 149 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
duke@435 150 assert(_start_array->covered_region().contains(lab), "Sanity");
duke@435 151
duke@435 152 PSOldGen* old_gen = heap->old_gen();
duke@435 153 MemRegion used = old_gen->object_space()->used_region();
duke@435 154
duke@435 155 if (used.contains(lab)) {
duke@435 156 return true;
duke@435 157 }
duke@435 158
duke@435 159 return false;
duke@435 160 }
duke@435 161
duke@435 162 #endif /* ASSERT */

mercurial