src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp

Fri, 16 Mar 2012 16:14:04 +0100

author
nloodin
date
Fri, 16 Mar 2012 16:14:04 +0100
changeset 3665
8a729074feae
parent 3536
95f6641e38e0
child 4037
da91efe96a93
permissions
-rw-r--r--

7154517: Build error in hotspot-gc without precompiled headers
Reviewed-by: jcoomes, brutisso

duke@435 1 /*
iveresov@3536 2 * Copyright (c) 2002, 2012, 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_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
stefank@2314 29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
stefank@2314 30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
iveresov@3536 31 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
stefank@2314 32 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
stefank@2314 33
duke@435 34 inline void PSScavenge::save_to_space_top_before_gc() {
duke@435 35 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 36 _to_space_top_before_gc = heap->young_gen()->to_space()->top();
duke@435 37 }
duke@435 38
coleenp@548 39 template <class T> inline bool PSScavenge::should_scavenge(T* p) {
coleenp@548 40 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 41 if (oopDesc::is_null(heap_oop)) return false;
coleenp@548 42 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 43 return PSScavenge::is_obj_in_young((HeapWord*)obj);
duke@435 44 }
duke@435 45
coleenp@548 46 template <class T>
coleenp@548 47 inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
duke@435 48 if (should_scavenge(p)) {
coleenp@548 49 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
duke@435 50 // Skip objects copied to to_space since the scavenge started.
coleenp@548 51 HeapWord* const addr = (HeapWord*)obj;
duke@435 52 return addr < to_space_top_before_gc() || addr >= to_space->end();
duke@435 53 }
duke@435 54 return false;
duke@435 55 }
duke@435 56
coleenp@548 57 template <class T>
coleenp@548 58 inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
duke@435 59 if (check_to_space) {
coleenp@548 60 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
duke@435 61 return should_scavenge(p, heap->young_gen()->to_space());
duke@435 62 }
duke@435 63 return should_scavenge(p);
duke@435 64 }
duke@435 65
duke@435 66 // Attempt to "claim" oop at p via CAS, push the new obj if successful
duke@435 67 // This version tests the oop* to make sure it is within the heap before
duke@435 68 // attempting marking.
iveresov@3536 69 template <class T, bool promote_immediately>
duke@435 70 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
coleenp@548 71 T* p) {
coleenp@548 72 assert(should_scavenge(p, true), "revisiting object?");
duke@435 73
coleenp@548 74 oop o = oopDesc::load_decode_heap_oop_not_null(p);
coleenp@548 75 oop new_obj = o->is_forwarded()
coleenp@548 76 ? o->forwardee()
iveresov@3536 77 : pm->copy_to_survivor_space<promote_immediately>(o);
coleenp@548 78 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
duke@435 79
duke@435 80 // We cannot mark without test, as some code passes us pointers
duke@435 81 // that are outside the heap.
coleenp@548 82 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
duke@435 83 Universe::heap()->is_in_reserved(p)) {
coleenp@548 84 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
coleenp@548 85 card_table()->inline_write_ref_field_gc(p, new_obj);
duke@435 86 }
duke@435 87 }
duke@435 88 }
stefank@2314 89
iveresov@3536 90 template<bool promote_immediately>
iveresov@3536 91 class PSRootsClosure: public OopClosure {
jcoomes@2661 92 private:
jcoomes@2661 93 PSPromotionManager* _promotion_manager;
jcoomes@2661 94
jcoomes@2661 95 protected:
jcoomes@2661 96 template <class T> void do_oop_work(T *p) {
jcoomes@2661 97 if (PSScavenge::should_scavenge(p)) {
jcoomes@2661 98 // We never card mark roots, maybe call a func without test?
iveresov@3536 99 PSScavenge::copy_and_push_safe_barrier<T, promote_immediately>(_promotion_manager, p);
jcoomes@2661 100 }
jcoomes@2661 101 }
jcoomes@2661 102 public:
iveresov@3536 103 PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
iveresov@3536 104 void do_oop(oop* p) { PSRootsClosure::do_oop_work(p); }
iveresov@3536 105 void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); }
jcoomes@2661 106 };
jcoomes@2661 107
iveresov@3536 108 typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure;
iveresov@3536 109 typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure;
iveresov@3536 110
stefank@2314 111 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP

mercurial