annotate src/share/vm/oops/oop.pcgc.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
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 2005-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 void oopDesc::update_contents(ParCompactionManager* cm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // The klass field must be updated before anything else
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // can be done.
a61af66fc99e Initial load
duke
parents:
diff changeset
28 DEBUG_ONLY(klassOopDesc* original_klass = klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Can the option to update and/or copy be moved up in the
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // call chain to avoid calling into here?
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 if (PSParallelCompact::should_update_klass(klass())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 update_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
35 assert(klass()->is_klass(), "Not updated correctly");
a61af66fc99e Initial load
duke
parents:
diff changeset
36 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 assert(klass()->is_klass(), "Not updated");
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 Klass* new_klass = blueprint();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 if (!new_klass->oop_is_typeArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // It might contain oops beyond the header, so take the virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 new_klass->oop_update_pointers(cm, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Else skip it. The typeArrayKlass in the header never needs scavenging.
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 inline void oopDesc::update_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
49 HeapWord* begin_limit,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 HeapWord* end_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // The klass field must be updated before anything else
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // can be done.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 debug_only(klassOopDesc* original_klass = klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 update_contents(cm, klass(), begin_limit, end_limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 inline void oopDesc::update_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 klassOop old_klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
60 HeapWord* begin_limit,
a61af66fc99e Initial load
duke
parents:
diff changeset
61 HeapWord* end_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 klassOop updated_klass =
a61af66fc99e Initial load
duke
parents:
diff changeset
64 PSParallelCompact::summary_data().calc_new_klass(old_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Needs to be boundary aware for the 64 bit case
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // update_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // The klass has moved. Is the location of the klass
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // within the limits?
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
70 if ((((HeapWord*)&_metadata._klass) >= begin_limit) &&
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
71 (((HeapWord*)&_metadata._klass) < end_limit)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 set_klass(updated_klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 Klass* klass = updated_klass->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (!klass->oop_is_typeArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // It might contain oops beyond the header, so take the virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 klass->oop_update_pointers(cm, this, begin_limit, end_limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Else skip it. The typeArrayKlass in the header never needs scavenging.
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 inline void oopDesc::follow_contents(ParCompactionManager* cm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 assert (PSParallelCompact::mark_bitmap()->is_marked(this),
a61af66fc99e Initial load
duke
parents:
diff changeset
85 "should be marked");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 blueprint()->oop_follow_contents(cm, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Used by parallel old GC.
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 inline void oopDesc::follow_header(ParCompactionManager* cm) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
92 if (UseCompressedOops) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
93 PSParallelCompact::mark_and_push(cm, compressed_klass_addr());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
94 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
95 PSParallelCompact::mark_and_push(cm, klass_addr());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
96 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 inline oop oopDesc::forward_to_atomic(oop p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 assert(ParNewGeneration::is_legal_forward_ptr(p),
a61af66fc99e Initial load
duke
parents:
diff changeset
101 "illegal forwarding pointer value.");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 markOop oldMark = mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 markOop curMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 while (!is_forwarded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (curMark == oldMark) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 assert(is_forwarded(), "the CAS should have succeeded.");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 oldMark = curMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return forwardee();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 inline void oopDesc::update_header() {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
121 if (UseCompressedOops) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
122 PSParallelCompact::adjust_pointer(compressed_klass_addr());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
123 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
124 PSParallelCompact::adjust_pointer(klass_addr());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
125 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 inline void oopDesc::update_header(HeapWord* beg_addr, HeapWord* end_addr) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
129 if (UseCompressedOops) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
130 PSParallelCompact::adjust_pointer(compressed_klass_addr(),
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
131 beg_addr, end_addr);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
132 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
133 PSParallelCompact::adjust_pointer(klass_addr(), beg_addr, end_addr);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
134 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }