Mercurial > hg > truffle
comparison src/share/vm/classfile/classFileParser.hpp @ 6226:9c9fb30d2b3b
Merge
author | kvn |
---|---|
date | Mon, 16 Jul 2012 19:50:52 -0700 |
parents | 6d8f36bcef55 |
children | dd785aabe02b |
comparison
equal
deleted
inserted
replaced
6212:54e66510c9cd | 6226:9c9fb30d2b3b |
---|---|
29 #include "memory/resourceArea.hpp" | 29 #include "memory/resourceArea.hpp" |
30 #include "oops/oop.inline.hpp" | 30 #include "oops/oop.inline.hpp" |
31 #include "oops/typeArrayOop.hpp" | 31 #include "oops/typeArrayOop.hpp" |
32 #include "runtime/handles.inline.hpp" | 32 #include "runtime/handles.inline.hpp" |
33 #include "utilities/accessFlags.hpp" | 33 #include "utilities/accessFlags.hpp" |
34 | 34 #include "classfile/symbolTable.hpp" |
35 class TempNewSymbol; | 35 |
36 class FieldAllocationCount; | 36 class FieldAllocationCount; |
37 | 37 |
38 | 38 |
39 // Parser for for .class files | 39 // Parser for for .class files |
40 // | 40 // |
48 u2 _minor_version; | 48 u2 _minor_version; |
49 Symbol* _class_name; | 49 Symbol* _class_name; |
50 KlassHandle _host_klass; | 50 KlassHandle _host_klass; |
51 GrowableArray<Handle>* _cp_patches; // overrides for CP entries | 51 GrowableArray<Handle>* _cp_patches; // overrides for CP entries |
52 | 52 |
53 // precomputed flags | |
53 bool _has_finalizer; | 54 bool _has_finalizer; |
54 bool _has_empty_finalizer; | 55 bool _has_empty_finalizer; |
55 bool _has_vanilla_constructor; | 56 bool _has_vanilla_constructor; |
56 | 57 int _max_bootstrap_specifier_index; // detects BSS values |
57 int _max_bootstrap_specifier_index; | 58 |
59 // class attributes parsed before the instance klass is created: | |
60 bool _synthetic_flag; | |
61 Symbol* _sourcefile; | |
62 Symbol* _generic_signature; | |
63 char* _sde_buffer; | |
64 int _sde_length; | |
65 typeArrayHandle _inner_classes; | |
66 typeArrayHandle _annotations; | |
67 | |
68 void set_class_synthetic_flag(bool x) { _synthetic_flag = x; } | |
69 void set_class_sourcefile(Symbol* x) { _sourcefile = 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; } | |
72 void set_class_inner_classes(typeArrayHandle x) { _inner_classes = x; } | |
73 void set_class_annotations(typeArrayHandle x) { _annotations = x; } | |
74 void init_parsed_class_attributes() { | |
75 _synthetic_flag = false; | |
76 _sourcefile = NULL; | |
77 _generic_signature = NULL; | |
78 _sde_buffer = NULL; | |
79 _sde_length = 0; | |
80 // initialize the other flags too: | |
81 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false; | |
82 _max_bootstrap_specifier_index = -1; | |
83 } | |
84 void apply_parsed_class_attributes(instanceKlassHandle k); // update k | |
85 | |
86 class AnnotationCollector { | |
87 public: | |
88 enum Location { _in_field, _in_method, _in_class }; | |
89 enum ID { | |
90 _unknown = 0, | |
91 _method_ForceInline, | |
92 _annotation_LIMIT | |
93 }; | |
94 const Location _location; | |
95 int _annotations_present; | |
96 AnnotationCollector(Location location) | |
97 : _location(location), _annotations_present(0) | |
98 { | |
99 assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, ""); | |
100 } | |
101 // If this annotation name has an ID, report it (or _none). | |
102 ID annotation_index(Symbol* name); | |
103 // Set the annotation name: | |
104 void set_annotation(ID id) { | |
105 assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob"); | |
106 _annotations_present |= nth_bit((int)id); | |
107 } | |
108 // Report if the annotation is present. | |
109 bool has_any_annotations() { return _annotations_present != 0; } | |
110 bool has_annotation(ID id) { return (nth_bit((int)id) & _annotations_present) != 0; } | |
111 }; | |
112 class FieldAnnotationCollector: public AnnotationCollector { | |
113 public: | |
114 FieldAnnotationCollector() : AnnotationCollector(_in_field) { } | |
115 void apply_to(FieldInfo* f); | |
116 }; | |
117 class MethodAnnotationCollector: public AnnotationCollector { | |
118 public: | |
119 MethodAnnotationCollector() : AnnotationCollector(_in_method) { } | |
120 void apply_to(methodHandle m); | |
121 }; | |
122 class ClassAnnotationCollector: public AnnotationCollector { | |
123 public: | |
124 ClassAnnotationCollector() : AnnotationCollector(_in_class) { } | |
125 void apply_to(instanceKlassHandle k); | |
126 }; | |
58 | 127 |
59 enum { fixed_buffer_size = 128 }; | 128 enum { fixed_buffer_size = 128 }; |
60 u_char linenumbertable_buffer[fixed_buffer_size]; | 129 u_char linenumbertable_buffer[fixed_buffer_size]; |
61 | 130 |
62 ClassFileStream* _stream; // Actual input stream | 131 ClassFileStream* _stream; // Actual input stream |
85 void parse_field_attributes(constantPoolHandle cp, u2 attributes_count, | 154 void parse_field_attributes(constantPoolHandle cp, u2 attributes_count, |
86 bool is_static, u2 signature_index, | 155 bool is_static, u2 signature_index, |
87 u2* constantvalue_index_addr, | 156 u2* constantvalue_index_addr, |
88 bool* is_synthetic_addr, | 157 bool* is_synthetic_addr, |
89 u2* generic_signature_index_addr, | 158 u2* generic_signature_index_addr, |
90 typeArrayHandle* field_annotations, TRAPS); | 159 typeArrayHandle* field_annotations, |
160 FieldAnnotationCollector* parsed_annotations, | |
161 TRAPS); | |
91 typeArrayHandle parse_fields(Symbol* class_name, | 162 typeArrayHandle parse_fields(Symbol* class_name, |
92 constantPoolHandle cp, bool is_interface, | 163 constantPoolHandle cp, bool is_interface, |
93 FieldAllocationCount *fac, | 164 FieldAllocationCount *fac, |
94 objArrayHandle* fields_annotations, | 165 objArrayHandle* fields_annotations, |
95 u2* java_fields_count_ptr, TRAPS); | 166 u2* java_fields_count_ptr, TRAPS); |
126 void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index, | 197 void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index, |
127 u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS); | 198 u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS); |
128 typeArrayOop parse_stackmap_table(u4 code_attribute_length, TRAPS); | 199 typeArrayOop parse_stackmap_table(u4 code_attribute_length, TRAPS); |
129 | 200 |
130 // Classfile attribute parsing | 201 // Classfile attribute parsing |
131 void parse_classfile_sourcefile_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS); | 202 void parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS); |
132 void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp, | 203 void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp, int length, TRAPS); |
133 instanceKlassHandle k, int length, TRAPS); | |
134 u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start, | 204 u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start, |
135 bool parsed_enclosingmethod_attribute, | 205 bool parsed_enclosingmethod_attribute, |
136 u2 enclosing_method_class_index, | 206 u2 enclosing_method_class_index, |
137 u2 enclosing_method_method_index, | 207 u2 enclosing_method_method_index, |
138 constantPoolHandle cp, | 208 constantPoolHandle cp, |
139 instanceKlassHandle k, TRAPS); | 209 TRAPS); |
140 void parse_classfile_attributes(constantPoolHandle cp, instanceKlassHandle k, TRAPS); | 210 void parse_classfile_attributes(constantPoolHandle cp, |
141 void parse_classfile_synthetic_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS); | 211 ClassAnnotationCollector* parsed_annotations, |
142 void parse_classfile_signature_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS); | 212 TRAPS); |
143 void parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, instanceKlassHandle k, u4 attribute_length, TRAPS); | 213 void parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS); |
214 void parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS); | |
215 void parse_classfile_bootstrap_methods_attribute(constantPoolHandle cp, u4 attribute_length, TRAPS); | |
144 | 216 |
145 // Annotations handling | 217 // Annotations handling |
146 typeArrayHandle assemble_annotations(u1* runtime_visible_annotations, | 218 typeArrayHandle assemble_annotations(u1* runtime_visible_annotations, |
147 int runtime_visible_annotations_length, | 219 int runtime_visible_annotations_length, |
148 u1* runtime_invisible_annotations, | 220 u1* runtime_invisible_annotations, |
149 int runtime_invisible_annotations_length, TRAPS); | 221 int runtime_invisible_annotations_length, TRAPS); |
222 int skip_annotation(u1* buffer, int limit, int index); | |
223 int skip_annotation_value(u1* buffer, int limit, int index); | |
224 void parse_annotations(u1* buffer, int limit, constantPoolHandle cp, | |
225 /* Results (currently, only one result is supported): */ | |
226 AnnotationCollector* result, | |
227 TRAPS); | |
150 | 228 |
151 // Final setup | 229 // Final setup |
152 unsigned int compute_oop_map_count(instanceKlassHandle super, | 230 unsigned int compute_oop_map_count(instanceKlassHandle super, |
153 unsigned int nonstatic_oop_count, | 231 unsigned int nonstatic_oop_count, |
154 int first_nonstatic_oop_offset); | 232 int first_nonstatic_oop_offset); |