annotate src/share/vm/memory/genOopClosures.inline.hpp @ 113:ba764ed4b6f2

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
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1 37f87013dfd8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 inline OopsInGenClosure::OopsInGenClosure(Generation* gen) :
a61af66fc99e Initial load
duke
parents:
diff changeset
26 OopClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
27 set_generation(gen);
a61af66fc99e Initial load
duke
parents:
diff changeset
28 }
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 inline void OopsInGenClosure::set_generation(Generation* gen) {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 _gen = gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 _gen_boundary = _gen->reserved().start();
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Barrier set for the heap, must be set after heap is initialized
a61af66fc99e Initial load
duke
parents:
diff changeset
34 if (_rs == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 GenRemSet* rs = SharedHeap::heap()->rem_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 assert(rs->rs_kind() == GenRemSet::CardTable, "Wrong rem set kind");
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _rs = (CardTableRS*)rs;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
41 template <class T> inline void OopsInGenClosure::do_barrier(T* p) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 assert(generation()->is_in_reserved(p), "expected ref in generation");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
43 assert(!oopDesc::is_null(*p), "expected non-null object");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
44 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // If p points to a younger generation, mark the card.
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if ((HeapWord*)obj < _gen_boundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _rs->inline_write_ref_field_gc(p, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // NOTE! Any changes made here should also be made
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
52 // in FastScanClosure::do_oop_work()
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
53 template <class T> inline void ScanClosure::do_oop_work(T* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
54 T heap_oop = oopDesc::load_heap_oop(p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Should we copy the obj?
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
56 if (!oopDesc::is_null(heap_oop)) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
57 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if ((HeapWord*)obj < _boundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
60 oop new_obj = obj->is_forwarded() ? obj->forwardee()
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
61 : _g->copy_to_survivor_space(obj);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
62 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if (_gc_barrier) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Now call parent closure
a61af66fc99e Initial load
duke
parents:
diff changeset
66 do_barrier(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
71 inline void ScanClosure::do_oop_nv(oop* p) { ScanClosure::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
72 inline void ScanClosure::do_oop_nv(narrowOop* p) { ScanClosure::do_oop_work(p); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // NOTE! Any changes made here should also be made
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
75 // in ScanClosure::do_oop_work()
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
76 template <class T> inline void FastScanClosure::do_oop_work(T* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
77 T heap_oop = oopDesc::load_heap_oop(p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Should we copy the obj?
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
79 if (!oopDesc::is_null(heap_oop)) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
80 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81 if ((HeapWord*)obj < _boundary) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
83 oop new_obj = obj->is_forwarded() ? obj->forwardee()
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
84 : _g->copy_to_survivor_space(obj);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
85 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (_gc_barrier) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Now call parent closure
a61af66fc99e Initial load
duke
parents:
diff changeset
88 do_barrier(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
94 inline void FastScanClosure::do_oop_nv(oop* p) { FastScanClosure::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
95 inline void FastScanClosure::do_oop_nv(narrowOop* p) { FastScanClosure::do_oop_work(p); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Note similarity to ScanClosure; the difference is that
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // the barrier set is taken care of outside this closure.
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
99 template <class T> inline void ScanWeakRefClosure::do_oop_work(T* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
100 assert(!oopDesc::is_null(*p), "null weak reference?");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
101 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // weak references are sometimes scanned twice; must check
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // that to-space doesn't already contain this object
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
105 oop new_obj = obj->is_forwarded() ? obj->forwardee()
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
106 : _g->copy_to_survivor_space(obj);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
107 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
111 inline void ScanWeakRefClosure::do_oop_nv(oop* p) { ScanWeakRefClosure::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
112 inline void ScanWeakRefClosure::do_oop_nv(narrowOop* p) { ScanWeakRefClosure::do_oop_work(p); }