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

Fri, 24 Jun 2016 17:12:13 +0800

author
aoqi<aoqi@loongson.cn>
date
Fri, 24 Jun 2016 17:12:13 +0800
changeset 25
873fd82b133d
parent 1
2d8a650513c2
child 6876
710a3c8b516e
permissions
-rw-r--r--

[Code Reorganization] Removed GC related modifications made by Loongson, for example, UseOldNUMA.

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

mercurial