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

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_HPP
aoqi@0 27
aoqi@0 28 #include "memory/allocation.hpp"
aoqi@0 29 #include "utilities/stack.hpp"
aoqi@0 30 #include "utilities/taskqueue.hpp"
aoqi@0 31
aoqi@0 32 // Move to some global location
aoqi@0 33 #define HAS_BEEN_MOVED 0x1501d01d
aoqi@0 34 // End move to some global location
aoqi@0 35
aoqi@0 36
aoqi@0 37 class MutableSpace;
aoqi@0 38 class PSOldGen;
aoqi@0 39 class ParCompactionManager;
aoqi@0 40 class ObjectStartArray;
aoqi@0 41 class ParallelCompactData;
aoqi@0 42 class ParMarkBitMap;
aoqi@0 43
aoqi@0 44 class ParCompactionManager : public CHeapObj<mtGC> {
aoqi@0 45 friend class ParallelTaskTerminator;
aoqi@0 46 friend class ParMarkBitMap;
aoqi@0 47 friend class PSParallelCompact;
aoqi@0 48 friend class StealRegionCompactionTask;
aoqi@0 49 friend class UpdateAndFillClosure;
aoqi@0 50 friend class RefProcTaskExecutor;
aoqi@0 51 friend class IdleGCTask;
aoqi@0 52
aoqi@0 53 public:
aoqi@0 54
aoqi@0 55 // ------------------------ Don't putback if not needed
aoqi@0 56 // Actions that the compaction manager should take.
aoqi@0 57 enum Action {
aoqi@0 58 Update,
aoqi@0 59 Copy,
aoqi@0 60 UpdateAndCopy,
aoqi@0 61 CopyAndUpdate,
aoqi@0 62 NotValid
aoqi@0 63 };
aoqi@0 64 // ------------------------ End don't putback if not needed
aoqi@0 65
aoqi@0 66 private:
aoqi@0 67 // 32-bit: 4K * 8 = 32KiB; 64-bit: 8K * 16 = 128KiB
aoqi@0 68 #define QUEUE_SIZE (1 << NOT_LP64(12) LP64_ONLY(13))
aoqi@0 69 typedef OverflowTaskQueue<ObjArrayTask, mtGC, QUEUE_SIZE> ObjArrayTaskQueue;
aoqi@0 70 typedef GenericTaskQueueSet<ObjArrayTaskQueue, mtGC> ObjArrayTaskQueueSet;
aoqi@0 71 #undef QUEUE_SIZE
aoqi@0 72
aoqi@0 73 static ParCompactionManager** _manager_array;
aoqi@0 74 static OopTaskQueueSet* _stack_array;
aoqi@0 75 static ObjArrayTaskQueueSet* _objarray_queues;
aoqi@0 76 static ObjectStartArray* _start_array;
aoqi@0 77 static RegionTaskQueueSet* _region_array;
aoqi@0 78 static PSOldGen* _old_gen;
aoqi@0 79
aoqi@0 80 private:
aoqi@0 81 OverflowTaskQueue<oop, mtGC> _marking_stack;
aoqi@0 82 ObjArrayTaskQueue _objarray_stack;
aoqi@0 83
aoqi@0 84 // Is there a way to reuse the _marking_stack for the
aoqi@0 85 // saving empty regions? For now just create a different
aoqi@0 86 // type of TaskQueue.
aoqi@0 87 RegionTaskQueue* _region_stack;
aoqi@0 88
aoqi@0 89 static RegionTaskQueue** _region_list;
aoqi@0 90 // Index in _region_list for current _region_stack.
aoqi@0 91 uint _region_stack_index;
aoqi@0 92
aoqi@0 93 // Indexes of recycled region stacks/overflow stacks
aoqi@0 94 // Stacks of regions to be compacted are embedded in the tasks doing
aoqi@0 95 // the compaction. A thread that executes the task extracts the
aoqi@0 96 // region stack and drains it. These threads keep these region
aoqi@0 97 // stacks for use during compaction task stealing. If a thread
aoqi@0 98 // gets a second draining task, it pushed its current region stack
aoqi@0 99 // index into the array _recycled_stack_index and gets a new
aoqi@0 100 // region stack from the task. A thread that is executing a
aoqi@0 101 // compaction stealing task without ever having executing a
aoqi@0 102 // draining task, will get a region stack from _recycled_stack_index.
aoqi@0 103 //
aoqi@0 104 // Array of indexes into the array of region stacks.
aoqi@0 105 static uint* _recycled_stack_index;
aoqi@0 106 // The index into _recycled_stack_index of the last region stack index
aoqi@0 107 // pushed. If -1, there are no entries into _recycled_stack_index.
aoqi@0 108 static int _recycled_top;
aoqi@0 109 // The index into _recycled_stack_index of the last region stack index
aoqi@0 110 // popped. If -1, there has not been any entry popped.
aoqi@0 111 static int _recycled_bottom;
aoqi@0 112
aoqi@0 113 static ParMarkBitMap* _mark_bitmap;
aoqi@0 114
aoqi@0 115 Action _action;
aoqi@0 116
aoqi@0 117 static PSOldGen* old_gen() { return _old_gen; }
aoqi@0 118 static ObjectStartArray* start_array() { return _start_array; }
aoqi@0 119 static OopTaskQueueSet* stack_array() { return _stack_array; }
aoqi@0 120
aoqi@0 121 static void initialize(ParMarkBitMap* mbm);
aoqi@0 122
aoqi@0 123 protected:
aoqi@0 124 // Array of tasks. Needed by the ParallelTaskTerminator.
aoqi@0 125 static RegionTaskQueueSet* region_array() { return _region_array; }
aoqi@0 126 OverflowTaskQueue<oop, mtGC>* marking_stack() { return &_marking_stack; }
aoqi@0 127
aoqi@0 128 // Pushes onto the marking stack. If the marking stack is full,
aoqi@0 129 // pushes onto the overflow stack.
aoqi@0 130 void stack_push(oop obj);
aoqi@0 131 // Do not implement an equivalent stack_pop. Deal with the
aoqi@0 132 // marking stack and overflow stack directly.
aoqi@0 133
aoqi@0 134 public:
aoqi@0 135 Action action() { return _action; }
aoqi@0 136 void set_action(Action v) { _action = v; }
aoqi@0 137
aoqi@0 138 RegionTaskQueue* region_stack() { return _region_stack; }
aoqi@0 139 void set_region_stack(RegionTaskQueue* v) { _region_stack = v; }
aoqi@0 140
aoqi@0 141 inline static ParCompactionManager* manager_array(int index);
aoqi@0 142
aoqi@0 143 inline static RegionTaskQueue* region_list(int index) {
aoqi@0 144 return _region_list[index];
aoqi@0 145 }
aoqi@0 146
aoqi@0 147 uint region_stack_index() { return _region_stack_index; }
aoqi@0 148 void set_region_stack_index(uint v) { _region_stack_index = v; }
aoqi@0 149
aoqi@0 150 // Pop and push unique reusable stack index
aoqi@0 151 static int pop_recycled_stack_index();
aoqi@0 152 static void push_recycled_stack_index(uint v);
aoqi@0 153 static void reset_recycled_stack_index() {
aoqi@0 154 _recycled_bottom = _recycled_top = -1;
aoqi@0 155 }
aoqi@0 156
aoqi@0 157 ParCompactionManager();
aoqi@0 158 ~ParCompactionManager();
aoqi@0 159
aoqi@0 160 // Pushes onto the region stack at the given index. If the
aoqi@0 161 // region stack is full,
aoqi@0 162 // pushes onto the region overflow stack.
aoqi@0 163 static void region_list_push(uint stack_index, size_t region_index);
aoqi@0 164 static void verify_region_list_empty(uint stack_index);
aoqi@0 165 ParMarkBitMap* mark_bitmap() { return _mark_bitmap; }
aoqi@0 166
aoqi@0 167 // void drain_stacks();
aoqi@0 168
aoqi@0 169 bool should_update();
aoqi@0 170 bool should_copy();
aoqi@0 171
aoqi@0 172 // Save for later processing. Must not fail.
aoqi@0 173 inline void push(oop obj) { _marking_stack.push(obj); }
aoqi@0 174 inline void push_objarray(oop objarray, size_t index);
aoqi@0 175 inline void push_region(size_t index);
aoqi@0 176
aoqi@0 177 // Access function for compaction managers
aoqi@0 178 static ParCompactionManager* gc_thread_compaction_manager(int index);
aoqi@0 179
aoqi@0 180 static bool steal(int queue_num, int* seed, oop& t) {
aoqi@0 181 return stack_array()->steal(queue_num, seed, t);
aoqi@0 182 }
aoqi@0 183
aoqi@0 184 static bool steal_objarray(int queue_num, int* seed, ObjArrayTask& t) {
aoqi@0 185 return _objarray_queues->steal(queue_num, seed, t);
aoqi@0 186 }
aoqi@0 187
aoqi@0 188 static bool steal(int queue_num, int* seed, size_t& region) {
aoqi@0 189 return region_array()->steal(queue_num, seed, region);
aoqi@0 190 }
aoqi@0 191
aoqi@0 192 // Process tasks remaining on any marking stack
aoqi@0 193 void follow_marking_stacks();
aoqi@0 194 inline bool marking_stacks_empty() const;
aoqi@0 195
aoqi@0 196 // Process tasks remaining on any stack
aoqi@0 197 void drain_region_stacks();
aoqi@0 198
aoqi@0 199 };
aoqi@0 200
aoqi@0 201 inline ParCompactionManager* ParCompactionManager::manager_array(int index) {
aoqi@0 202 assert(_manager_array != NULL, "access of NULL manager_array");
aoqi@0 203 assert(index >= 0 && index <= (int)ParallelGCThreads,
aoqi@0 204 "out of range manager_array access");
aoqi@0 205 return _manager_array[index];
aoqi@0 206 }
aoqi@0 207
aoqi@0 208 bool ParCompactionManager::marking_stacks_empty() const {
aoqi@0 209 return _marking_stack.is_empty() && _objarray_stack.is_empty();
aoqi@0 210 }
aoqi@0 211
aoqi@0 212 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_HPP

mercurial