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