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

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 631
d1605aabd0a1
child 2314
f95d63e2154a
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

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

mercurial