213
214 class java_lang_Class : AllStatic {
215 friend class VMStructs;
216 friend class JVMCIVMStructs;
217
218 private:
219
220 // The fake offsets are added by the class loader when java.lang.Class is loaded
221
222 static int _klass_offset;
223 static int _array_klass_offset;
224
225 static int _oop_size_offset;
226 static int _static_oop_field_count_offset;
227
228 static int _protection_domain_offset;
229 static int _signers_offset;
230 static int _class_loader_offset;
231 static int _module_offset;
232 static int _component_mirror_offset;
233 static int _name_offset;
234 static int _source_file_offset;
235 static int _classData_offset;
236 static int _classRedefinedCount_offset;
237
238 static bool _offsets_computed;
239
240 static GrowableArray<Klass*>* _fixup_mirror_list;
241 static GrowableArray<Klass*>* _fixup_module_field_list;
242
243 static void set_protection_domain(oop java_class, oop protection_domain);
244 static void set_class_loader(oop java_class, oop class_loader);
245 static void set_component_mirror(oop java_class, oop comp_mirror);
246 static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
247 Handle classData, TRAPS);
248 static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
249 public:
250 static void allocate_fixup_lists();
251 static void compute_offsets();
252
253 // Instance creation
254 static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
255 Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
256 static void create_mirror(Klass* k, Handle class_loader, Handle module,
257 Handle protection_domain, Handle classData, TRAPS);
258 static void fixup_mirror(Klass* k, TRAPS);
259 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
260
261 // Archiving
262 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
263 static void create_scratch_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
264 static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
265 Handle protection_domain,
266 TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
267
268 static void fixup_module_field(Klass* k, Handle module);
269
270 // Conversion
271 static Klass* as_Klass(oop java_class);
272 static void set_klass(oop java_class, Klass* klass);
273 static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
274 static Symbol* as_signature(oop java_class, bool intern_if_not_found);
275 static void print_signature(oop java_class, outputStream *st);
276 static const char* as_external_name(oop java_class);
277 // Testing
278 static bool is_instance(oop obj);
279
280 static bool is_primitive(oop java_class);
281 static BasicType primitive_type(oop java_class);
282 static oop primitive_mirror(BasicType t);
283 // JVM_NewArray support
284 static Klass* array_klass_acquire(oop java_class);
285 static void release_set_array_klass(oop java_class, Klass* klass);
286 // compiler support for class operations
287 static int klass_offset() { CHECK_INIT(_klass_offset); }
288 static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
289 // Support for classRedefinedCount field
290 static int classRedefinedCount(oop the_class_mirror);
291 static void set_classRedefinedCount(oop the_class_mirror, int value);
292
293 // Support for embedded per-class oops
294 static oop protection_domain(oop java_class);
295 static oop component_mirror(oop java_class);
296 static objArrayOop signers(oop java_class);
297 static void set_signers(oop java_class, objArrayOop signers);
298 static oop class_data(oop java_class);
299 static void set_class_data(oop java_class, oop classData);
300
301 static int component_mirror_offset() { return _component_mirror_offset; }
302
303 static oop class_loader(oop java_class);
304 static void set_module(oop java_class, oop module);
305 static oop module(oop java_class);
306
307 static oop name(Handle java_class, TRAPS);
308
309 static oop source_file(oop java_class);
310 static void set_source_file(oop java_class, oop source_file);
311
312 static size_t oop_size(oop java_class);
313 static void set_oop_size(HeapWord* java_class, size_t size);
314 static int static_oop_field_count(oop java_class);
315 static void set_static_oop_field_count(oop java_class, int size);
316
317 static GrowableArray<Klass*>* fixup_mirror_list() {
318 return _fixup_mirror_list;
319 }
320 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
321 _fixup_mirror_list = v;
322 }
1264 static void set_flags(oop mname, int flags);
1265
1266 // Link through ResolvedMethodName field to get Method*
1267 static Method* vmtarget(oop mname);
1268 static void set_method(oop mname, oop method);
1269
1270 static intptr_t vmindex(oop mname);
1271 static void set_vmindex(oop mname, intptr_t index);
1272
1273 // Testers
1274 static bool is_subclass(Klass* klass) {
1275 return klass->is_subclass_of(vmClasses::MemberName_klass());
1276 }
1277 static bool is_instance(oop obj);
1278
1279 static bool is_method(oop obj);
1280
1281 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1282 enum {
1283 MN_IS_METHOD = 0x00010000, // method (not constructor)
1284 MN_IS_CONSTRUCTOR = 0x00020000, // constructor
1285 MN_IS_FIELD = 0x00040000, // field
1286 MN_IS_TYPE = 0x00080000, // nested type
1287 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1288 MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1289 MN_HIDDEN_MEMBER = 0x00400000, // @Hidden annotation detected
1290 MN_REFERENCE_KIND_SHIFT = 24, // refKind
1291 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
1292 MN_NESTMATE_CLASS = 0x00000001,
1293 MN_HIDDEN_CLASS = 0x00000002,
1294 MN_STRONG_LOADER_LINK = 0x00000004,
1295 MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1296 // Lookup modes
1297 MN_MODULE_MODE = 0x00000010,
1298 MN_UNCONDITIONAL_MODE = 0x00000020,
1299 MN_TRUSTED_MODE = -1
1300 };
1301
1302 // Accessors for code generation:
1303 static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1304 static int type_offset() { CHECK_INIT(_type_offset); }
1305 static int flags_offset() { CHECK_INIT(_flags_offset); }
1306 static int method_offset() { CHECK_INIT(_method_offset); }
1307 static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1308 };
1309
1833 class java_lang_Short_ShortCache : AllStatic {
1834 private:
1835 static int _static_cache_offset;
1836 public:
1837 static Symbol* symbol();
1838 static void compute_offsets(InstanceKlass* k);
1839 static objArrayOop cache(InstanceKlass *k);
1840 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1841 };
1842
1843 class java_lang_Byte_ByteCache : AllStatic {
1844 private:
1845 static int _static_cache_offset;
1846 public:
1847 static Symbol* symbol();
1848 static void compute_offsets(InstanceKlass* k);
1849 static objArrayOop cache(InstanceKlass *k);
1850 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1851 };
1852
1853
1854 // Interface to java.lang.InternalError objects
1855
1856 #define INTERNALERROR_INJECTED_FIELDS(macro) \
1857 macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1858
1859 class java_lang_InternalError : AllStatic {
1860 private:
1861 static int _during_unsafe_access_offset;
1862 public:
1863 static jboolean during_unsafe_access(oop internal_error);
1864 static void set_during_unsafe_access(oop internal_error);
1865 static void compute_offsets();
1866 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1867 };
1868
1869 // Use to declare fields that need to be injected into Java classes
1870 // for the JVM to use. The name_index and signature_index are
1871 // declared in vmSymbols. The may_be_java flag is used to declare
1872 // fields that might already exist in Java but should be injected if
1873 // they don't. Otherwise the field is unconditionally injected and
|
213
214 class java_lang_Class : AllStatic {
215 friend class VMStructs;
216 friend class JVMCIVMStructs;
217
218 private:
219
220 // The fake offsets are added by the class loader when java.lang.Class is loaded
221
222 static int _klass_offset;
223 static int _array_klass_offset;
224
225 static int _oop_size_offset;
226 static int _static_oop_field_count_offset;
227
228 static int _protection_domain_offset;
229 static int _signers_offset;
230 static int _class_loader_offset;
231 static int _module_offset;
232 static int _component_mirror_offset;
233 static int _primary_mirror_offset;
234 static int _secondary_mirror_offset;
235
236 static int _name_offset;
237 static int _source_file_offset;
238 static int _classData_offset;
239 static int _classRedefinedCount_offset;
240
241 static bool _offsets_computed;
242
243 static GrowableArray<Klass*>* _fixup_mirror_list;
244 static GrowableArray<Klass*>* _fixup_module_field_list;
245
246 static void set_protection_domain(oop java_class, oop protection_domain);
247 static void set_class_loader(oop java_class, oop class_loader);
248 static void set_component_mirror(oop java_class, oop comp_mirror);
249 static void set_primary_mirror(oop java_class, oop comp_mirror);
250 static void set_secondary_mirror(oop java_class, oop comp_mirror);
251
252 static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
253 Handle classData, TRAPS);
254 static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
255 public:
256 static void allocate_fixup_lists();
257 static void compute_offsets();
258
259 // Instance creation
260 static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
261 Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
262 static void create_mirror(Klass* k, Handle class_loader, Handle module,
263 Handle protection_domain, Handle classData, TRAPS);
264 static void fixup_mirror(Klass* k, TRAPS);
265 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
266 static oop create_secondary_mirror(Klass* k, Handle mirror, TRAPS);
267
268 // Archiving
269 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
270 static void create_scratch_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
271 static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
272 Handle protection_domain,
273 TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
274
275 static void fixup_module_field(Klass* k, Handle module);
276
277 // Conversion
278 static Klass* as_Klass(oop java_class);
279 static void set_klass(oop java_class, Klass* klass);
280 static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
281 static Symbol* as_signature(oop java_class, bool intern_if_not_found);
282 static void print_signature(oop java_class, outputStream *st);
283 static const char* as_external_name(oop java_class);
284 // Testing
285 static bool is_instance(oop obj);
286
287 static bool is_primitive(oop java_class);
288 static BasicType primitive_type(oop java_class);
289 static oop primitive_mirror(BasicType t);
290 // JVM_NewArray support
291 static Klass* array_klass_acquire(oop java_class);
292 static void release_set_array_klass(oop java_class, Klass* klass);
293 // compiler support for class operations
294 static int klass_offset() { CHECK_INIT(_klass_offset); }
295 static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
296 static int component_mirror_offset() { CHECK_INIT(_component_mirror_offset); }
297 static int primary_mirror_offset() { CHECK_INIT(_primary_mirror_offset); }
298 static int secondary_mirror_offset() { CHECK_INIT(_secondary_mirror_offset); }
299 // Support for classRedefinedCount field
300 static int classRedefinedCount(oop the_class_mirror);
301 static void set_classRedefinedCount(oop the_class_mirror, int value);
302
303 // Support for embedded per-class oops
304 static oop protection_domain(oop java_class);
305 static oop component_mirror(oop java_class);
306 static oop primary_mirror(oop java_class);
307 static oop secondary_mirror(oop java_class);
308 static bool is_primary_mirror(oop java_class);
309 static bool is_secondary_mirror(oop java_class);
310
311 static objArrayOop signers(oop java_class);
312 static void set_signers(oop java_class, objArrayOop signers);
313 static oop class_data(oop java_class);
314 static void set_class_data(oop java_class, oop classData);
315
316 static oop class_loader(oop java_class);
317 static void set_module(oop java_class, oop module);
318 static oop module(oop java_class);
319
320 static oop name(Handle java_class, TRAPS);
321
322 static oop source_file(oop java_class);
323 static void set_source_file(oop java_class, oop source_file);
324
325 static size_t oop_size(oop java_class);
326 static void set_oop_size(HeapWord* java_class, size_t size);
327 static int static_oop_field_count(oop java_class);
328 static void set_static_oop_field_count(oop java_class, int size);
329
330 static GrowableArray<Klass*>* fixup_mirror_list() {
331 return _fixup_mirror_list;
332 }
333 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
334 _fixup_mirror_list = v;
335 }
1277 static void set_flags(oop mname, int flags);
1278
1279 // Link through ResolvedMethodName field to get Method*
1280 static Method* vmtarget(oop mname);
1281 static void set_method(oop mname, oop method);
1282
1283 static intptr_t vmindex(oop mname);
1284 static void set_vmindex(oop mname, intptr_t index);
1285
1286 // Testers
1287 static bool is_subclass(Klass* klass) {
1288 return klass->is_subclass_of(vmClasses::MemberName_klass());
1289 }
1290 static bool is_instance(oop obj);
1291
1292 static bool is_method(oop obj);
1293
1294 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1295 enum {
1296 MN_IS_METHOD = 0x00010000, // method (not constructor)
1297 MN_IS_OBJECT_CONSTRUCTOR = 0x00020000, // constructor
1298 MN_IS_FIELD = 0x00040000, // field
1299 MN_IS_TYPE = 0x00080000, // nested type
1300 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1301 MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1302 MN_HIDDEN_MEMBER = 0x00400000, // @Hidden annotation detected
1303 MN_FLAT_FIELD = 0x00800000, // flat field
1304 MN_REFERENCE_KIND_SHIFT = 24, // refKind
1305 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
1306 MN_NESTMATE_CLASS = 0x00000001,
1307 MN_HIDDEN_CLASS = 0x00000002,
1308 MN_STRONG_LOADER_LINK = 0x00000004,
1309 MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1310 // Lookup modes
1311 MN_MODULE_MODE = 0x00000010,
1312 MN_UNCONDITIONAL_MODE = 0x00000020,
1313 MN_TRUSTED_MODE = -1
1314 };
1315
1316 // Accessors for code generation:
1317 static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1318 static int type_offset() { CHECK_INIT(_type_offset); }
1319 static int flags_offset() { CHECK_INIT(_flags_offset); }
1320 static int method_offset() { CHECK_INIT(_method_offset); }
1321 static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1322 };
1323
1847 class java_lang_Short_ShortCache : AllStatic {
1848 private:
1849 static int _static_cache_offset;
1850 public:
1851 static Symbol* symbol();
1852 static void compute_offsets(InstanceKlass* k);
1853 static objArrayOop cache(InstanceKlass *k);
1854 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1855 };
1856
1857 class java_lang_Byte_ByteCache : AllStatic {
1858 private:
1859 static int _static_cache_offset;
1860 public:
1861 static Symbol* symbol();
1862 static void compute_offsets(InstanceKlass* k);
1863 static objArrayOop cache(InstanceKlass *k);
1864 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1865 };
1866
1867 // Interface to java.lang.InternalError objects
1868
1869 #define INTERNALERROR_INJECTED_FIELDS(macro) \
1870 macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1871
1872 class java_lang_InternalError : AllStatic {
1873 private:
1874 static int _during_unsafe_access_offset;
1875 public:
1876 static jboolean during_unsafe_access(oop internal_error);
1877 static void set_during_unsafe_access(oop internal_error);
1878 static void compute_offsets();
1879 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1880 };
1881
1882 // Use to declare fields that need to be injected into Java classes
1883 // for the JVM to use. The name_index and signature_index are
1884 // declared in vmSymbols. The may_be_java flag is used to declare
1885 // fields that might already exist in Java but should be injected if
1886 // they don't. Otherwise the field is unconditionally injected and
|