Tue, 11 May 2010 14:35:43 -0700
6931180: Migration to recent versions of MS Platform SDK
6951582: Build problems on win64
Summary: Changes to enable building JDK7 with Microsoft Visual Studio 2010
Reviewed-by: ohair, art, ccheung, dcubed
1 /*
2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 class Generation;
26 class HeapWord;
27 class CardTableRS;
28 class CardTableModRefBS;
29 class DefNewGeneration;
31 template<class E, unsigned int N> class GenericTaskQueue;
32 typedef GenericTaskQueue<oop, TASKQUEUE_SIZE> OopTaskQueue;
33 template<class T> class GenericTaskQueueSet;
34 typedef GenericTaskQueueSet<OopTaskQueue> OopTaskQueueSet;
36 // Closure for iterating roots from a particular generation
37 // Note: all classes deriving from this MUST call this do_barrier
38 // method at the end of their own do_oop method!
39 // Note: no do_oop defined, this is an abstract class.
41 class OopsInGenClosure : public OopClosure {
42 private:
43 Generation* _orig_gen; // generation originally set in ctor
44 Generation* _gen; // generation being scanned
46 protected:
47 // Some subtypes need access.
48 HeapWord* _gen_boundary; // start of generation
49 CardTableRS* _rs; // remembered set
51 // For assertions
52 Generation* generation() { return _gen; }
53 CardTableRS* rs() { return _rs; }
55 // Derived classes that modify oops so that they might be old-to-young
56 // pointers must call the method below.
57 template <class T> void do_barrier(T* p);
59 // Version for use by closures that may be called in parallel code.
60 template <class T> void par_do_barrier(T* p);
62 public:
63 OopsInGenClosure() : OopClosure(NULL),
64 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
66 OopsInGenClosure(Generation* gen);
67 void set_generation(Generation* gen);
69 void reset_generation() { _gen = _orig_gen; }
71 // Problem with static closures: must have _gen_boundary set at some point,
72 // but cannot do this until after the heap is initialized.
73 void set_orig_generation(Generation* gen) {
74 _orig_gen = gen;
75 set_generation(gen);
76 }
78 HeapWord* gen_boundary() { return _gen_boundary; }
79 };
81 // Closure for scanning DefNewGeneration.
82 //
83 // This closure will perform barrier store calls for ALL
84 // pointers in scanned oops.
85 class ScanClosure: public OopsInGenClosure {
86 protected:
87 DefNewGeneration* _g;
88 HeapWord* _boundary;
89 bool _gc_barrier;
90 template <class T> inline void do_oop_work(T* p);
91 public:
92 ScanClosure(DefNewGeneration* g, bool gc_barrier);
93 virtual void do_oop(oop* p);
94 virtual void do_oop(narrowOop* p);
95 inline void do_oop_nv(oop* p);
96 inline void do_oop_nv(narrowOop* p);
97 bool do_header() { return false; }
98 Prefetch::style prefetch_style() {
99 return Prefetch::do_write;
100 }
101 };
103 // Closure for scanning DefNewGeneration.
104 //
105 // This closure only performs barrier store calls on
106 // pointers into the DefNewGeneration. This is less
107 // precise, but faster, than a ScanClosure
108 class FastScanClosure: public OopsInGenClosure {
109 protected:
110 DefNewGeneration* _g;
111 HeapWord* _boundary;
112 bool _gc_barrier;
113 template <class T> inline void do_oop_work(T* p);
114 public:
115 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
116 virtual void do_oop(oop* p);
117 virtual void do_oop(narrowOop* p);
118 inline void do_oop_nv(oop* p);
119 inline void do_oop_nv(narrowOop* p);
120 bool do_header() { return false; }
121 Prefetch::style prefetch_style() {
122 return Prefetch::do_write;
123 }
124 };
126 class FilteringClosure: public OopClosure {
127 private:
128 HeapWord* _boundary;
129 OopClosure* _cl;
130 protected:
131 template <class T> inline void do_oop_work(T* p) {
132 T heap_oop = oopDesc::load_heap_oop(p);
133 if (!oopDesc::is_null(heap_oop)) {
134 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
135 if ((HeapWord*)obj < _boundary) {
136 _cl->do_oop(p);
137 }
138 }
139 }
140 public:
141 FilteringClosure(HeapWord* boundary, OopClosure* cl) :
142 OopClosure(cl->_ref_processor), _boundary(boundary),
143 _cl(cl) {}
144 virtual void do_oop(oop* p);
145 virtual void do_oop(narrowOop* p);
146 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); }
147 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
148 bool do_header() { return false; }
149 };
151 // Closure for scanning DefNewGeneration's weak references.
152 // NOTE: very much like ScanClosure but not derived from
153 // OopsInGenClosure -- weak references are processed all
154 // at once, with no notion of which generation they were in.
155 class ScanWeakRefClosure: public OopClosure {
156 protected:
157 DefNewGeneration* _g;
158 HeapWord* _boundary;
159 template <class T> inline void do_oop_work(T* p);
160 public:
161 ScanWeakRefClosure(DefNewGeneration* g);
162 virtual void do_oop(oop* p);
163 virtual void do_oop(narrowOop* p);
164 inline void do_oop_nv(oop* p);
165 inline void do_oop_nv(narrowOop* p);
166 };
168 class VerifyOopClosure: public OopClosure {
169 protected:
170 template <class T> inline void do_oop_work(T* p) {
171 oop obj = oopDesc::load_decode_heap_oop(p);
172 guarantee(obj->is_oop_or_null(), "invalid oop");
173 }
174 public:
175 virtual void do_oop(oop* p);
176 virtual void do_oop(narrowOop* p);
177 static VerifyOopClosure verify_oop;
178 };