Thu, 22 Sep 2011 10:57:37 -0700
6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 2002, 2010, 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_PSTASKS_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "utilities/growableArray.hpp" |
stefank@2314 | 30 | |
duke@435 | 31 | // |
duke@435 | 32 | // psTasks.hpp is a collection of GCTasks used by the |
duke@435 | 33 | // parallelScavenge collector. |
duke@435 | 34 | // |
duke@435 | 35 | |
duke@435 | 36 | class GCTask; |
duke@435 | 37 | class OopClosure; |
duke@435 | 38 | class OopStack; |
duke@435 | 39 | class ObjectStartArray; |
duke@435 | 40 | class ParallelTaskTerminator; |
duke@435 | 41 | class MutableSpace; |
duke@435 | 42 | class PSOldGen; |
duke@435 | 43 | class Thread; |
duke@435 | 44 | class VMThread; |
duke@435 | 45 | |
duke@435 | 46 | // |
duke@435 | 47 | // ScavengeRootsTask |
duke@435 | 48 | // |
duke@435 | 49 | // This task scans all the roots of a given type. |
duke@435 | 50 | // |
duke@435 | 51 | // |
duke@435 | 52 | |
duke@435 | 53 | class ScavengeRootsTask : public GCTask { |
duke@435 | 54 | public: |
duke@435 | 55 | enum RootType { |
duke@435 | 56 | universe = 1, |
duke@435 | 57 | jni_handles = 2, |
duke@435 | 58 | threads = 3, |
duke@435 | 59 | object_synchronizer = 4, |
duke@435 | 60 | flat_profiler = 5, |
duke@435 | 61 | system_dictionary = 6, |
duke@435 | 62 | management = 7, |
jrose@1424 | 63 | jvmti = 8, |
jrose@1424 | 64 | code_cache = 9 |
duke@435 | 65 | }; |
duke@435 | 66 | private: |
duke@435 | 67 | RootType _root_type; |
duke@435 | 68 | public: |
duke@435 | 69 | ScavengeRootsTask(RootType value) : _root_type(value) {} |
duke@435 | 70 | |
duke@435 | 71 | char* name() { return (char *)"scavenge-roots-task"; } |
duke@435 | 72 | |
duke@435 | 73 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 74 | }; |
duke@435 | 75 | |
duke@435 | 76 | // |
duke@435 | 77 | // ThreadRootsTask |
duke@435 | 78 | // |
duke@435 | 79 | // This task scans the roots of a single thread. This task |
duke@435 | 80 | // enables scanning of thread roots in parallel. |
duke@435 | 81 | // |
duke@435 | 82 | |
duke@435 | 83 | class ThreadRootsTask : public GCTask { |
duke@435 | 84 | private: |
duke@435 | 85 | JavaThread* _java_thread; |
duke@435 | 86 | VMThread* _vm_thread; |
duke@435 | 87 | public: |
duke@435 | 88 | ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {} |
duke@435 | 89 | ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {} |
duke@435 | 90 | |
duke@435 | 91 | char* name() { return (char *)"thread-roots-task"; } |
duke@435 | 92 | |
duke@435 | 93 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 94 | }; |
duke@435 | 95 | |
duke@435 | 96 | // |
duke@435 | 97 | // StealTask |
duke@435 | 98 | // |
duke@435 | 99 | // This task is used to distribute work to idle threads. |
duke@435 | 100 | // |
duke@435 | 101 | |
duke@435 | 102 | class StealTask : public GCTask { |
duke@435 | 103 | private: |
duke@435 | 104 | ParallelTaskTerminator* const _terminator; |
duke@435 | 105 | public: |
duke@435 | 106 | char* name() { return (char *)"steal-task"; } |
duke@435 | 107 | |
duke@435 | 108 | StealTask(ParallelTaskTerminator* t); |
duke@435 | 109 | |
duke@435 | 110 | ParallelTaskTerminator* terminator() { return _terminator; } |
duke@435 | 111 | |
duke@435 | 112 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 113 | }; |
duke@435 | 114 | |
duke@435 | 115 | // |
duke@435 | 116 | // SerialOldToYoungRootsTask |
duke@435 | 117 | // |
duke@435 | 118 | // This task is used to scan for roots in the perm gen |
duke@435 | 119 | |
duke@435 | 120 | class SerialOldToYoungRootsTask : public GCTask { |
duke@435 | 121 | private: |
duke@435 | 122 | PSOldGen* _gen; |
duke@435 | 123 | HeapWord* _gen_top; |
duke@435 | 124 | |
duke@435 | 125 | public: |
duke@435 | 126 | SerialOldToYoungRootsTask(PSOldGen *gen, HeapWord* gen_top) : |
duke@435 | 127 | _gen(gen), _gen_top(gen_top) { } |
duke@435 | 128 | |
duke@435 | 129 | char* name() { return (char *)"serial-old-to-young-roots-task"; } |
duke@435 | 130 | |
duke@435 | 131 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 132 | }; |
duke@435 | 133 | |
duke@435 | 134 | // |
duke@435 | 135 | // OldToYoungRootsTask |
duke@435 | 136 | // |
duke@435 | 137 | // This task is used to scan old to young roots in parallel |
duke@435 | 138 | |
duke@435 | 139 | class OldToYoungRootsTask : public GCTask { |
duke@435 | 140 | private: |
duke@435 | 141 | PSOldGen* _gen; |
duke@435 | 142 | HeapWord* _gen_top; |
duke@435 | 143 | uint _stripe_number; |
duke@435 | 144 | |
duke@435 | 145 | public: |
duke@435 | 146 | OldToYoungRootsTask(PSOldGen *gen, HeapWord* gen_top, uint stripe_number) : |
duke@435 | 147 | _gen(gen), _gen_top(gen_top), _stripe_number(stripe_number) { } |
duke@435 | 148 | |
duke@435 | 149 | char* name() { return (char *)"old-to-young-roots-task"; } |
duke@435 | 150 | |
duke@435 | 151 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 152 | }; |
stefank@2314 | 153 | |
stefank@2314 | 154 | #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP |