comparison src/share/vm/classfile/classFileParser.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 1d7922586cf6
children d8ce2825b193 19eb999cb72c
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
60 bool _synthetic_flag; 60 bool _synthetic_flag;
61 Symbol* _sourcefile; 61 Symbol* _sourcefile;
62 Symbol* _generic_signature; 62 Symbol* _generic_signature;
63 char* _sde_buffer; 63 char* _sde_buffer;
64 int _sde_length; 64 int _sde_length;
65 typeArrayHandle _inner_classes; 65 Array<u2>* _inner_classes;
66 typeArrayHandle _annotations; 66 AnnotationArray* _annotations;
67 67
68 void set_class_synthetic_flag(bool x) { _synthetic_flag = x; } 68 void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
69 void set_class_sourcefile(Symbol* x) { _sourcefile = x; } 69 void set_class_sourcefile(Symbol* x) { _sourcefile = x; }
70 void set_class_generic_signature(Symbol* x) { _generic_signature = x; } 70 void set_class_generic_signature(Symbol* x) { _generic_signature = x; }
71 void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; } 71 void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; }
72 void set_class_inner_classes(typeArrayHandle x) { _inner_classes = x; } 72 void set_class_inner_classes(Array<u2>* x) { _inner_classes = x; }
73 void set_class_annotations(typeArrayHandle x) { _annotations = x; } 73 void set_class_annotations(AnnotationArray* x) { _annotations = x; }
74 void init_parsed_class_attributes() { 74 void init_parsed_class_attributes() {
75 _synthetic_flag = false; 75 _synthetic_flag = false;
76 _sourcefile = NULL; 76 _sourcefile = NULL;
77 _generic_signature = NULL; 77 _generic_signature = NULL;
78 _sde_buffer = NULL; 78 _sde_buffer = NULL;
138 // Accessors 138 // Accessors
139 ClassFileStream* stream() { return _stream; } 139 ClassFileStream* stream() { return _stream; }
140 void set_stream(ClassFileStream* st) { _stream = st; } 140 void set_stream(ClassFileStream* st) { _stream = st; }
141 141
142 // Constant pool parsing 142 // Constant pool parsing
143 void parse_constant_pool_entries(Handle class_loader, 143 void parse_constant_pool_entries(ClassLoaderData* loader_data,
144 constantPoolHandle cp, int length, TRAPS); 144 constantPoolHandle cp, int length, TRAPS);
145 145
146 constantPoolHandle parse_constant_pool(Handle class_loader, TRAPS); 146 constantPoolHandle parse_constant_pool(ClassLoaderData* loader_data, TRAPS);
147 147
148 // Interface parsing 148 // Interface parsing
149 objArrayHandle parse_interfaces(constantPoolHandle cp, 149 Array<Klass*>* parse_interfaces(constantPoolHandle cp,
150 int length, 150 int length,
151 Handle class_loader, 151 ClassLoaderData* loader_data,
152 Handle protection_domain, 152 Handle protection_domain,
153 Symbol* class_name, 153 Symbol* class_name,
154 TRAPS); 154 TRAPS);
155 void record_defined_class_dependencies(instanceKlassHandle defined_klass, TRAPS);
155 156
156 // Field parsing 157 // Field parsing
157 void parse_field_attributes(constantPoolHandle cp, u2 attributes_count, 158 void parse_field_attributes(ClassLoaderData* loader_data,
159 constantPoolHandle cp, u2 attributes_count,
158 bool is_static, u2 signature_index, 160 bool is_static, u2 signature_index,
159 u2* constantvalue_index_addr, 161 u2* constantvalue_index_addr,
160 bool* is_synthetic_addr, 162 bool* is_synthetic_addr,
161 u2* generic_signature_index_addr, 163 u2* generic_signature_index_addr,
162 typeArrayHandle* field_annotations, 164 AnnotationArray** field_annotations,
163 FieldAnnotationCollector* parsed_annotations, 165 FieldAnnotationCollector* parsed_annotations,
164 TRAPS); 166 TRAPS);
165 typeArrayHandle parse_fields(Symbol* class_name, 167 Array<u2>* parse_fields(ClassLoaderData* loader_data,
168 Symbol* class_name,
166 constantPoolHandle cp, bool is_interface, 169 constantPoolHandle cp, bool is_interface,
167 FieldAllocationCount *fac, 170 FieldAllocationCount *fac,
168 objArrayHandle* fields_annotations, 171 Array<AnnotationArray*>** fields_annotations,
169 u2* java_fields_count_ptr, TRAPS); 172 u2* java_fields_count_ptr, TRAPS);
170 173
171 // Method parsing 174 // Method parsing
172 methodHandle parse_method(constantPoolHandle cp, bool is_interface, 175 methodHandle parse_method(ClassLoaderData* loader_data,
176 constantPoolHandle cp,
177 bool is_interface,
173 AccessFlags* promoted_flags, 178 AccessFlags* promoted_flags,
174 typeArrayHandle* method_annotations, 179 AnnotationArray** method_annotations,
175 typeArrayHandle* method_parameter_annotations, 180 AnnotationArray** method_parameter_annotations,
176 typeArrayHandle* method_default_annotations, 181 AnnotationArray** method_default_annotations,
177 TRAPS); 182 TRAPS);
178 objArrayHandle parse_methods (constantPoolHandle cp, bool is_interface, 183 Array<Method*>* parse_methods(ClassLoaderData* loader_data,
184 constantPoolHandle cp,
185 bool is_interface,
179 AccessFlags* promoted_flags, 186 AccessFlags* promoted_flags,
180 bool* has_final_method, 187 bool* has_final_method,
181 objArrayOop* methods_annotations_oop, 188 Array<AnnotationArray*>** methods_annotations,
182 objArrayOop* methods_parameter_annotations_oop, 189 Array<AnnotationArray*>** methods_parameter_annotations,
183 objArrayOop* methods_default_annotations_oop, 190 Array<AnnotationArray*>** methods_default_annotations,
184 TRAPS); 191 TRAPS);
185 typeArrayHandle sort_methods (objArrayHandle methods, 192 Array<int>* sort_methods(ClassLoaderData* loader_data,
186 objArrayHandle methods_annotations, 193 Array<Method*>* methods,
187 objArrayHandle methods_parameter_annotations, 194 Array<AnnotationArray*>* methods_annotations,
188 objArrayHandle methods_default_annotations, 195 Array<AnnotationArray*>* methods_parameter_annotations,
196 Array<AnnotationArray*>* methods_default_annotations,
189 TRAPS); 197 TRAPS);
190 u2* parse_exception_table(u4 code_length, u4 exception_table_length, 198 u2* parse_exception_table(ClassLoaderData* loader_data,
199 u4 code_length, u4 exception_table_length,
191 constantPoolHandle cp, TRAPS); 200 constantPoolHandle cp, TRAPS);
192 void parse_linenumber_table( 201 void parse_linenumber_table(
193 u4 code_attribute_length, u4 code_length, 202 u4 code_attribute_length, u4 code_length,
194 CompressedLineNumberWriteStream** write_stream, TRAPS); 203 CompressedLineNumberWriteStream** write_stream, TRAPS);
195 u2* parse_localvariable_table(u4 code_length, u2 max_locals, u4 code_attribute_length, 204 u2* parse_localvariable_table(u4 code_length, u2 max_locals, u4 code_attribute_length,
197 bool isLVTT, TRAPS); 206 bool isLVTT, TRAPS);
198 u2* parse_checked_exceptions(u2* checked_exceptions_length, u4 method_attribute_length, 207 u2* parse_checked_exceptions(u2* checked_exceptions_length, u4 method_attribute_length,
199 constantPoolHandle cp, TRAPS); 208 constantPoolHandle cp, TRAPS);
200 void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index, 209 void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index,
201 u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS); 210 u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS);
202 typeArrayOop parse_stackmap_table(u4 code_attribute_length, TRAPS); 211 Array<u1>* parse_stackmap_table(ClassLoaderData* loader_data, u4 code_attribute_length, TRAPS);
203 212
204 // Classfile attribute parsing 213 // Classfile attribute parsing
205 void parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS); 214 void parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS);
206 void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp, int length, TRAPS); 215 void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
207 u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start, 216 int length, TRAPS);
217 u2 parse_classfile_inner_classes_attribute(ClassLoaderData* loader_data,
218 u1* inner_classes_attribute_start,
208 bool parsed_enclosingmethod_attribute, 219 bool parsed_enclosingmethod_attribute,
209 u2 enclosing_method_class_index, 220 u2 enclosing_method_class_index,
210 u2 enclosing_method_method_index, 221 u2 enclosing_method_method_index,
211 constantPoolHandle cp, 222 constantPoolHandle cp,
212 TRAPS); 223 TRAPS);
213 void parse_classfile_attributes(constantPoolHandle cp, 224 void parse_classfile_attributes(ClassLoaderData* loader_data,
225 constantPoolHandle cp,
214 ClassAnnotationCollector* parsed_annotations, 226 ClassAnnotationCollector* parsed_annotations,
215 TRAPS); 227 TRAPS);
216 void parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS); 228 void parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS);
217 void parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS); 229 void parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS);
218 void parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, u4 attribute_length, TRAPS); 230 void parse_classfile_bootstrap_methods_attribute(ClassLoaderData* loader_data, constantPoolHandle cp, u4 attribute_length, TRAPS);
219 231
220 // Annotations handling 232 // Annotations handling
221 typeArrayHandle assemble_annotations(u1* runtime_visible_annotations, 233 AnnotationArray* assemble_annotations(ClassLoaderData* loader_data,
234 u1* runtime_visible_annotations,
222 int runtime_visible_annotations_length, 235 int runtime_visible_annotations_length,
223 u1* runtime_invisible_annotations, 236 u1* runtime_invisible_annotations,
224 int runtime_invisible_annotations_length, TRAPS); 237 int runtime_invisible_annotations_length, TRAPS);
225 int skip_annotation(u1* buffer, int limit, int index); 238 int skip_annotation(u1* buffer, int limit, int index);
226 int skip_annotation_value(u1* buffer, int limit, int index); 239 int skip_annotation_value(u1* buffer, int limit, int index);
236 void fill_oop_maps(instanceKlassHandle k, 249 void fill_oop_maps(instanceKlassHandle k,
237 unsigned int nonstatic_oop_map_count, 250 unsigned int nonstatic_oop_map_count,
238 int* nonstatic_oop_offsets, 251 int* nonstatic_oop_offsets,
239 unsigned int* nonstatic_oop_counts); 252 unsigned int* nonstatic_oop_counts);
240 void set_precomputed_flags(instanceKlassHandle k); 253 void set_precomputed_flags(instanceKlassHandle k);
241 objArrayHandle compute_transitive_interfaces(instanceKlassHandle super, 254 Array<Klass*>* compute_transitive_interfaces(ClassLoaderData* loader_data,
242 objArrayHandle local_ifs, TRAPS); 255 instanceKlassHandle super,
256 Array<Klass*>* local_ifs, TRAPS);
243 257
244 // Format checker methods 258 // Format checker methods
245 void classfile_parse_error(const char* msg, TRAPS); 259 void classfile_parse_error(const char* msg, TRAPS);
246 void classfile_parse_error(const char* msg, int index, TRAPS); 260 void classfile_parse_error(const char* msg, int index, TRAPS);
247 void classfile_parse_error(const char* msg, const char *name, TRAPS); 261 void classfile_parse_error(const char* msg, const char *name, TRAPS);
324 return patch; 338 return patch;
325 } 339 }
326 void patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS); 340 void patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS);
327 341
328 // Wrapper for constantTag.is_klass_[or_]reference. 342 // Wrapper for constantTag.is_klass_[or_]reference.
329 // In older versions of the VM, klassOops cannot sneak into early phases of 343 // In older versions of the VM, Klass*s cannot sneak into early phases of
330 // constant pool construction, but in later versions they can. 344 // constant pool construction, but in later versions they can.
331 // %%% Let's phase out the old is_klass_reference. 345 // %%% Let's phase out the old is_klass_reference.
332 bool is_klass_reference(constantPoolHandle cp, int index) { 346 bool is_klass_reference(constantPoolHandle cp, int index) {
333 return ((LinkWellKnownClasses || EnableInvokeDynamic) 347 return ((LinkWellKnownClasses || EnableInvokeDynamic)
334 ? cp->tag_at(index).is_klass_or_reference() 348 ? cp->tag_at(index).is_klass_or_reference()
337 351
338 public: 352 public:
339 // Constructor 353 // Constructor
340 ClassFileParser(ClassFileStream* st) { set_stream(st); } 354 ClassFileParser(ClassFileStream* st) { set_stream(st); }
341 355
342 // Parse .class file and return new klassOop. The klassOop is not hooked up 356 // Parse .class file and return new Klass*. The Klass* is not hooked up
343 // to the system dictionary or any other structures, so a .class file can 357 // to the system dictionary or any other structures, so a .class file can
344 // be loaded several times if desired. 358 // be loaded several times if desired.
345 // The system dictionary hookup is done by the caller. 359 // The system dictionary hookup is done by the caller.
346 // 360 //
347 // "parsed_name" is updated by this method, and is the name found 361 // "parsed_name" is updated by this method, and is the name found