annotate src/share/vm/oops/oop.cpp @ 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 1997-2006 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 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_oop.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 bool always_do_update_barrier = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 BarrierSet* oopDesc::_bs = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 #ifdef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
33 void oopDesc::print_on(outputStream* st) const {}
a61af66fc99e Initial load
duke
parents:
diff changeset
34 void oopDesc::print_value_on(outputStream* st) const {}
a61af66fc99e Initial load
duke
parents:
diff changeset
35 void oopDesc::print_address_on(outputStream* st) const {}
a61af66fc99e Initial load
duke
parents:
diff changeset
36 char* oopDesc::print_value_string() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
37 char* oopDesc::print_string() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
38 void oopDesc::print() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
39 void oopDesc::print_value() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
40 void oopDesc::print_address() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
41 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
42 void oopDesc::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if (this == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 st->print_cr("NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
45 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 blueprint()->oop_print_on(oop(this), st);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void oopDesc::print_value_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 oop obj = oop(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if (this == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 st->print("NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
54 } else if (java_lang_String::is_instance(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 java_lang_String::print(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 if (PrintOopAddress) print_address_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
58 } else if (!Universe::heap()->is_in(obj) || !Universe::heap()->is_in(klass())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 st->print("### BAD OOP %p ###", (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
61 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 blueprint()->oop_print_value_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void oopDesc::print_address_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 if (PrintOopAddress) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 st->print("{");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (PrintOopAddress) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 st->print(INTPTR_FORMAT, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 st->print("}");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void oopDesc::print() { print_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 void oopDesc::print_value() { print_value_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 void oopDesc::print_address() { print_address_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 char* oopDesc::print_string() {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 stringStream* st = new stringStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return st->as_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 char* oopDesc::print_value_string() {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 stringStream* st = new stringStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return st->as_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void oopDesc::verify_on(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (this != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 blueprint()->oop_verify_on(this, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void oopDesc::verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 verify_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
108 // XXX verify_old_oop doesn't do anything (should we remove?)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
109 void oopDesc::verify_old_oop(oop* p, bool allow_dirty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 blueprint()->oop_verify_old_oop(this, p, allow_dirty);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
113 void oopDesc::verify_old_oop(narrowOop* p, bool allow_dirty) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
114 blueprint()->oop_verify_old_oop(this, p, allow_dirty);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
115 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bool oopDesc::partially_loaded() {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return blueprint()->oop_partially_loaded(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void oopDesc::set_partially_loaded() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 blueprint()->oop_set_partially_loaded(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 intptr_t oopDesc::slow_identity_hash() {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // slow case; we have to acquire the micro lock in order to locate the header
a61af66fc99e Initial load
duke
parents:
diff changeset
129 ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
a61af66fc99e Initial load
duke
parents:
diff changeset
130 HandleMark hm;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 Handle object((oop)this);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 assert(!is_shared_readonly(), "using identity hash on readonly object?");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 return ObjectSynchronizer::identity_hash_value_for(object);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 VerifyOopClosure VerifyOopClosure::verify_oop;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
137
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
138 void VerifyOopClosure::do_oop(oop* p) { VerifyOopClosure::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
139 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }