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

Sat, 19 Jul 2008 17:38:22 -0400

author
coleenp
date
Sat, 19 Jul 2008 17:38:22 -0400
changeset 672
1fdb98a17101
parent 435
a61af66fc99e
child 810
81cd571500b0
permissions
-rw-r--r--

6716785: implicit null checks not triggering with CompressedOops
Summary: allocate alignment-sized page(s) below java heap so that memory accesses at heap_base+1page give signal and cause an implicit null check
Reviewed-by: kvn, jmasa, phh, jcoomes

duke@435 1 /*
duke@435 2 * Copyright 2005-2007 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 //
duke@435 26 // psPromotionManager is used by a single thread to manage object survival
duke@435 27 // during a scavenge. The promotion manager contains thread local data only.
duke@435 28 //
duke@435 29 // NOTE! Be carefull when allocating the stacks on cheap. If you are going
duke@435 30 // to use a promotion manager in more than one thread, the stacks MUST be
duke@435 31 // on cheap. This can lead to memory leaks, though, as they are not auto
duke@435 32 // deallocated.
duke@435 33 //
duke@435 34 // FIX ME FIX ME Add a destructor, and don't rely on the user to drain/flush/deallocate!
duke@435 35 //
duke@435 36
duke@435 37 // Move to some global location
duke@435 38 #define HAS_BEEN_MOVED 0x1501d01d
duke@435 39 // End move to some global location
duke@435 40
duke@435 41
duke@435 42 class MutableSpace;
duke@435 43 class PSOldGen;
duke@435 44 class ParCompactionManager;
duke@435 45 class ObjectStartArray;
duke@435 46 class ParallelCompactData;
duke@435 47 class ParMarkBitMap;
duke@435 48
duke@435 49 // Move to it's own file if this works out.
duke@435 50
duke@435 51 class ParCompactionManager : public CHeapObj {
duke@435 52 friend class ParallelTaskTerminator;
duke@435 53 friend class ParMarkBitMap;
duke@435 54 friend class PSParallelCompact;
duke@435 55 friend class StealChunkCompactionTask;
duke@435 56 friend class UpdateAndFillClosure;
duke@435 57 friend class RefProcTaskExecutor;
duke@435 58
duke@435 59 public:
duke@435 60
duke@435 61 // ------------------------ Don't putback if not needed
duke@435 62 // Actions that the compaction manager should take.
duke@435 63 enum Action {
duke@435 64 Update,
duke@435 65 Copy,
duke@435 66 UpdateAndCopy,
duke@435 67 CopyAndUpdate,
duke@435 68 VerifyUpdate,
duke@435 69 ResetObjects,
duke@435 70 NotValid
duke@435 71 };
duke@435 72 // ------------------------ End don't putback if not needed
duke@435 73
duke@435 74 private:
duke@435 75 static ParCompactionManager** _manager_array;
duke@435 76 static OopTaskQueueSet* _stack_array;
duke@435 77 static ObjectStartArray* _start_array;
duke@435 78 static ChunkTaskQueueSet* _chunk_array;
duke@435 79 static PSOldGen* _old_gen;
duke@435 80
duke@435 81 OopTaskQueue _marking_stack;
duke@435 82 GrowableArray<oop>* _overflow_stack;
duke@435 83 // Is there a way to reuse the _marking_stack for the
duke@435 84 // saving empty chunks? For now just create a different
duke@435 85 // type of TaskQueue.
duke@435 86
duke@435 87 #ifdef USE_ChunkTaskQueueWithOverflow
duke@435 88 ChunkTaskQueueWithOverflow _chunk_stack;
duke@435 89 #else
duke@435 90 ChunkTaskQueue _chunk_stack;
duke@435 91 GrowableArray<size_t>* _chunk_overflow_stack;
duke@435 92 #endif
duke@435 93
duke@435 94 #if 1 // does this happen enough to need a per thread stack?
duke@435 95 GrowableArray<Klass*>* _revisit_klass_stack;
duke@435 96 #endif
duke@435 97 static ParMarkBitMap* _mark_bitmap;
duke@435 98
duke@435 99 Action _action;
duke@435 100
duke@435 101 static PSOldGen* old_gen() { return _old_gen; }
duke@435 102 static ObjectStartArray* start_array() { return _start_array; }
duke@435 103 static OopTaskQueueSet* stack_array() { return _stack_array; }
duke@435 104
duke@435 105 static void initialize(ParMarkBitMap* mbm);
duke@435 106
duke@435 107 protected:
duke@435 108 // Array of tasks. Needed by the ParallelTaskTerminator.
duke@435 109 static ChunkTaskQueueSet* chunk_array() { return _chunk_array; }
duke@435 110
duke@435 111 OopTaskQueue* marking_stack() { return &_marking_stack; }
duke@435 112 GrowableArray<oop>* overflow_stack() { return _overflow_stack; }
duke@435 113 #ifdef USE_ChunkTaskQueueWithOverflow
duke@435 114 ChunkTaskQueueWithOverflow* chunk_stack() { return &_chunk_stack; }
duke@435 115 #else
duke@435 116 ChunkTaskQueue* chunk_stack() { return &_chunk_stack; }
duke@435 117 GrowableArray<size_t>* chunk_overflow_stack() { return _chunk_overflow_stack; }
duke@435 118 #endif
duke@435 119
duke@435 120 // Pushes onto the marking stack. If the marking stack is full,
duke@435 121 // pushes onto the overflow stack.
duke@435 122 void stack_push(oop obj);
duke@435 123 // Do not implement an equivalent stack_pop. Deal with the
duke@435 124 // marking stack and overflow stack directly.
duke@435 125
duke@435 126 // Pushes onto the chunk stack. If the chunk stack is full,
duke@435 127 // pushes onto the chunk overflow stack.
duke@435 128 void chunk_stack_push(size_t chunk_index);
duke@435 129 public:
duke@435 130
duke@435 131 Action action() { return _action; }
duke@435 132 void set_action(Action v) { _action = v; }
duke@435 133
duke@435 134 inline static ParCompactionManager* manager_array(int index);
duke@435 135
duke@435 136 ParCompactionManager();
duke@435 137 ~ParCompactionManager();
duke@435 138
duke@435 139 void allocate_stacks();
duke@435 140 void deallocate_stacks();
duke@435 141 ParMarkBitMap* mark_bitmap() { return _mark_bitmap; }
duke@435 142
duke@435 143 // Take actions in preparation for a compaction.
duke@435 144 static void reset();
duke@435 145
duke@435 146 // void drain_stacks();
duke@435 147
duke@435 148 bool should_update();
duke@435 149 bool should_copy();
duke@435 150 bool should_verify_only();
duke@435 151 bool should_reset_only();
duke@435 152
duke@435 153 #if 1
duke@435 154 // Probably stays as a growable array
duke@435 155 GrowableArray<Klass*>* revisit_klass_stack() { return _revisit_klass_stack; }
duke@435 156 #endif
duke@435 157
duke@435 158 // Save oop for later processing. Must not fail.
duke@435 159 void save_for_scanning(oop m);
duke@435 160 // Get a oop for scanning. If returns null, no oop were found.
duke@435 161 oop retrieve_for_scanning();
duke@435 162
duke@435 163 // Save chunk for later processing. Must not fail.
duke@435 164 void save_for_processing(size_t chunk_index);
duke@435 165 // Get a chunk for processing. If returns null, no chunk were found.
duke@435 166 bool retrieve_for_processing(size_t& chunk_index);
duke@435 167
duke@435 168 // Access function for compaction managers
duke@435 169 static ParCompactionManager* gc_thread_compaction_manager(int index);
duke@435 170
duke@435 171 static bool steal(int queue_num, int* seed, Task& t) {
duke@435 172 return stack_array()->steal(queue_num, seed, t);
duke@435 173 }
duke@435 174
duke@435 175 static bool steal(int queue_num, int* seed, ChunkTask& t) {
duke@435 176 return chunk_array()->steal(queue_num, seed, t);
duke@435 177 }
duke@435 178
duke@435 179 // Process tasks remaining on any stack
duke@435 180 void drain_marking_stacks(OopClosure *blk);
duke@435 181
duke@435 182 // Process tasks remaining on any stack
duke@435 183 void drain_chunk_stacks();
duke@435 184
duke@435 185 // Process tasks remaining on any stack
duke@435 186 void drain_chunk_overflow_stack();
duke@435 187
duke@435 188 // Debugging support
duke@435 189 #ifdef ASSERT
duke@435 190 bool stacks_have_been_allocated();
duke@435 191 #endif
duke@435 192 };
duke@435 193
duke@435 194 inline ParCompactionManager* ParCompactionManager::manager_array(int index) {
duke@435 195 assert(_manager_array != NULL, "access of NULL manager_array");
duke@435 196 assert(index >= 0 && index <= (int)ParallelGCThreads,
duke@435 197 "out of range manager_array access");
duke@435 198 return _manager_array[index];
duke@435 199 }

mercurial