Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/reflectionUtils.hpp @ 3979:4dfb2df418f2
6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
author | johnc |
---|---|
date | Thu, 22 Sep 2011 10:57:37 -0700 |
parents | e6b1331a51d2 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2177
diff
changeset
|
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP |
26 #define SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "oops/instanceKlass.hpp" | |
30 #include "oops/objArrayOop.hpp" | |
31 #include "oops/oopsHierarchy.hpp" | |
32 #include "runtime/handles.inline.hpp" | |
33 #include "runtime/reflection.hpp" | |
34 #include "utilities/accessFlags.hpp" | |
35 #include "utilities/globalDefinitions.hpp" | |
36 | |
0 | 37 // A KlassStream is an abstract stream for streaming over self, superclasses |
38 // and (super)interfaces. Streaming is done in reverse order (subclasses first, | |
39 // interfaces last). | |
40 // | |
41 // for (KlassStream st(k, false, false); !st.eos(); st.next()) { | |
42 // klassOop k = st.klass(); | |
43 // ... | |
44 // } | |
45 | |
46 class KlassStream VALUE_OBJ_CLASS_SPEC { | |
47 protected: | |
48 instanceKlassHandle _klass; // current klass/interface iterated over | |
49 objArrayHandle _interfaces; // transitive interfaces for initial class | |
50 int _interface_index; // current interface being processed | |
51 bool _local_only; // process initial class/interface only | |
52 bool _classes_only; // process classes only (no interfaces) | |
53 int _index; | |
54 | |
55 virtual int length() const = 0; | |
56 | |
57 public: | |
58 // constructor | |
59 KlassStream(instanceKlassHandle klass, bool local_only, bool classes_only); | |
60 | |
61 // testing | |
62 bool eos(); | |
63 | |
64 // iterating | |
65 virtual void next() = 0; | |
66 | |
67 // accessors | |
68 instanceKlassHandle klass() const { return _klass; } | |
69 int index() const { return _index; } | |
70 }; | |
71 | |
72 | |
73 // A MethodStream streams over all methods in a class, superclasses and (super)interfaces. | |
74 // Streaming is done in reverse order (subclasses first, methods in reverse order) | |
75 // Usage: | |
76 // | |
77 // for (MethodStream st(k, false, false); !st.eos(); st.next()) { | |
78 // methodOop m = st.method(); | |
79 // ... | |
80 // } | |
81 | |
82 class MethodStream : public KlassStream { | |
83 private: | |
84 int length() const { return methods()->length(); } | |
85 objArrayOop methods() const { return _klass->methods(); } | |
86 public: | |
87 MethodStream(instanceKlassHandle klass, bool local_only, bool classes_only) | |
88 : KlassStream(klass, local_only, classes_only) { | |
89 _index = length(); | |
90 next(); | |
91 } | |
92 | |
93 void next() { _index--; } | |
94 methodOop method() const { return methodOop(methods()->obj_at(index())); } | |
95 }; | |
96 | |
97 | |
98 // A FieldStream streams over all fields in a class, superclasses and (super)interfaces. | |
99 // Streaming is done in reverse order (subclasses first, fields in reverse order) | |
100 // Usage: | |
101 // | |
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 | 104 // ... |
105 // } | |
106 | |
107 | |
108 class FieldStream : public KlassStream { | |
109 private: | |
3938 | 110 int length() const { return _klass->java_fields_count(); } |
111 | |
0 | 112 public: |
113 FieldStream(instanceKlassHandle klass, bool local_only, bool classes_only) | |
114 : KlassStream(klass, local_only, classes_only) { | |
115 _index = length(); | |
116 next(); | |
117 } | |
118 | |
3938 | 119 void next() { _index -= 1; } |
0 | 120 |
121 // Accessors for current field | |
122 AccessFlags access_flags() const { | |
123 AccessFlags flags; | |
3938 | 124 flags.set_flags(_klass->field_access_flags(_index)); |
0 | 125 return flags; |
126 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
127 Symbol* name() const { |
3938 | 128 return _klass->field_name(_index); |
0 | 129 } |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
130 Symbol* signature() const { |
3938 | 131 return _klass->field_signature(_index); |
0 | 132 } |
133 // missing: initval() | |
134 int offset() const { | |
3938 | 135 return _klass->field_offset( index() ); |
0 | 136 } |
137 }; | |
138 | |
139 class FilteredField { | |
140 private: | |
141 klassOop _klass; | |
142 int _field_offset; | |
143 | |
144 public: | |
145 FilteredField(klassOop klass, int field_offset) { | |
146 _klass = klass; | |
147 _field_offset = field_offset; | |
148 } | |
149 klassOop klass() { return _klass; } | |
150 oop* klass_addr() { return (oop*) &_klass; } | |
151 int field_offset() { return _field_offset; } | |
152 }; | |
153 | |
154 class FilteredFieldsMap : AllStatic { | |
155 private: | |
156 static GrowableArray<FilteredField *> *_filtered_fields; | |
157 public: | |
158 static void initialize(); | |
159 static bool is_filtered_field(klassOop klass, int field_offset) { | |
160 for (int i=0; i < _filtered_fields->length(); i++) { | |
161 if (klass == _filtered_fields->at(i)->klass() && | |
162 field_offset == _filtered_fields->at(i)->field_offset()) { | |
163 return true; | |
164 } | |
165 } | |
166 return false; | |
167 } | |
168 static int filtered_fields_count(klassOop klass, bool local_only) { | |
169 int nflds = 0; | |
170 for (int i=0; i < _filtered_fields->length(); i++) { | |
171 if (local_only && klass == _filtered_fields->at(i)->klass()) { | |
172 nflds++; | |
173 } else if (klass->klass_part()->is_subtype_of(_filtered_fields->at(i)->klass())) { | |
174 nflds++; | |
175 } | |
176 } | |
177 return nflds; | |
178 } | |
179 // GC support. | |
180 static void klasses_oops_do(OopClosure* f) { | |
181 for (int i = 0; i < _filtered_fields->length(); i++) { | |
182 f->do_oop((oop*)_filtered_fields->at(i)->klass_addr()); | |
183 } | |
184 } | |
185 }; | |
186 | |
187 | |
188 // A FilteredFieldStream streams over all fields in a class, superclasses and | |
189 // (super)interfaces. Streaming is done in reverse order (subclasses first, | |
190 // fields in reverse order) | |
191 // | |
192 // Usage: | |
193 // | |
194 // 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
|
195 // Symbol* field_name = st.name(); |
0 | 196 // ... |
197 // } | |
198 | |
199 class FilteredFieldStream : public FieldStream { | |
200 private: | |
201 int _filtered_fields_count; | |
202 bool has_filtered_field() { return (_filtered_fields_count > 0); } | |
203 | |
204 public: | |
205 FilteredFieldStream(instanceKlassHandle klass, bool local_only, bool classes_only) | |
206 : FieldStream(klass, local_only, classes_only) { | |
207 _filtered_fields_count = FilteredFieldsMap::filtered_fields_count((klassOop)klass(), local_only); | |
208 } | |
209 int field_count(); | |
210 void next() { | |
3938 | 211 _index -= 1; |
0 | 212 if (has_filtered_field()) { |
213 while (_index >=0 && FilteredFieldsMap::is_filtered_field((klassOop)_klass(), offset())) { | |
3938 | 214 _index -= 1; |
0 | 215 } |
216 } | |
217 } | |
218 }; | |
1972 | 219 |
220 #endif // SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP |