comparison src/share/vm/classfile/javaClasses.hpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents 957c266d8bc5 da91efe96a93
children 2cb439954abf
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
57 static int count_offset; 57 static int count_offset;
58 static int hash_offset; 58 static int hash_offset;
59 59
60 static bool initialized; 60 static bool initialized;
61 61
62 static Handle basic_create(int length, bool tenured, TRAPS); 62 static Handle basic_create(int length, TRAPS);
63 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS);
64 63
65 static void set_value( oop string, typeArrayOop buffer) { 64 static void set_value( oop string, typeArrayOop buffer) {
66 assert(initialized, "Must be initialized"); 65 assert(initialized, "Must be initialized");
67 string->obj_field_put(value_offset, (oop)buffer); 66 string->obj_field_put(value_offset, (oop)buffer);
68 } 67 }
82 public: 81 public:
83 static void compute_offsets(); 82 static void compute_offsets();
84 83
85 // Instance creation 84 // Instance creation
86 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); 85 static Handle create_from_unicode(jchar* unicode, int len, TRAPS);
87 static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS);
88 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); 86 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS);
89 static Handle create_from_str(const char* utf8_str, TRAPS); 87 static Handle create_from_str(const char* utf8_str, TRAPS);
90 static oop create_oop_from_str(const char* utf8_str, TRAPS); 88 static oop create_oop_from_str(const char* utf8_str, TRAPS);
91 static Handle create_from_symbol(Symbol* symbol, TRAPS); 89 static Handle create_from_symbol(Symbol* symbol, TRAPS);
92 static Handle create_from_platform_dependent_str(const char* str, TRAPS); 90 static Handle create_from_platform_dependent_str(const char* str, TRAPS);
203 201
204 202
205 // Interface to java.lang.Class objects 203 // Interface to java.lang.Class objects
206 204
207 #define CLASS_INJECTED_FIELDS(macro) \ 205 #define CLASS_INJECTED_FIELDS(macro) \
208 macro(java_lang_Class, klass, object_signature, false) \ 206 macro(java_lang_Class, klass, intptr_signature, false) \
209 macro(java_lang_Class, resolved_constructor, object_signature, false) \ 207 GRAAL_ONLY(macro(java_lang_Class, graal_mirror, object_signature, false))\
210 macro(java_lang_Class, array_klass, object_signature, false) \ 208 macro(java_lang_Class, resolved_constructor, intptr_signature, false) \
209 macro(java_lang_Class, array_klass, intptr_signature, false) \
211 macro(java_lang_Class, oop_size, int_signature, false) \ 210 macro(java_lang_Class, oop_size, int_signature, false) \
212 macro(java_lang_Class, static_oop_field_count, int_signature, false) 211 macro(java_lang_Class, static_oop_field_count, int_signature, false)
213 212
214 class java_lang_Class : AllStatic { 213 class java_lang_Class : AllStatic {
215 friend class VMStructs; 214 friend class VMStructs;
221 static int _resolved_constructor_offset; 220 static int _resolved_constructor_offset;
222 static int _array_klass_offset; 221 static int _array_klass_offset;
223 222
224 static int _oop_size_offset; 223 static int _oop_size_offset;
225 static int _static_oop_field_count_offset; 224 static int _static_oop_field_count_offset;
225 #ifdef GRAAL
226 static int _graal_mirror_offset;
227 #endif
226 228
227 static bool offsets_computed; 229 static bool offsets_computed;
228 static int classRedefinedCount_offset; 230 static int classRedefinedCount_offset;
231 static GrowableArray<Klass*>* _fixup_mirror_list;
229 232
230 public: 233 public:
231 static void compute_offsets(); 234 static void compute_offsets();
232 235
233 // Instance creation 236 // Instance creation
234 static oop create_mirror(KlassHandle k, TRAPS); 237 static oop create_mirror(KlassHandle k, TRAPS);
235 static void fixup_mirror(KlassHandle k, TRAPS); 238 static void fixup_mirror(KlassHandle k, TRAPS);
236 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); 239 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
237 // Conversion 240 // Conversion
238 static klassOop as_klassOop(oop java_class); 241 static Klass* as_Klass(oop java_class);
239 static void set_klass(oop java_class, klassOop klass); 242 static void set_klass(oop java_class, Klass* klass);
240 static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL); 243 static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
241 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { 244 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) {
242 klassOop refk_oop = NULL; 245 Klass* refk_oop = NULL;
243 BasicType result = as_BasicType(java_class, &refk_oop); 246 BasicType result = as_BasicType(java_class, &refk_oop);
244 (*reference_klass) = KlassHandle(refk_oop); 247 (*reference_klass) = KlassHandle(refk_oop);
245 return result; 248 return result;
246 } 249 }
247 static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS); 250 static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
252 } 255 }
253 static bool is_primitive(oop java_class); 256 static bool is_primitive(oop java_class);
254 static BasicType primitive_type(oop java_class); 257 static BasicType primitive_type(oop java_class);
255 static oop primitive_mirror(BasicType t); 258 static oop primitive_mirror(BasicType t);
256 // JVM_NewInstance support 259 // JVM_NewInstance support
257 static methodOop resolved_constructor(oop java_class); 260 static Method* resolved_constructor(oop java_class);
258 static void set_resolved_constructor(oop java_class, methodOop constructor); 261 static void set_resolved_constructor(oop java_class, Method* constructor);
259 // JVM_NewArray support 262 // JVM_NewArray support
260 static klassOop array_klass(oop java_class); 263 static Klass* array_klass(oop java_class);
261 static void set_array_klass(oop java_class, klassOop klass); 264 static void set_array_klass(oop java_class, Klass* klass);
262 // compiler support for class operations 265 // compiler support for class operations
263 static int klass_offset_in_bytes() { return _klass_offset; } 266 static int klass_offset_in_bytes() { return _klass_offset; }
264 static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; } 267 static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; }
265 static int array_klass_offset_in_bytes() { return _array_klass_offset; } 268 static int array_klass_offset_in_bytes() { return _array_klass_offset; }
266 // Support for classRedefinedCount field 269 // Support for classRedefinedCount field
270 static int oop_size(oop java_class); 273 static int oop_size(oop java_class);
271 static void set_oop_size(oop java_class, int size); 274 static void set_oop_size(oop java_class, int size);
272 static int static_oop_field_count(oop java_class); 275 static int static_oop_field_count(oop java_class);
273 static void set_static_oop_field_count(oop java_class, int size); 276 static void set_static_oop_field_count(oop java_class, int size);
274 277
275 // Debugging 278 #ifdef GRAAL
276 friend class JavaClasses; 279 static oop graal_mirror(oop java_class);
277 friend class instanceKlass; // verification code accesses offsets 280 static int graal_mirror_offset_in_bytes() { return _graal_mirror_offset; }
281 #endif
282
283 static GrowableArray<Klass*>* fixup_mirror_list() {
284 return _fixup_mirror_list;
285 }
286 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
287 _fixup_mirror_list = v;
288 }
289 // Debugging
290 friend class JavaClasses;
291 friend class InstanceKlass; // verification code accesses offsets
278 friend class ClassFileParser; // access to number_of_fake_fields 292 friend class ClassFileParser; // access to number_of_fake_fields
279 }; 293 };
280 294
281 // Interface to java.lang.Thread objects 295 // Interface to java.lang.Thread objects
282 296
448 }; 462 };
449 // Trace constants 463 // Trace constants
450 enum { 464 enum {
451 trace_methods_offset = 0, 465 trace_methods_offset = 0,
452 trace_bcis_offset = 1, 466 trace_bcis_offset = 1,
453 trace_next_offset = 2, 467 trace_mirrors_offset = 2,
454 trace_size = 3, 468 trace_next_offset = 3,
469 trace_size = 4,
455 trace_chunk_size = 32 470 trace_chunk_size = 32
456 }; 471 };
457 472
458 static int backtrace_offset; 473 static int backtrace_offset;
459 static int detailMessage_offset; 474 static int detailMessage_offset;
460 static int cause_offset; 475 static int cause_offset;
461 static int stackTrace_offset; 476 static int stackTrace_offset;
462 static int static_unassigned_stacktrace_offset; 477 static int static_unassigned_stacktrace_offset;
463 478
464 // Printing 479 // Printing
465 static char* print_stack_element_to_buffer(methodOop method, int bci); 480 static char* print_stack_element_to_buffer(Method* method, int bci);
466 static void print_to_stream(Handle stream, const char* str); 481 static void print_to_stream(Handle stream, const char* str);
467 // StackTrace (programmatic access, new since 1.4) 482 // StackTrace (programmatic access, new since 1.4)
468 static void clear_stacktrace(oop throwable); 483 static void clear_stacktrace(oop throwable);
469 // No stack trace available 484 // No stack trace available
470 static const char* no_stack_trace_message(); 485 static const char* no_stack_trace_message();
485 static void set_message(oop throwable, oop value); 500 static void set_message(oop throwable, oop value);
486 // Print stack trace stored in exception by call-back to Java 501 // Print stack trace stored in exception by call-back to Java
487 // Note: this is no longer used in Merlin, but we still suppport 502 // Note: this is no longer used in Merlin, but we still suppport
488 // it for compatibility. 503 // it for compatibility.
489 static void print_stack_trace(oop throwable, oop print_stream); 504 static void print_stack_trace(oop throwable, oop print_stream);
490 static void print_stack_element(Handle stream, methodOop method, int bci); 505 static void print_stack_element(Handle stream, Method* method, int bci);
491 static void print_stack_element(outputStream *st, methodOop method, int bci); 506 static void print_stack_element(outputStream *st, Method* method, int bci);
492 static void print_stack_usage(Handle stream); 507 static void print_stack_usage(Handle stream);
493 508
494 // Allocate space for backtrace (created but stack trace not filled in) 509 // Allocate space for backtrace (created but stack trace not filled in)
495 static void allocate_backtrace(Handle throwable, TRAPS); 510 static void allocate_backtrace(Handle throwable, TRAPS);
496 // Fill in current stack trace for throwable with preallocated backtrace (no GC) 511 // Fill in current stack trace for throwable with preallocated backtrace (no GC)
710 // Interface to sun.reflect.ConstantPool objects 725 // Interface to sun.reflect.ConstantPool objects
711 class sun_reflect_ConstantPool { 726 class sun_reflect_ConstantPool {
712 private: 727 private:
713 // Note that to reduce dependencies on the JDK we compute these 728 // Note that to reduce dependencies on the JDK we compute these
714 // offsets at run-time. 729 // offsets at run-time.
715 static int _cp_oop_offset; 730 static int _oop_offset;
716 731
717 static void compute_offsets(); 732 static void compute_offsets();
718 733
719 public: 734 public:
720 // Allocation 735 // Allocation
721 static Handle create(TRAPS); 736 static Handle create(TRAPS);
722 737
723 // Accessors 738 // Accessors
724 static oop cp_oop(oop reflect); 739 static void set_cp(oop reflect, ConstantPool* value);
725 static void set_cp_oop(oop reflect, oop value); 740 static int oop_offset() {
726 static int cp_oop_offset() { 741 return _oop_offset;
727 return _cp_oop_offset; 742 }
728 } 743
744 static ConstantPool* get_cp(oop reflect);
729 745
730 // Debugging 746 // Debugging
731 friend class JavaClasses; 747 friend class JavaClasses;
732 }; 748 };
733 749
852 } 868 }
853 // Accessors for statics 869 // Accessors for statics
854 static oop pending_list_lock(); 870 static oop pending_list_lock();
855 static oop pending_list(); 871 static oop pending_list();
856 872
873 static HeapWord* pending_list_lock_addr();
857 static HeapWord* pending_list_addr(); 874 static HeapWord* pending_list_addr();
858 }; 875 };
859 876
860 877
861 // Interface to java.lang.ref.SoftReference objects 878 // Interface to java.lang.ref.SoftReference objects
902 919
903 static oop form(oop mh); 920 static oop form(oop mh);
904 static void set_form(oop mh, oop lform); 921 static void set_form(oop mh, oop lform);
905 922
906 // Testers 923 // Testers
907 static bool is_subclass(klassOop klass) { 924 static bool is_subclass(Klass* klass) {
908 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); 925 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass());
909 } 926 }
910 static bool is_instance(oop obj) { 927 static bool is_instance(oop obj) {
911 return obj != NULL && is_subclass(obj->klass()); 928 return obj != NULL && is_subclass(obj->klass());
912 } 929 }
931 // Accessors 948 // Accessors
932 static oop vmentry(oop lform); 949 static oop vmentry(oop lform);
933 static void set_vmentry(oop lform, oop invoker); 950 static void set_vmentry(oop lform, oop invoker);
934 951
935 // Testers 952 // Testers
936 static bool is_subclass(klassOop klass) { 953 static bool is_subclass(Klass* klass) {
937 return SystemDictionary::LambdaForm_klass() != NULL && 954 return SystemDictionary::LambdaForm_klass() != NULL &&
938 Klass::cast(klass)->is_subclass_of(SystemDictionary::LambdaForm_klass()); 955 Klass::cast(klass)->is_subclass_of(SystemDictionary::LambdaForm_klass());
939 } 956 }
940 static bool is_instance(oop obj) { 957 static bool is_instance(oop obj) {
941 return obj != NULL && is_subclass(obj->klass()); 958 return obj != NULL && is_subclass(obj->klass());
948 965
949 // Interface to java.lang.invoke.MemberName objects 966 // Interface to java.lang.invoke.MemberName objects
950 // (These are a private interface for Java code to query the class hierarchy.) 967 // (These are a private interface for Java code to query the class hierarchy.)
951 968
952 #define MEMBERNAME_INJECTED_FIELDS(macro) \ 969 #define MEMBERNAME_INJECTED_FIELDS(macro) \
970 macro(java_lang_invoke_MemberName, vmloader, object_signature, false) \
953 macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false) \ 971 macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false) \
954 macro(java_lang_invoke_MemberName, vmtarget, object_signature, false) 972 macro(java_lang_invoke_MemberName, vmtarget, intptr_signature, false)
955 973
956 class java_lang_invoke_MemberName: AllStatic { 974 class java_lang_invoke_MemberName: AllStatic {
957 friend class JavaClasses; 975 friend class JavaClasses;
958 976
959 private: 977 private:
960 // From java.lang.invoke.MemberName: 978 // From java.lang.invoke.MemberName:
961 // private Class<?> clazz; // class in which the method is defined 979 // private Class<?> clazz; // class in which the method is defined
962 // private String name; // may be null if not yet materialized 980 // private String name; // may be null if not yet materialized
963 // private Object type; // may be null if not yet materialized 981 // private Object type; // may be null if not yet materialized
964 // private int flags; // modifier bits; see reflect.Modifier 982 // private int flags; // modifier bits; see reflect.Modifier
965 // private Object vmtarget; // VM-specific target value 983 // private intptr vmtarget; // VM-specific target value
966 // private intptr_t vmindex; // member index within class or interface 984 // private intptr_t vmindex; // member index within class or interface
967 static int _clazz_offset; 985 static int _clazz_offset;
968 static int _name_offset; 986 static int _name_offset;
969 static int _type_offset; 987 static int _type_offset;
970 static int _flags_offset; 988 static int _flags_offset;
971 static int _vmtarget_offset; 989 static int _vmtarget_offset;
990 static int _vmloader_offset;
972 static int _vmindex_offset; 991 static int _vmindex_offset;
973 992
974 static void compute_offsets(); 993 static void compute_offsets();
975 994
976 public: 995 public:
985 static void set_name(oop mname, oop name); 1004 static void set_name(oop mname, oop name);
986 1005
987 static int flags(oop mname); 1006 static int flags(oop mname);
988 static void set_flags(oop mname, int flags); 1007 static void set_flags(oop mname, int flags);
989 1008
990 static oop vmtarget(oop mname); 1009 static Metadata* vmtarget(oop mname);
991 static void set_vmtarget(oop mname, oop target); 1010 static void set_vmtarget(oop mname, Metadata* target);
992 1011
993 static intptr_t vmindex(oop mname); 1012 static intptr_t vmindex(oop mname);
994 static void set_vmindex(oop mname, intptr_t index); 1013 static void set_vmindex(oop mname, intptr_t index);
995 1014
996 // Testers 1015 // Testers
997 static bool is_subclass(klassOop klass) { 1016 static bool is_subclass(Klass* klass) {
998 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); 1017 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass());
999 } 1018 }
1000 static bool is_instance(oop obj) { 1019 static bool is_instance(oop obj) {
1001 return obj != NULL && is_subclass(obj->klass()); 1020 return obj != NULL && is_subclass(obj->klass());
1002 } 1021 }
1078 1097
1079 static volatile oop target_volatile(oop site) { return site->obj_field_volatile( _target_offset); } 1098 static volatile oop target_volatile(oop site) { return site->obj_field_volatile( _target_offset); }
1080 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); } 1099 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); }
1081 1100
1082 // Testers 1101 // Testers
1083 static bool is_subclass(klassOop klass) { 1102 static bool is_subclass(Klass* klass) {
1084 return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass()); 1103 return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass());
1085 } 1104 }
1086 static bool is_instance(oop obj) { 1105 static bool is_instance(oop obj) {
1087 return obj != NULL && is_subclass(obj->klass()); 1106 return obj != NULL && is_subclass(obj->klass());
1088 } 1107 }
1111 }; 1130 };
1112 1131
1113 1132
1114 // Interface to java.lang.ClassLoader objects 1133 // Interface to java.lang.ClassLoader objects
1115 1134
1135 #define CLASSLOADER_INJECTED_FIELDS(macro) \
1136 macro(java_lang_ClassLoader, loader_data, intptr_signature, false) \
1137 macro(java_lang_ClassLoader, dependencies, object_signature, false)
1138
1116 class java_lang_ClassLoader : AllStatic { 1139 class java_lang_ClassLoader : AllStatic {
1117 private: 1140 private:
1141 // The fake offsets are added by the class loader when java.lang.Class is loaded
1118 enum { 1142 enum {
1119 hc_parent_offset = 0 1143 hc_parent_offset = 0
1120 }; 1144 };
1121 1145 static int _loader_data_offset;
1146 static int _dependencies_offset;
1122 static bool offsets_computed; 1147 static bool offsets_computed;
1123 static int parent_offset; 1148 static int parent_offset;
1124 static int parallelCapable_offset; 1149 static int parallelCapable_offset;
1125 1150
1126 static void compute_offsets(); 1151 public:
1127 1152 static void compute_offsets();
1128 public: 1153
1154 static ClassLoaderData** loader_data_addr(oop loader);
1155 static ClassLoaderData* loader_data(oop loader);
1156
1157 static oop dependencies(oop loader);
1158 static HeapWord* dependencies_addr(oop loader);
1159
1129 static oop parent(oop loader); 1160 static oop parent(oop loader);
1130 static bool isAncestor(oop loader, oop cl); 1161 static bool isAncestor(oop loader, oop cl);
1131 1162
1132 // Support for parallelCapable field 1163 // Support for parallelCapable field
1133 static bool parallelCapable(oop the_class_mirror); 1164 static bool parallelCapable(oop the_class_mirror);
1136 1167
1137 // Fix for 4474172 1168 // Fix for 4474172
1138 static oop non_reflection_class_loader(oop loader); 1169 static oop non_reflection_class_loader(oop loader);
1139 1170
1140 // Testers 1171 // Testers
1141 static bool is_subclass(klassOop klass) { 1172 static bool is_subclass(Klass* klass) {
1142 return Klass::cast(klass)->is_subclass_of(SystemDictionary::ClassLoader_klass()); 1173 return Klass::cast(klass)->is_subclass_of(SystemDictionary::ClassLoader_klass());
1143 } 1174 }
1144 static bool is_instance(oop obj) { 1175 static bool is_instance(oop obj) {
1145 return obj != NULL && is_subclass(obj->klass()); 1176 return obj != NULL && is_subclass(obj->klass());
1146 } 1177 }
1147 1178
1148 // Debugging 1179 // Debugging
1149 friend class JavaClasses; 1180 friend class JavaClasses;
1181 friend class ClassFileParser; // access to number_of_fake_fields
1150 }; 1182 };
1151 1183
1152 1184
1153 // Interface to java.lang.System objects 1185 // Interface to java.lang.System objects
1154 1186
1267 const vmSymbols::SID name_index; 1299 const vmSymbols::SID name_index;
1268 const vmSymbols::SID signature_index; 1300 const vmSymbols::SID signature_index;
1269 const bool may_be_java; 1301 const bool may_be_java;
1270 1302
1271 1303
1272 klassOop klass() const { return SystemDictionary::well_known_klass(klass_id); } 1304 Klass* klass() const { return SystemDictionary::well_known_klass(klass_id); }
1273 Symbol* name() const { return lookup_symbol(name_index); } 1305 Symbol* name() const { return lookup_symbol(name_index); }
1274 Symbol* signature() const { return lookup_symbol(signature_index); } 1306 Symbol* signature() const { return lookup_symbol(signature_index); }
1275 1307
1276 int compute_offset(); 1308 int compute_offset();
1277 1309
1284 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ 1316 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
1285 klass##_##name##_enum, 1317 klass##_##name##_enum,
1286 1318
1287 #define ALL_INJECTED_FIELDS(macro) \ 1319 #define ALL_INJECTED_FIELDS(macro) \
1288 CLASS_INJECTED_FIELDS(macro) \ 1320 CLASS_INJECTED_FIELDS(macro) \
1321 CLASSLOADER_INJECTED_FIELDS(macro) \
1289 MEMBERNAME_INJECTED_FIELDS(macro) 1322 MEMBERNAME_INJECTED_FIELDS(macro)
1290 1323
1291 // Interface to hard-coded offset checking 1324 // Interface to hard-coded offset checking
1292 1325
1293 class JavaClasses : AllStatic { 1326 class JavaClasses : AllStatic {