src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.hpp

Tue, 28 Sep 2010 15:56:15 -0700

author
jcoomes
date
Tue, 28 Sep 2010 15:56:15 -0700
changeset 2191
894b1d7c7e01
parent 1993
b2a00dd3117c
child 2314
f95d63e2154a
permissions
-rw-r--r--

6423256: GC stacks should use a better data structure
6942771: SEGV in ParScanThreadState::take_from_overflow_stack
Reviewed-by: apetrusenko, ysr, pbk

duke@435 1 /*
jcoomes@1993 2 * Copyright (c) 2005, 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
duke@435 25 // Move to some global location
duke@435 26 #define HAS_BEEN_MOVED 0x1501d01d
duke@435 27 // End move to some global location
duke@435 28
duke@435 29
duke@435 30 class MutableSpace;
duke@435 31 class PSOldGen;
duke@435 32 class ParCompactionManager;
duke@435 33 class ObjectStartArray;
duke@435 34 class ParallelCompactData;
duke@435 35 class ParMarkBitMap;
duke@435 36
duke@435 37 class ParCompactionManager : public CHeapObj {
duke@435 38 friend class ParallelTaskTerminator;
duke@435 39 friend class ParMarkBitMap;
duke@435 40 friend class PSParallelCompact;
jcoomes@810 41 friend class StealRegionCompactionTask;
duke@435 42 friend class UpdateAndFillClosure;
duke@435 43 friend class RefProcTaskExecutor;
duke@435 44
duke@435 45 public:
duke@435 46
duke@435 47 // ------------------------ Don't putback if not needed
duke@435 48 // Actions that the compaction manager should take.
duke@435 49 enum Action {
duke@435 50 Update,
duke@435 51 Copy,
duke@435 52 UpdateAndCopy,
duke@435 53 CopyAndUpdate,
duke@435 54 VerifyUpdate,
duke@435 55 ResetObjects,
duke@435 56 NotValid
duke@435 57 };
duke@435 58 // ------------------------ End don't putback if not needed
duke@435 59
duke@435 60 private:
jcoomes@1746 61 // 32-bit: 4K * 8 = 32KiB; 64-bit: 8K * 16 = 128KiB
jcoomes@1993 62 #define QUEUE_SIZE (1 << NOT_LP64(12) LP64_ONLY(13))
jcoomes@1993 63 typedef OverflowTaskQueue<ObjArrayTask, QUEUE_SIZE> ObjArrayTaskQueue;
jcoomes@1993 64 typedef GenericTaskQueueSet<ObjArrayTaskQueue> ObjArrayTaskQueueSet;
jcoomes@1993 65 #undef QUEUE_SIZE
jcoomes@1746 66
jcoomes@810 67 static ParCompactionManager** _manager_array;
jcoomes@810 68 static OopTaskQueueSet* _stack_array;
jcoomes@1746 69 static ObjArrayTaskQueueSet* _objarray_queues;
jcoomes@810 70 static ObjectStartArray* _start_array;
jcoomes@810 71 static RegionTaskQueueSet* _region_array;
jcoomes@810 72 static PSOldGen* _old_gen;
duke@435 73
jcoomes@1746 74 private:
jcoomes@1993 75 OverflowTaskQueue<oop> _marking_stack;
jcoomes@1993 76 ObjArrayTaskQueue _objarray_stack;
jcoomes@1746 77
duke@435 78 // Is there a way to reuse the _marking_stack for the
jcoomes@810 79 // saving empty regions? For now just create a different
duke@435 80 // type of TaskQueue.
jcoomes@810 81 RegionTaskQueue _region_stack;
duke@435 82
jcoomes@2191 83 Stack<Klass*> _revisit_klass_stack;
jcoomes@2191 84 Stack<DataLayout*> _revisit_mdo_stack;
jcoomes@2191 85
duke@435 86 static ParMarkBitMap* _mark_bitmap;
duke@435 87
duke@435 88 Action _action;
duke@435 89
duke@435 90 static PSOldGen* old_gen() { return _old_gen; }
duke@435 91 static ObjectStartArray* start_array() { return _start_array; }
jcoomes@810 92 static OopTaskQueueSet* stack_array() { return _stack_array; }
duke@435 93
duke@435 94 static void initialize(ParMarkBitMap* mbm);
duke@435 95
duke@435 96 protected:
duke@435 97 // Array of tasks. Needed by the ParallelTaskTerminator.
jcoomes@810 98 static RegionTaskQueueSet* region_array() { return _region_array; }
jcoomes@1993 99 OverflowTaskQueue<oop>* marking_stack() { return &_marking_stack; }
jcoomes@1993 100 RegionTaskQueue* region_stack() { return &_region_stack; }
duke@435 101
duke@435 102 // Pushes onto the marking stack. If the marking stack is full,
duke@435 103 // pushes onto the overflow stack.
duke@435 104 void stack_push(oop obj);
duke@435 105 // Do not implement an equivalent stack_pop. Deal with the
duke@435 106 // marking stack and overflow stack directly.
duke@435 107
jcoomes@1993 108 public:
duke@435 109 Action action() { return _action; }
duke@435 110 void set_action(Action v) { _action = v; }
duke@435 111
duke@435 112 inline static ParCompactionManager* manager_array(int index);
duke@435 113
duke@435 114 ParCompactionManager();
duke@435 115
duke@435 116 ParMarkBitMap* mark_bitmap() { return _mark_bitmap; }
duke@435 117
duke@435 118 // Take actions in preparation for a compaction.
duke@435 119 static void reset();
duke@435 120
duke@435 121 // void drain_stacks();
duke@435 122
duke@435 123 bool should_update();
duke@435 124 bool should_copy();
duke@435 125 bool should_verify_only();
duke@435 126 bool should_reset_only();
duke@435 127
jcoomes@2191 128 Stack<Klass*>* revisit_klass_stack() { return &_revisit_klass_stack; }
jcoomes@2191 129 Stack<DataLayout*>* revisit_mdo_stack() { return &_revisit_mdo_stack; }
duke@435 130
jcoomes@1993 131 // Save for later processing. Must not fail.
jcoomes@1993 132 inline void push(oop obj) { _marking_stack.push(obj); }
jcoomes@1993 133 inline void push_objarray(oop objarray, size_t index);
jcoomes@1993 134 inline void push_region(size_t index);
duke@435 135
duke@435 136 // Access function for compaction managers
duke@435 137 static ParCompactionManager* gc_thread_compaction_manager(int index);
duke@435 138
jcoomes@1993 139 static bool steal(int queue_num, int* seed, oop& t) {
duke@435 140 return stack_array()->steal(queue_num, seed, t);
duke@435 141 }
duke@435 142
jcoomes@1746 143 static bool steal_objarray(int queue_num, int* seed, ObjArrayTask& t) {
jcoomes@1746 144 return _objarray_queues->steal(queue_num, seed, t);
jcoomes@1746 145 }
jcoomes@1746 146
jcoomes@1993 147 static bool steal(int queue_num, int* seed, size_t& region) {
jcoomes@1993 148 return region_array()->steal(queue_num, seed, region);
duke@435 149 }
duke@435 150
jcoomes@1746 151 // Process tasks remaining on any marking stack
jcoomes@1746 152 void follow_marking_stacks();
jcoomes@1746 153 inline bool marking_stacks_empty() const;
duke@435 154
duke@435 155 // Process tasks remaining on any stack
jcoomes@810 156 void drain_region_stacks();
duke@435 157
duke@435 158 };
duke@435 159
duke@435 160 inline ParCompactionManager* ParCompactionManager::manager_array(int index) {
duke@435 161 assert(_manager_array != NULL, "access of NULL manager_array");
duke@435 162 assert(index >= 0 && index <= (int)ParallelGCThreads,
duke@435 163 "out of range manager_array access");
duke@435 164 return _manager_array[index];
duke@435 165 }
jcoomes@1746 166
jcoomes@1746 167 bool ParCompactionManager::marking_stacks_empty() const {
jcoomes@1993 168 return _marking_stack.is_empty() && _objarray_stack.is_empty();
jcoomes@1746 169 }

mercurial