comparison src/share/vm/oops/instanceKlass.hpp @ 3938:e6b1331a51d2

7086585: make Java field injection more flexible Reviewed-by: jrose, twisti, kvn, coleenp
author never
date Sat, 10 Sep 2011 17:29:02 -0700
parents d3b9f2be46ab
children f6f3bb0ee072
comparison
equal deleted inserted replaced
3937:c565834fb592 3938:e6b1331a51d2
25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_HPP 25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_HPP
26 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP 26 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP
27 27
28 #include "oops/constMethodOop.hpp" 28 #include "oops/constMethodOop.hpp"
29 #include "oops/constantPoolOop.hpp" 29 #include "oops/constantPoolOop.hpp"
30 #include "oops/fieldInfo.hpp"
30 #include "oops/instanceOop.hpp" 31 #include "oops/instanceOop.hpp"
31 #include "oops/klassOop.hpp" 32 #include "oops/klassOop.hpp"
32 #include "oops/klassVtable.hpp" 33 #include "oops/klassVtable.hpp"
33 #include "oops/objArrayOop.hpp" 34 #include "oops/objArrayOop.hpp"
34 #include "runtime/handles.hpp" 35 #include "runtime/handles.hpp"
226 // (including inherited fields but after header_size()). 227 // (including inherited fields but after header_size()).
227 int _nonstatic_field_size; 228 int _nonstatic_field_size;
228 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass 229 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
229 int _static_oop_field_count;// number of static oop fields in this klass 230 int _static_oop_field_count;// number of static oop fields in this klass
230 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks 231 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
232 int _java_fields_count; // The number of declared Java fields
231 bool _is_marked_dependent; // used for marking during flushing and deoptimization 233 bool _is_marked_dependent; // used for marking during flushing and deoptimization
232 bool _rewritten; // methods rewritten. 234 bool _rewritten; // methods rewritten.
233 bool _has_nonstatic_fields; // for sizing with UseCompressedOops 235 bool _has_nonstatic_fields; // for sizing with UseCompressedOops
234 bool _should_verify_class; // allow caching of preverification 236 bool _should_verify_class; // allow caching of preverification
235 u2 _minor_version; // minor version number of class file 237 u2 _minor_version; // minor version number of class file
305 objArrayOop local_interfaces() const { return _local_interfaces; } 307 objArrayOop local_interfaces() const { return _local_interfaces; }
306 void set_local_interfaces(objArrayOop a) { oop_store_without_check((oop*) &_local_interfaces, (oop) a); } 308 void set_local_interfaces(objArrayOop a) { oop_store_without_check((oop*) &_local_interfaces, (oop) a); }
307 objArrayOop transitive_interfaces() const { return _transitive_interfaces; } 309 objArrayOop transitive_interfaces() const { return _transitive_interfaces; }
308 void set_transitive_interfaces(objArrayOop a) { oop_store_without_check((oop*) &_transitive_interfaces, (oop) a); } 310 void set_transitive_interfaces(objArrayOop a) { oop_store_without_check((oop*) &_transitive_interfaces, (oop) a); }
309 311
310 // fields 312 private:
311 // Field info extracted from the class file and stored 313 friend class fieldDescriptor;
312 // as an array of 7 shorts 314 FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
313 enum FieldOffset { 315
314 access_flags_offset = 0, 316 public:
315 name_index_offset = 1, 317 int field_offset (int index) const { return field(index)->offset(); }
316 signature_index_offset = 2, 318 int field_access_flags(int index) const { return field(index)->access_flags(); }
317 initval_index_offset = 3, 319 Symbol* field_name (int index) const { return field(index)->name(constants()); }
318 low_offset = 4, 320 Symbol* field_signature (int index) const { return field(index)->signature(constants()); }
319 high_offset = 5, 321
320 generic_signature_offset = 6, 322 // Number of Java declared fields
321 next_offset = 7 323 int java_fields_count() const { return _java_fields_count; }
322 }; 324
325 // Number of fields including any injected fields
326 int all_fields_count() const { return _fields->length() / sizeof(FieldInfo::field_slots); }
323 327
324 typeArrayOop fields() const { return _fields; } 328 typeArrayOop fields() const { return _fields; }
325 int offset_from_fields( int index ) const { 329
326 return build_int_from_shorts( fields()->ushort_at(index + low_offset), 330 void set_fields(typeArrayOop f, int java_fields_count) {
327 fields()->ushort_at(index + high_offset) ); 331 oop_store_without_check((oop*) &_fields, (oop) f);
328 } 332 _java_fields_count = java_fields_count;
329 333 }
330 void set_fields(typeArrayOop f) { oop_store_without_check((oop*) &_fields, (oop) f); }
331 334
332 // inner classes 335 // inner classes
333 typeArrayOop inner_classes() const { return _inner_classes; } 336 typeArrayOop inner_classes() const { return _inner_classes; }
334 void set_inner_classes(typeArrayOop f) { oop_store_without_check((oop*) &_inner_classes, (oop) f); } 337 void set_inner_classes(typeArrayOop f) { oop_store_without_check((oop*) &_inner_classes, (oop) f); }
335 338
840 #endif 843 #endif
841 844
842 // Verification 845 // Verification
843 const char* internal_name() const; 846 const char* internal_name() const;
844 void oop_verify_on(oop obj, outputStream* st); 847 void oop_verify_on(oop obj, outputStream* st);
845
846 #ifndef PRODUCT
847 static void verify_class_klass_nonstatic_oop_maps(klassOop k) PRODUCT_RETURN;
848 #endif
849 }; 848 };
850 849
851 inline methodOop instanceKlass::method_at_vtable(int index) { 850 inline methodOop instanceKlass::method_at_vtable(int index) {
852 #ifndef PRODUCT 851 #ifndef PRODUCT
853 assert(index >= 0, "valid vtable index"); 852 assert(index >= 0, "valid vtable index");