Sun, 13 Apr 2008 17:43:42 -0400
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
1 /*
2 * Copyright 2001-2007 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> class GenericTaskQueue;
32 typedef GenericTaskQueue<oop> OopTaskQueue;
33 template<class E> class GenericTaskQueueSet;
34 typedef GenericTaskQueueSet<oop> 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 public:
60 OopsInGenClosure() : OopClosure(NULL),
61 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
63 OopsInGenClosure(Generation* gen);
64 void set_generation(Generation* gen);
66 void reset_generation() { _gen = _orig_gen; }
68 // Problem with static closures: must have _gen_boundary set at some point,
69 // but cannot do this until after the heap is initialized.
70 void set_orig_generation(Generation* gen) {
71 _orig_gen = gen;
72 set_generation(gen);
73 }
75 HeapWord* gen_boundary() { return _gen_boundary; }
76 };
78 // Closure for scanning DefNewGeneration.
79 //
80 // This closure will perform barrier store calls for ALL
81 // pointers in scanned oops.
82 class ScanClosure: public OopsInGenClosure {
83 protected:
84 DefNewGeneration* _g;
85 HeapWord* _boundary;
86 bool _gc_barrier;
87 template <class T> inline void do_oop_work(T* p);
88 public:
89 ScanClosure(DefNewGeneration* g, bool gc_barrier);
90 virtual void do_oop(oop* p);
91 virtual void do_oop(narrowOop* p);
92 inline void do_oop_nv(oop* p);
93 inline void do_oop_nv(narrowOop* p);
94 bool do_header() { return false; }
95 Prefetch::style prefetch_style() {
96 return Prefetch::do_write;
97 }
98 };
100 // Closure for scanning DefNewGeneration.
101 //
102 // This closure only performs barrier store calls on
103 // pointers into the DefNewGeneration. This is less
104 // precise, but faster, than a ScanClosure
105 class FastScanClosure: public OopsInGenClosure {
106 protected:
107 DefNewGeneration* _g;
108 HeapWord* _boundary;
109 bool _gc_barrier;
110 template <class T> inline void do_oop_work(T* p);
111 public:
112 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
113 virtual void do_oop(oop* p);
114 virtual void do_oop(narrowOop* p);
115 inline void do_oop_nv(oop* p);
116 inline void do_oop_nv(narrowOop* p);
117 bool do_header() { return false; }
118 Prefetch::style prefetch_style() {
119 return Prefetch::do_write;
120 }
121 };
123 class FilteringClosure: public OopClosure {
124 private:
125 HeapWord* _boundary;
126 OopClosure* _cl;
127 protected:
128 template <class T> inline void do_oop_work(T* p) {
129 T heap_oop = oopDesc::load_heap_oop(p);
130 if (!oopDesc::is_null(heap_oop)) {
131 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
132 if ((HeapWord*)obj < _boundary) {
133 _cl->do_oop(p);
134 }
135 }
136 }
137 public:
138 FilteringClosure(HeapWord* boundary, OopClosure* cl) :
139 OopClosure(cl->_ref_processor), _boundary(boundary),
140 _cl(cl) {}
141 virtual void do_oop(oop* p);
142 virtual void do_oop(narrowOop* p);
143 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); }
144 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
145 bool do_header() { return false; }
146 };
148 // Closure for scanning DefNewGeneration's weak references.
149 // NOTE: very much like ScanClosure but not derived from
150 // OopsInGenClosure -- weak references are processed all
151 // at once, with no notion of which generation they were in.
152 class ScanWeakRefClosure: public OopClosure {
153 protected:
154 DefNewGeneration* _g;
155 HeapWord* _boundary;
156 template <class T> inline void do_oop_work(T* p);
157 public:
158 ScanWeakRefClosure(DefNewGeneration* g);
159 virtual void do_oop(oop* p);
160 virtual void do_oop(narrowOop* p);
161 inline void do_oop_nv(oop* p);
162 inline void do_oop_nv(narrowOop* p);
163 };
165 class VerifyOopClosure: public OopClosure {
166 protected:
167 template <class T> inline void do_oop_work(T* p) {
168 oop obj = oopDesc::load_decode_heap_oop(p);
169 guarantee(obj->is_oop_or_null(), "invalid oop");
170 }
171 public:
172 virtual void do_oop(oop* p);
173 virtual void do_oop(narrowOop* p);
174 static VerifyOopClosure verify_oop;
175 };