annotate src/share/vm/runtime/reflectionUtils.hpp @ 2368:dde920245681

6896099: Integrate CMS heap ergo with default heap sizing ergo 6627787: CMS: JVM refuses to start up with -Xms16m -Xmx16m 7000125: CMS: Anti-monotone young gen sizing with respect to maximum whole heap size specification 7027529: CMS: retire CMSUseOldDefaults flag Summary: Simplify CMS heap sizing code, relying on ergonomic initial sizing consistent with other collectors for the most part, controlling only young gen sizing to rein in pause times. Make CMS young gen sizing default statically cpu-dependant. Remove inconsistencies wrt generation sizing and policy code, allowing for the fixing for 6627787 and 7000125. For 7027529, retire the flag CMSUseOldDefaults which had been introduced as a bridge from JDK 5 to JDK 6 a number of years ago. Reviewed-by: brutisso, poonam
author ysr
date Wed, 16 Mar 2011 10:37:08 -0700
parents 3582bf76420e
children 1d1603768966
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/instanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/objArrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/oopsHierarchy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/reflection.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "utilities/accessFlags.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // A KlassStream is an abstract stream for streaming over self, superclasses
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // and (super)interfaces. Streaming is done in reverse order (subclasses first,
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // interfaces last).
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // for (KlassStream st(k, false, false); !st.eos(); st.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // klassOop k = st.klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class KlassStream VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 instanceKlassHandle _klass; // current klass/interface iterated over
a61af66fc99e Initial load
duke
parents:
diff changeset
49 objArrayHandle _interfaces; // transitive interfaces for initial class
a61af66fc99e Initial load
duke
parents:
diff changeset
50 int _interface_index; // current interface being processed
a61af66fc99e Initial load
duke
parents:
diff changeset
51 bool _local_only; // process initial class/interface only
a61af66fc99e Initial load
duke
parents:
diff changeset
52 bool _classes_only; // process classes only (no interfaces)
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int _index;
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 virtual int length() const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
59 KlassStream(instanceKlassHandle klass, bool local_only, bool classes_only);
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // testing
a61af66fc99e Initial load
duke
parents:
diff changeset
62 bool eos();
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // iterating
a61af66fc99e Initial load
duke
parents:
diff changeset
65 virtual void next() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
68 instanceKlassHandle klass() const { return _klass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int index() const { return _index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 };
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // A MethodStream streams over all methods in a class, superclasses and (super)interfaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Streaming is done in reverse order (subclasses first, methods in reverse order)
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 //
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // for (MethodStream st(k, false, false); !st.eos(); st.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // methodOop m = st.method();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 class MethodStream : public KlassStream {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int length() const { return methods()->length(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 objArrayOop methods() const { return _klass->methods(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
87 MethodStream(instanceKlassHandle klass, bool local_only, bool classes_only)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 : KlassStream(klass, local_only, classes_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _index = length();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void next() { _index--; }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 methodOop method() const { return methodOop(methods()->obj_at(index())); }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 };
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // A FieldStream streams over all fields in a class, superclasses and (super)interfaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Streaming is done in reverse order (subclasses first, fields in reverse order)
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // for (FieldStream st(k, false, false); !st.eos(); st.next()) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
103 // Symbol* field_name = st.name();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 class FieldStream : public KlassStream {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
110 int length() const { return fields()->length(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 constantPoolOop constants() const { return _klass->constants(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
113 typeArrayOop fields() const { return _klass->fields(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
115 FieldStream(instanceKlassHandle klass, bool local_only, bool classes_only)
a61af66fc99e Initial load
duke
parents:
diff changeset
116 : KlassStream(klass, local_only, classes_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _index = length();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void next() { _index -= instanceKlass::next_offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Accessors for current field
a61af66fc99e Initial load
duke
parents:
diff changeset
124 AccessFlags access_flags() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 AccessFlags flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 flags.set_flags(fields()->ushort_at(index() + instanceKlass::access_flags_offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
129 Symbol* name() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int name_index = fields()->ushort_at(index() + instanceKlass::name_index_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return constants()->symbol_at(name_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
133 Symbol* signature() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 int signature_index = fields()->ushort_at(index() +
a61af66fc99e Initial load
duke
parents:
diff changeset
135 instanceKlass::signature_index_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return constants()->symbol_at(signature_index);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // missing: initval()
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int offset() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return _klass->offset_from_fields( index() );
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 };
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 class FilteredField {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
146 klassOop _klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 int _field_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
150 FilteredField(klassOop klass, int field_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 _klass = klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 _field_offset = field_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 klassOop klass() { return _klass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 oop* klass_addr() { return (oop*) &_klass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 int field_offset() { return _field_offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 };
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 class FilteredFieldsMap : AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
161 static GrowableArray<FilteredField *> *_filtered_fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
163 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 static bool is_filtered_field(klassOop klass, int field_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 for (int i=0; i < _filtered_fields->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (klass == _filtered_fields->at(i)->klass() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
167 field_offset == _filtered_fields->at(i)->field_offset()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 static int filtered_fields_count(klassOop klass, bool local_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 int nflds = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 for (int i=0; i < _filtered_fields->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (local_only && klass == _filtered_fields->at(i)->klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 nflds++;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 } else if (klass->klass_part()->is_subtype_of(_filtered_fields->at(i)->klass())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 nflds++;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return nflds;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // GC support.
a61af66fc99e Initial load
duke
parents:
diff changeset
185 static void klasses_oops_do(OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 for (int i = 0; i < _filtered_fields->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 f->do_oop((oop*)_filtered_fields->at(i)->klass_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 };
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // A FilteredFieldStream streams over all fields in a class, superclasses and
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // (super)interfaces. Streaming is done in reverse order (subclasses first,
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // fields in reverse order)
a61af66fc99e Initial load
duke
parents:
diff changeset
196 //
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
198 //
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // for (FilteredFieldStream st(k, false, false); !st.eos(); st.next()) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
200 // Symbol* field_name = st.name();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 class FilteredFieldStream : public FieldStream {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
206 int _filtered_fields_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 bool has_filtered_field() { return (_filtered_fields_count > 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
210 FilteredFieldStream(instanceKlassHandle klass, bool local_only, bool classes_only)
a61af66fc99e Initial load
duke
parents:
diff changeset
211 : FieldStream(klass, local_only, classes_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 _filtered_fields_count = FilteredFieldsMap::filtered_fields_count((klassOop)klass(), local_only);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 int field_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 _index -= instanceKlass::next_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (has_filtered_field()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 while (_index >=0 && FilteredFieldsMap::is_filtered_field((klassOop)_klass(), offset())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 _index -= instanceKlass::next_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
224
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
225 #endif // SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP