154 }; |
154 }; |
155 |
155 |
156 |
156 |
157 // Interface to java.lang.Class objects |
157 // Interface to java.lang.Class objects |
158 |
158 |
|
159 #define CLASS_INJECTED_FIELDS(macro) \ |
|
160 macro(java_lang_Class, klass, object_signature, false) \ |
|
161 macro(java_lang_Class, resolved_constructor, object_signature, false) \ |
|
162 macro(java_lang_Class, array_klass, object_signature, false) \ |
|
163 macro(java_lang_Class, oop_size, int_signature, false) \ |
|
164 macro(java_lang_Class, static_oop_field_count, int_signature, false) |
|
165 |
159 class java_lang_Class : AllStatic { |
166 class java_lang_Class : AllStatic { |
160 friend class VMStructs; |
167 friend class VMStructs; |
|
168 |
161 private: |
169 private: |
162 // The fake offsets are added by the class loader when java.lang.Class is loaded |
170 // The fake offsets are added by the class loader when java.lang.Class is loaded |
163 |
171 |
164 enum { |
172 static int _klass_offset; |
165 hc_number_of_fake_oop_fields = 3, |
173 static int _resolved_constructor_offset; |
166 hc_number_of_fake_int_fields = 2 |
174 static int _array_klass_offset; |
167 }; |
175 |
168 |
176 static int _oop_size_offset; |
169 static int klass_offset; |
177 static int _static_oop_field_count_offset; |
170 static int resolved_constructor_offset; |
178 |
171 static int array_klass_offset; |
|
172 static int number_of_fake_oop_fields; |
|
173 |
|
174 static int oop_size_offset; |
|
175 static int static_oop_field_count_offset; |
|
176 |
|
177 static void compute_offsets(); |
|
178 static bool offsets_computed; |
179 static bool offsets_computed; |
179 static int classRedefinedCount_offset; |
180 static int classRedefinedCount_offset; |
180 static int parallelCapable_offset; |
181 |
181 |
182 public: |
182 public: |
183 static void compute_offsets(); |
|
184 |
183 // Instance creation |
185 // Instance creation |
184 static oop create_mirror(KlassHandle k, TRAPS); |
186 static oop create_mirror(KlassHandle k, TRAPS); |
185 static void fixup_mirror(KlassHandle k, TRAPS); |
187 static void fixup_mirror(KlassHandle k, TRAPS); |
186 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); |
188 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); |
187 // Conversion |
189 // Conversion |
207 static void set_resolved_constructor(oop java_class, methodOop constructor); |
209 static void set_resolved_constructor(oop java_class, methodOop constructor); |
208 // JVM_NewArray support |
210 // JVM_NewArray support |
209 static klassOop array_klass(oop java_class); |
211 static klassOop array_klass(oop java_class); |
210 static void set_array_klass(oop java_class, klassOop klass); |
212 static void set_array_klass(oop java_class, klassOop klass); |
211 // compiler support for class operations |
213 // compiler support for class operations |
212 static int klass_offset_in_bytes() { return klass_offset; } |
214 static int klass_offset_in_bytes() { return _klass_offset; } |
213 static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; } |
215 static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; } |
214 static int array_klass_offset_in_bytes() { return array_klass_offset; } |
216 static int array_klass_offset_in_bytes() { return _array_klass_offset; } |
215 // Support for classRedefinedCount field |
217 // Support for classRedefinedCount field |
216 static int classRedefinedCount(oop the_class_mirror); |
218 static int classRedefinedCount(oop the_class_mirror); |
217 static void set_classRedefinedCount(oop the_class_mirror, int value); |
219 static void set_classRedefinedCount(oop the_class_mirror, int value); |
218 // Support for parallelCapable field |
|
219 static bool parallelCapable(oop the_class_mirror); |
|
220 |
220 |
221 static int oop_size(oop java_class); |
221 static int oop_size(oop java_class); |
222 static void set_oop_size(oop java_class, int size); |
222 static void set_oop_size(oop java_class, int size); |
223 static int static_oop_field_count(oop java_class); |
223 static int static_oop_field_count(oop java_class); |
224 static void set_static_oop_field_count(oop java_class, int size); |
224 static void set_static_oop_field_count(oop java_class, int size); |
832 }; |
832 }; |
833 |
833 |
834 |
834 |
835 // Interface to java.lang.invoke.MethodHandle objects |
835 // Interface to java.lang.invoke.MethodHandle objects |
836 |
836 |
|
837 #define METHODHANDLE_INJECTED_FIELDS(macro) \ |
|
838 macro(java_lang_invoke_MethodHandle, vmentry, intptr_signature, false) \ |
|
839 macro(java_lang_invoke_MethodHandle, vmtarget, object_signature, true) |
|
840 |
837 class MethodHandleEntry; |
841 class MethodHandleEntry; |
838 |
842 |
839 class java_lang_invoke_MethodHandle: AllStatic { |
843 class java_lang_invoke_MethodHandle: AllStatic { |
840 friend class JavaClasses; |
844 friend class JavaClasses; |
841 |
845 |
842 private: |
846 private: |
843 static int _vmentry_offset; // assembly code trampoline for MH |
847 static int _vmentry_offset; // assembly code trampoline for MH |
844 static int _vmtarget_offset; // class-specific target reference |
848 static int _vmtarget_offset; // class-specific target reference |
845 static int _type_offset; // the MethodType of this MH |
849 static int _type_offset; // the MethodType of this MH |
846 static int _vmslots_offset; // OPTIONAL hoisted type.form.vmslots |
|
847 |
850 |
848 static void compute_offsets(); |
851 static void compute_offsets(); |
849 |
852 |
850 public: |
853 public: |
851 // Accessors |
854 // Accessors |
872 |
873 |
873 // Accessors for code generation: |
874 // Accessors for code generation: |
874 static int type_offset_in_bytes() { return _type_offset; } |
875 static int type_offset_in_bytes() { return _type_offset; } |
875 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } |
876 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } |
876 static int vmentry_offset_in_bytes() { return _vmentry_offset; } |
877 static int vmentry_offset_in_bytes() { return _vmentry_offset; } |
877 static int vmslots_offset_in_bytes() { return _vmslots_offset; } |
878 }; |
878 }; |
879 |
|
880 #define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \ |
|
881 macro(java_lang_invoke_DirectMethodHandle, vmindex, int_signature, true) |
879 |
882 |
880 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle { |
883 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle { |
881 friend class JavaClasses; |
884 friend class JavaClasses; |
882 |
885 |
883 private: |
886 private: |
884 // _vmtarget_offset; // method or class or interface |
|
885 static int _vmindex_offset; // negative or vtable idx or itable idx |
887 static int _vmindex_offset; // negative or vtable idx or itable idx |
886 static void compute_offsets(); |
888 static void compute_offsets(); |
887 |
889 |
888 public: |
890 public: |
889 // Accessors |
891 // Accessors |
1119 static int rtype_offset_in_bytes() { return _rtype_offset; } |
1124 static int rtype_offset_in_bytes() { return _rtype_offset; } |
1120 static int ptypes_offset_in_bytes() { return _ptypes_offset; } |
1125 static int ptypes_offset_in_bytes() { return _ptypes_offset; } |
1121 static int form_offset_in_bytes() { return _form_offset; } |
1126 static int form_offset_in_bytes() { return _form_offset; } |
1122 }; |
1127 }; |
1123 |
1128 |
|
1129 #define METHODTYPEFORM_INJECTED_FIELDS(macro) \ |
|
1130 macro(java_lang_invoke_MethodTypeForm, vmslots, int_signature, true) \ |
|
1131 macro(java_lang_invoke_MethodTypeForm, vmlayout, object_signature, true) |
|
1132 |
1124 class java_lang_invoke_MethodTypeForm: AllStatic { |
1133 class java_lang_invoke_MethodTypeForm: AllStatic { |
1125 friend class JavaClasses; |
1134 friend class JavaClasses; |
1126 |
1135 |
1127 private: |
1136 private: |
1128 static int _vmslots_offset; // number of argument slots needed |
1137 static int _vmslots_offset; // number of argument slots needed |
1167 static void set_target( oop site, oop target) { site->obj_field_put( _target_offset, target); } |
1176 static void set_target( oop site, oop target) { site->obj_field_put( _target_offset, target); } |
1168 |
1177 |
1169 static volatile oop target_volatile(oop site) { return site->obj_field_volatile( _target_offset); } |
1178 static volatile oop target_volatile(oop site) { return site->obj_field_volatile( _target_offset); } |
1170 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); } |
1179 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); } |
1171 |
1180 |
1172 static oop caller_method(oop site); |
|
1173 static void set_caller_method(oop site, oop ref); |
|
1174 |
|
1175 static jint caller_bci(oop site); |
|
1176 static void set_caller_bci(oop site, jint bci); |
|
1177 |
|
1178 // Testers |
1181 // Testers |
1179 static bool is_subclass(klassOop klass) { |
1182 static bool is_subclass(klassOop klass) { |
1180 return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass()); |
1183 return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass()); |
1181 } |
1184 } |
1182 static bool is_instance(oop obj) { |
1185 static bool is_instance(oop obj) { |
1183 return obj != NULL && is_subclass(obj->klass()); |
1186 return obj != NULL && is_subclass(obj->klass()); |
1184 } |
1187 } |
1185 |
1188 |
1186 // Accessors for code generation: |
1189 // Accessors for code generation: |
1187 static int target_offset_in_bytes() { return _target_offset; } |
1190 static int target_offset_in_bytes() { return _target_offset; } |
1188 static int caller_method_offset_in_bytes() { return _caller_method_offset; } |
|
1189 static int caller_bci_offset_in_bytes() { return _caller_bci_offset; } |
|
1190 }; |
1191 }; |
1191 |
1192 |
1192 |
1193 |
1193 // Interface to java.security.AccessControlContext objects |
1194 // Interface to java.security.AccessControlContext objects |
1194 |
1195 |
1341 public: |
1349 public: |
1342 static void initialize(TRAPS); |
1350 static void initialize(TRAPS); |
1343 static oop get_owner_threadObj(oop obj); |
1351 static oop get_owner_threadObj(oop obj); |
1344 }; |
1352 }; |
1345 |
1353 |
|
1354 // Use to declare fields that need to be injected into Java classes |
|
1355 // for the JVM to use. The name_index and signature_index are |
|
1356 // declared in vmSymbols. The may_be_java flag is used to declare |
|
1357 // fields that might already exist in Java but should be injected if |
|
1358 // they don't. Otherwise the field is unconditionally injected and |
|
1359 // the JVM uses the injected one. This is to ensure that name |
|
1360 // collisions don't occur. In general may_be_java should be false |
|
1361 // unless there's a good reason. |
|
1362 |
|
1363 class InjectedField { |
|
1364 public: |
|
1365 const SystemDictionary::WKID klass_id; |
|
1366 const vmSymbols::SID name_index; |
|
1367 const vmSymbols::SID signature_index; |
|
1368 const bool may_be_java; |
|
1369 |
|
1370 |
|
1371 klassOop klass() const { return SystemDictionary::well_known_klass(klass_id); } |
|
1372 Symbol* name() const { return lookup_symbol(name_index); } |
|
1373 Symbol* signature() const { return lookup_symbol(signature_index); } |
|
1374 |
|
1375 int compute_offset(); |
|
1376 |
|
1377 // Find the Symbol for this index |
|
1378 static Symbol* lookup_symbol(int symbol_index) { |
|
1379 return vmSymbols::symbol_at((vmSymbols::SID)symbol_index); |
|
1380 } |
|
1381 }; |
|
1382 |
|
1383 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ |
|
1384 klass##_##name##_enum, |
|
1385 |
|
1386 #define ALL_INJECTED_FIELDS(macro) \ |
|
1387 CLASS_INJECTED_FIELDS(macro) \ |
|
1388 METHODHANDLE_INJECTED_FIELDS(macro) \ |
|
1389 DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \ |
|
1390 MEMBERNAME_INJECTED_FIELDS(macro) \ |
|
1391 METHODTYPEFORM_INJECTED_FIELDS(macro) |
|
1392 |
1346 // Interface to hard-coded offset checking |
1393 // Interface to hard-coded offset checking |
1347 |
1394 |
1348 class JavaClasses : AllStatic { |
1395 class JavaClasses : AllStatic { |
1349 private: |
1396 private: |
|
1397 |
|
1398 static InjectedField _injected_fields[]; |
|
1399 |
1350 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1400 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1351 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1401 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1352 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1402 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1353 public: |
1403 |
|
1404 public: |
|
1405 enum InjectedFieldID { |
|
1406 ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM) |
|
1407 MAX_enum |
|
1408 }; |
|
1409 |
|
1410 static int compute_injected_offset(InjectedFieldID id); |
|
1411 |
1354 static void compute_hard_coded_offsets(); |
1412 static void compute_hard_coded_offsets(); |
1355 static void compute_offsets(); |
1413 static void compute_offsets(); |
1356 static void check_offsets() PRODUCT_RETURN; |
1414 static void check_offsets() PRODUCT_RETURN; |
1357 }; |
1415 |
|
1416 static InjectedField* get_injected(Symbol* class_name, int* field_count); |
|
1417 }; |
|
1418 |
|
1419 #undef DECLARE_INJECTED_FIELD_ENUM |
1358 |
1420 |
1359 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP |
1421 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP |