src/share/vm/gc_implementation/shared/spaceDecorator.cpp

Tue, 26 Nov 2013 14:35:38 +0100

author
sjohanss
date
Tue, 26 Nov 2013 14:35:38 +0100
changeset 6148
55a0da3d420b
parent 2314
f95d63e2154a
child 6680
78bbf4d43a14
permissions
-rw-r--r--

8027675: Full collections with Serial slower in JDK 8 compared to 7u40
Summary: Reduced the number of calls to follow_class_loader and instead marked and pushed the klass holder directly. Also removed unneeded calls to adjust_klass.
Reviewed-by: coleenp, jmasa, mgerdin, tschatzl

jmasa@698 1 /*
stefank@2314 2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
jmasa@698 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jmasa@698 4 *
jmasa@698 5 * This code is free software; you can redistribute it and/or modify it
jmasa@698 6 * under the terms of the GNU General Public License version 2 only, as
jmasa@698 7 * published by the Free Software Foundation.
jmasa@698 8 *
jmasa@698 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jmasa@698 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jmasa@698 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jmasa@698 12 * version 2 for more details (a copy is included in the LICENSE file that
jmasa@698 13 * accompanied this code).
jmasa@698 14 *
jmasa@698 15 * You should have received a copy of the GNU General Public License version
jmasa@698 16 * 2 along with this work; if not, write to the Free Software Foundation,
jmasa@698 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jmasa@698 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.
jmasa@698 22 *
jmasa@698 23 */
jmasa@698 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/shared/spaceDecorator.hpp"
stefank@2314 27 #include "memory/space.inline.hpp"
stefank@2314 28 #include "utilities/copy.hpp"
jmasa@698 29
jmasa@698 30 // Catch-all file for utility classes
jmasa@698 31
jmasa@698 32 #ifndef PRODUCT
jmasa@698 33
jmasa@698 34 // Returns true is the location q matches the mangling
jmasa@698 35 // pattern.
jmasa@698 36 bool SpaceMangler::is_mangled(HeapWord* q) {
jmasa@698 37 // This test loses precision but is good enough
jmasa@698 38 return badHeapWord == (max_juint & (uintptr_t) q->value());
jmasa@698 39 }
jmasa@698 40
jmasa@698 41
jmasa@698 42 void SpaceMangler::set_top_for_allocations(HeapWord* v) {
jmasa@698 43 if (v < end()) {
jmasa@706 44 assert(!CheckZapUnusedHeapArea || is_mangled(v),
jmasa@706 45 "The high water mark is not mangled");
jmasa@698 46 }
jmasa@698 47 _top_for_allocations = v;
jmasa@698 48 }
jmasa@698 49
jmasa@698 50 // Mangle only the unused space that has not previously
jmasa@698 51 // been mangled and that has not been allocated since being
jmasa@698 52 // mangled.
jmasa@698 53 void SpaceMangler::mangle_unused_area() {
jmasa@698 54 assert(ZapUnusedHeapArea, "Mangling should not be in use");
jmasa@698 55 // Mangle between top and the high water mark. Safeguard
jmasa@698 56 // against the space changing since top_for_allocations was
jmasa@698 57 // set.
jmasa@698 58 HeapWord* mangled_end = MIN2(top_for_allocations(), end());
jmasa@698 59 if (top() < mangled_end) {
jmasa@698 60 MemRegion mangle_mr(top(), mangled_end);
jmasa@698 61 SpaceMangler::mangle_region(mangle_mr);
jmasa@698 62 // Light weight check of mangling.
jmasa@698 63 check_mangled_unused_area(end());
jmasa@698 64 }
jmasa@698 65 // Complete check of unused area which is functional when
jmasa@698 66 // DEBUG_MANGLING is defined.
jmasa@698 67 check_mangled_unused_area_complete();
jmasa@698 68 }
jmasa@698 69
jmasa@698 70 // A complete mangle is expected in the
jmasa@698 71 // exceptional case where top_for_allocations is not
jmasa@698 72 // properly tracking the high water mark for mangling.
jmasa@698 73 // This can be the case when to-space is being used for
jmasa@698 74 // scratch space during a mark-sweep-compact. See
jmasa@698 75 // contribute_scratch() and PSMarkSweep::allocate_stacks().
jmasa@698 76 void SpaceMangler::mangle_unused_area_complete() {
jmasa@698 77 assert(ZapUnusedHeapArea, "Mangling should not be in use");
jmasa@698 78 MemRegion mangle_mr(top(), end());
jmasa@698 79 SpaceMangler::mangle_region(mangle_mr);
jmasa@698 80 }
jmasa@698 81
jmasa@698 82 // Simply mangle the MemRegion mr.
jmasa@698 83 void SpaceMangler::mangle_region(MemRegion mr) {
jmasa@698 84 assert(ZapUnusedHeapArea, "Mangling should not be in use");
jmasa@698 85 #ifdef ASSERT
jmasa@698 86 if(TraceZapUnusedHeapArea) {
jmasa@698 87 gclog_or_tty->print("Mangling [0x%x to 0x%x)", mr.start(), mr.end());
jmasa@698 88 }
jmasa@698 89 Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord);
jmasa@698 90 if(TraceZapUnusedHeapArea) {
jmasa@698 91 gclog_or_tty->print_cr(" done");
jmasa@698 92 }
jmasa@698 93 #endif
jmasa@698 94 }
jmasa@698 95
jmasa@698 96 // Check that top, top_for_allocations and the last
jmasa@698 97 // word of the space are mangled. In a tight memory
jmasa@698 98 // situation even this light weight mangling could
jmasa@698 99 // cause paging by touching the end of the space.
jmasa@698 100 void SpaceMangler::check_mangled_unused_area(HeapWord* limit) {
jmasa@698 101 if (CheckZapUnusedHeapArea) {
jmasa@698 102 // This method can be called while the spaces are
jmasa@698 103 // being reshaped so skip the test if the end of the
jmasa@698 104 // space is beyond the specified limit;
jmasa@698 105 if (end() > limit) return;
jmasa@698 106
jmasa@698 107 assert(top() == end() ||
jmasa@698 108 (is_mangled(top())), "Top not mangled");
jmasa@698 109 assert((top_for_allocations() < top()) ||
jmasa@698 110 (top_for_allocations() >= end()) ||
jmasa@698 111 (is_mangled(top_for_allocations())),
jmasa@698 112 "Older unused not mangled");
jmasa@698 113 assert(top() == end() ||
jmasa@698 114 (is_mangled(end() - 1)), "End not properly mangled");
jmasa@698 115 // Only does checking when DEBUG_MANGLING is defined.
jmasa@698 116 check_mangled_unused_area_complete();
jmasa@698 117 }
jmasa@698 118 }
jmasa@698 119
jmasa@698 120 #undef DEBUG_MANGLING
jmasa@698 121 // This should only be used while debugging the mangling
jmasa@698 122 // because of the high cost of checking the completeness.
jmasa@698 123 void SpaceMangler::check_mangled_unused_area_complete() {
jmasa@698 124 if (CheckZapUnusedHeapArea) {
jmasa@698 125 assert(ZapUnusedHeapArea, "Not mangling unused area");
jmasa@698 126 #ifdef DEBUG_MANGLING
jmasa@698 127 HeapWord* q = top();
jmasa@698 128 HeapWord* limit = end();
jmasa@698 129
jmasa@698 130 bool passed = true;
jmasa@698 131 while (q < limit) {
jmasa@698 132 if (!is_mangled(q)) {
jmasa@698 133 passed = false;
jmasa@698 134 break;
jmasa@698 135 }
jmasa@698 136 q++;
jmasa@698 137 }
jmasa@698 138 assert(passed, "Mangling is not complete");
jmasa@698 139 #endif
jmasa@698 140 }
jmasa@698 141 }
jmasa@698 142 #undef DEBUG_MANGLING
jmasa@698 143 #endif // not PRODUCT

mercurial