src/share/vm/gc_implementation/shared/markSweep.inline.hpp

Mon, 06 Aug 2012 12:20:14 -0700

author
johnc
date
Mon, 06 Aug 2012 12:20:14 -0700
changeset 3982
aaf61e68b255
parent 3298
7913e93dca52
child 4037
da91efe96a93
permissions
-rw-r--r--

6818524: G1: use ergonomic resizing of PLABs
Summary: Employ PLABStats instances to record information about survivor and old PLABs, and use the recorded stats to adjust the sizes of survivor and old PLABS.
Reviewed-by: johnc, ysr
Contributed-by: Brandon Mitchell <brandon@twitter.com>

duke@435 1 /*
jmasa@3298 2 * Copyright (c) 2000, 2011, 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
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_INLINE_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_INLINE_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/shared/markSweep.hpp"
stefank@2314 29 #include "gc_interface/collectedHeap.hpp"
stefank@2314 30 #include "utilities/stack.inline.hpp"
stefank@2314 31 #ifndef SERIALGC
stefank@2314 32 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
stefank@2314 33 #endif
stefank@2314 34
duke@435 35 inline void MarkSweep::mark_object(oop obj) {
duke@435 36 // some marks may contain information we need to preserve so we store them away
duke@435 37 // and overwrite the mark. We'll restore it at the end of markSweep.
duke@435 38 markOop mark = obj->mark();
duke@435 39 obj->set_mark(markOopDesc::prototype()->set_marked());
duke@435 40
duke@435 41 if (mark->must_be_preserved(obj)) {
duke@435 42 preserve_mark(obj, mark);
duke@435 43 }
duke@435 44 }
coleenp@548 45
coleenp@548 46 template <class T> inline void MarkSweep::follow_root(T* p) {
coleenp@548 47 assert(!Universe::heap()->is_in_reserved(p),
coleenp@548 48 "roots shouldn't be things within the heap");
coleenp@548 49 #ifdef VALIDATE_MARK_SWEEP
coleenp@548 50 if (ValidateMarkSweep) {
coleenp@548 51 guarantee(!_root_refs_stack->contains(p), "should only be in here once");
coleenp@548 52 _root_refs_stack->push(p);
coleenp@548 53 }
coleenp@548 54 #endif
coleenp@548 55 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 56 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 57 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 58 if (!obj->mark()->is_marked()) {
coleenp@548 59 mark_object(obj);
coleenp@548 60 obj->follow_contents();
coleenp@548 61 }
coleenp@548 62 }
coleenp@548 63 follow_stack();
coleenp@548 64 }
coleenp@548 65
coleenp@548 66 template <class T> inline void MarkSweep::mark_and_push(T* p) {
coleenp@548 67 // assert(Universe::heap()->is_in_reserved(p), "should be in object space");
coleenp@548 68 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 69 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 70 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 71 if (!obj->mark()->is_marked()) {
coleenp@548 72 mark_object(obj);
jcoomes@2191 73 _marking_stack.push(obj);
coleenp@548 74 }
coleenp@548 75 }
coleenp@548 76 }
coleenp@548 77
jcoomes@1746 78 void MarkSweep::push_objarray(oop obj, size_t index) {
jcoomes@1746 79 ObjArrayTask task(obj, index);
jcoomes@1746 80 assert(task.is_valid(), "bad ObjArrayTask");
jcoomes@2191 81 _objarray_stack.push(task);
jcoomes@1746 82 }
jcoomes@1746 83
coleenp@548 84 template <class T> inline void MarkSweep::adjust_pointer(T* p, bool isroot) {
coleenp@548 85 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 86 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 87 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 88 oop new_obj = oop(obj->mark()->decode_pointer());
coleenp@548 89 assert(new_obj != NULL || // is forwarding ptr?
coleenp@548 90 obj->mark() == markOopDesc::prototype() || // not gc marked?
coleenp@548 91 (UseBiasedLocking && obj->mark()->has_bias_pattern()) ||
coleenp@548 92 // not gc marked?
coleenp@548 93 obj->is_shared(), // never forwarded?
coleenp@548 94 "should be forwarded");
coleenp@548 95 if (new_obj != NULL) {
coleenp@548 96 assert(Universe::heap()->is_in_reserved(new_obj),
coleenp@548 97 "should be in object space");
coleenp@548 98 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
coleenp@548 99 }
coleenp@548 100 }
coleenp@548 101 VALIDATE_MARK_SWEEP_ONLY(track_adjusted_pointer(p, isroot));
coleenp@548 102 }
coleenp@548 103
coleenp@548 104 template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
coleenp@548 105 #ifdef VALIDATE_MARK_SWEEP
coleenp@548 106 if (ValidateMarkSweep) {
coleenp@548 107 if (!Universe::heap()->is_in_reserved(p)) {
coleenp@548 108 _root_refs_stack->push(p);
coleenp@548 109 } else {
coleenp@548 110 _other_refs_stack->push(p);
coleenp@548 111 }
coleenp@548 112 }
coleenp@548 113 #endif
coleenp@548 114 mark_and_push(p);
coleenp@548 115 }
stefank@2314 116
stefank@2314 117 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_INLINE_HPP

mercurial