src/share/vm/memory/genOopClosures.hpp

Wed, 18 Jan 2012 09:50:16 -0800

author
johnc
date
Wed, 18 Jan 2012 09:50:16 -0800
changeset 3538
d903bf750e9f
parent 2874
8d944991dbf9
child 3900
d2a62e0f25eb
permissions
-rw-r--r--

7129514: time warp warnings after 7117303
Summary: Replace calls to os::javaTimeMillis() that are used to update the milliseconds since the last GC to an equivalent that uses a monotonically non-decreasing time source.
Reviewed-by: ysr, jmasa

duke@435 1 /*
twisti@2806 2 * Copyright (c) 2001, 2011, 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_MEMORY_GENOOPCLOSURES_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_GENOOPCLOSURES_HPP
stefank@2314 27
stefank@2314 28 #include "memory/iterator.hpp"
stefank@2314 29 #include "oops/oop.hpp"
stefank@2314 30
duke@435 31 class Generation;
duke@435 32 class HeapWord;
duke@435 33 class CardTableRS;
duke@435 34 class CardTableModRefBS;
duke@435 35 class DefNewGeneration;
duke@435 36
jcoomes@1746 37 template<class E, unsigned int N> class GenericTaskQueue;
jcoomes@1746 38 typedef GenericTaskQueue<oop, TASKQUEUE_SIZE> OopTaskQueue;
jcoomes@1746 39 template<class T> class GenericTaskQueueSet;
jcoomes@1746 40 typedef GenericTaskQueueSet<OopTaskQueue> OopTaskQueueSet;
coleenp@548 41
duke@435 42 // Closure for iterating roots from a particular generation
duke@435 43 // Note: all classes deriving from this MUST call this do_barrier
duke@435 44 // method at the end of their own do_oop method!
duke@435 45 // Note: no do_oop defined, this is an abstract class.
duke@435 46
duke@435 47 class OopsInGenClosure : public OopClosure {
duke@435 48 private:
coleenp@548 49 Generation* _orig_gen; // generation originally set in ctor
coleenp@548 50 Generation* _gen; // generation being scanned
duke@435 51
duke@435 52 protected:
duke@435 53 // Some subtypes need access.
coleenp@548 54 HeapWord* _gen_boundary; // start of generation
coleenp@548 55 CardTableRS* _rs; // remembered set
duke@435 56
duke@435 57 // For assertions
duke@435 58 Generation* generation() { return _gen; }
duke@435 59 CardTableRS* rs() { return _rs; }
duke@435 60
duke@435 61 // Derived classes that modify oops so that they might be old-to-young
duke@435 62 // pointers must call the method below.
coleenp@548 63 template <class T> void do_barrier(T* p);
duke@435 64
ysr@777 65 // Version for use by closures that may be called in parallel code.
ysr@1280 66 template <class T> void par_do_barrier(T* p);
ysr@777 67
duke@435 68 public:
duke@435 69 OopsInGenClosure() : OopClosure(NULL),
duke@435 70 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
duke@435 71
duke@435 72 OopsInGenClosure(Generation* gen);
duke@435 73 void set_generation(Generation* gen);
duke@435 74
duke@435 75 void reset_generation() { _gen = _orig_gen; }
duke@435 76
duke@435 77 // Problem with static closures: must have _gen_boundary set at some point,
duke@435 78 // but cannot do this until after the heap is initialized.
duke@435 79 void set_orig_generation(Generation* gen) {
duke@435 80 _orig_gen = gen;
duke@435 81 set_generation(gen);
duke@435 82 }
duke@435 83
duke@435 84 HeapWord* gen_boundary() { return _gen_boundary; }
duke@435 85 };
duke@435 86
duke@435 87 // Closure for scanning DefNewGeneration.
duke@435 88 //
duke@435 89 // This closure will perform barrier store calls for ALL
duke@435 90 // pointers in scanned oops.
duke@435 91 class ScanClosure: public OopsInGenClosure {
coleenp@548 92 protected:
duke@435 93 DefNewGeneration* _g;
coleenp@548 94 HeapWord* _boundary;
coleenp@548 95 bool _gc_barrier;
coleenp@548 96 template <class T> inline void do_oop_work(T* p);
coleenp@548 97 public:
duke@435 98 ScanClosure(DefNewGeneration* g, bool gc_barrier);
coleenp@548 99 virtual void do_oop(oop* p);
coleenp@548 100 virtual void do_oop(narrowOop* p);
coleenp@548 101 inline void do_oop_nv(oop* p);
coleenp@548 102 inline void do_oop_nv(narrowOop* p);
duke@435 103 bool do_header() { return false; }
duke@435 104 Prefetch::style prefetch_style() {
duke@435 105 return Prefetch::do_write;
duke@435 106 }
duke@435 107 };
duke@435 108
duke@435 109 // Closure for scanning DefNewGeneration.
duke@435 110 //
duke@435 111 // This closure only performs barrier store calls on
duke@435 112 // pointers into the DefNewGeneration. This is less
duke@435 113 // precise, but faster, than a ScanClosure
duke@435 114 class FastScanClosure: public OopsInGenClosure {
coleenp@548 115 protected:
duke@435 116 DefNewGeneration* _g;
coleenp@548 117 HeapWord* _boundary;
coleenp@548 118 bool _gc_barrier;
coleenp@548 119 template <class T> inline void do_oop_work(T* p);
coleenp@548 120 public:
duke@435 121 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
coleenp@548 122 virtual void do_oop(oop* p);
coleenp@548 123 virtual void do_oop(narrowOop* p);
coleenp@548 124 inline void do_oop_nv(oop* p);
coleenp@548 125 inline void do_oop_nv(narrowOop* p);
duke@435 126 bool do_header() { return false; }
duke@435 127 Prefetch::style prefetch_style() {
duke@435 128 return Prefetch::do_write;
duke@435 129 }
duke@435 130 };
duke@435 131
duke@435 132 class FilteringClosure: public OopClosure {
coleenp@548 133 private:
coleenp@548 134 HeapWord* _boundary;
duke@435 135 OopClosure* _cl;
coleenp@548 136 protected:
coleenp@548 137 template <class T> inline void do_oop_work(T* p) {
coleenp@548 138 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 139 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 140 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 141 if ((HeapWord*)obj < _boundary) {
coleenp@548 142 _cl->do_oop(p);
coleenp@548 143 }
coleenp@548 144 }
coleenp@548 145 }
coleenp@548 146 public:
duke@435 147 FilteringClosure(HeapWord* boundary, OopClosure* cl) :
duke@435 148 OopClosure(cl->_ref_processor), _boundary(boundary),
duke@435 149 _cl(cl) {}
coleenp@548 150 virtual void do_oop(oop* p);
coleenp@548 151 virtual void do_oop(narrowOop* p);
coleenp@548 152 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); }
coleenp@548 153 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
duke@435 154 bool do_header() { return false; }
duke@435 155 };
duke@435 156
duke@435 157 // Closure for scanning DefNewGeneration's weak references.
duke@435 158 // NOTE: very much like ScanClosure but not derived from
duke@435 159 // OopsInGenClosure -- weak references are processed all
duke@435 160 // at once, with no notion of which generation they were in.
duke@435 161 class ScanWeakRefClosure: public OopClosure {
coleenp@548 162 protected:
coleenp@548 163 DefNewGeneration* _g;
coleenp@548 164 HeapWord* _boundary;
coleenp@548 165 template <class T> inline void do_oop_work(T* p);
coleenp@548 166 public:
duke@435 167 ScanWeakRefClosure(DefNewGeneration* g);
coleenp@548 168 virtual void do_oop(oop* p);
coleenp@548 169 virtual void do_oop(narrowOop* p);
coleenp@548 170 inline void do_oop_nv(oop* p);
coleenp@548 171 inline void do_oop_nv(narrowOop* p);
duke@435 172 };
duke@435 173
duke@435 174 class VerifyOopClosure: public OopClosure {
coleenp@548 175 protected:
coleenp@548 176 template <class T> inline void do_oop_work(T* p) {
coleenp@548 177 oop obj = oopDesc::load_decode_heap_oop(p);
twisti@2874 178 guarantee(obj->is_oop_or_null(), err_msg("invalid oop: " INTPTR_FORMAT, (oopDesc*) obj));
duke@435 179 }
coleenp@548 180 public:
coleenp@548 181 virtual void do_oop(oop* p);
coleenp@548 182 virtual void do_oop(narrowOop* p);
duke@435 183 static VerifyOopClosure verify_oop;
duke@435 184 };
stefank@2314 185
stefank@2314 186 #endif // SHARE_VM_MEMORY_GENOOPCLOSURES_HPP

mercurial