< prev index next >

src/hotspot/share/cds/classPrelinker.hpp

Print this page

 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_CLASSPRELINKER_HPP
 26 #define SHARE_CDS_CLASSPRELINKER_HPP
 27 
 28 #include "interpreter/bytecodes.hpp"
 29 #include "oops/oopsHierarchy.hpp"
 30 #include "memory/allStatic.hpp"
 31 #include "memory/allocation.hpp"
 32 #include "runtime/handles.hpp"
 33 #include "utilities/exceptions.hpp"
 34 #include "utilities/macros.hpp"
 35 #include "utilities/resourceHash.hpp"
 36 
 37 class ConstantPool;
 38 class constantPoolHandle;
 39 class InstanceKlass;
 40 class Klass;



 41 
 42 // ClassPrelinker is used to perform ahead-of-time linking of ConstantPool entries
 43 // for archived InstanceKlasses.
 44 //
 45 // At run time, Java classes are loaded dynamically and may be replaced with JVMTI.
 46 // Therefore, we take care to prelink only the ConstantPool entries that are
 47 // guatanteed to resolve to the same results at both dump time and run time.
 48 //
 49 // For example, a JVM_CONSTANT_Class reference to a supertype can be safely resolved
 50 // at dump time, because at run time we will load a class from the CDS archive only
 51 // if all of its supertypes are loaded from the CDS archive.
 52 class ClassPrelinker :  AllStatic {

 53   using ClassesTable = ResourceHashtable<InstanceKlass*, bool, 15889, AnyObj::C_HEAP, mtClassShared> ;
 54   static ClassesTable* _processed_classes;
 55   static ClassesTable* _vm_classes;
 56 
 57   static void add_one_vm_class(InstanceKlass* ik);
 58 
 59 #ifdef ASSERT



 60   static bool is_in_archivebuilder_buffer(address p);
 61 #endif
 62 
 63   template <typename T>
 64   static bool is_in_archivebuilder_buffer(T p) {
 65     return is_in_archivebuilder_buffer((address)(p));
 66   }
 67   static void resolve_string(constantPoolHandle cp, int cp_index, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
 68   static bool is_class_resolution_deterministic(InstanceKlass* cp_holder, Klass* resolved_class);







 69 
 70   static Klass* find_loaded_class(Thread* current, oop class_loader, Symbol* name);
 71   static Klass* find_loaded_class(Thread* current, ConstantPool* cp, int class_cp_index);
 72 
 73   // fmi = FieldRef/MethodRef/InterfaceMethodRef
 74   static void maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m, Bytecodes::Code bc, int raw_index,
 75                                     GrowableArray<bool>* resolve_fmi_list, TRAPS);
 76 public:
 77   static void initialize();
 78   static void dispose();
 79 
 80   static void preresolve_class_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list);
 81   static void preresolve_field_and_method_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list);





 82 
 83   // Is this class resolved as part of vmClasses::resolve_all()? If so, these
 84   // classes are guatanteed to be loaded at runtime (and cannot be replaced by JVMTI)
 85   // when CDS is enabled. Therefore, we can safely keep a direct reference to these
 86   // classes.
 87   static bool is_vm_class(InstanceKlass* ik);
 88 
 89   // Resolve all constant pool entries that are safe to be stored in the
 90   // CDS archive.
 91   static void dumptime_resolve_constants(InstanceKlass* ik, TRAPS);
 92 
 93   static bool is_resolution_deterministic(ConstantPool* cp, int cp_index);
 94 };
 95 
 96 #endif // SHARE_CDS_CLASSPRELINKER_HPP

 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_CLASSPRELINKER_HPP
 26 #define SHARE_CDS_CLASSPRELINKER_HPP
 27 
 28 #include "interpreter/bytecodes.hpp"
 29 #include "oops/oopsHierarchy.hpp"
 30 #include "memory/allStatic.hpp"
 31 #include "memory/allocation.hpp"
 32 #include "runtime/handles.hpp"
 33 #include "utilities/exceptions.hpp"
 34 #include "utilities/macros.hpp"
 35 #include "utilities/resourceHash.hpp"
 36 
 37 class ConstantPool;
 38 class constantPoolHandle;
 39 class InstanceKlass;
 40 class Klass;
 41 class SerializeClosure;
 42 
 43 template <typename T> class GrowableArray;
 44 
 45 // ClassPrelinker is used to perform ahead-of-time linking of ConstantPool entries
 46 // for archived InstanceKlasses.
 47 //
 48 // At run time, Java classes are loaded dynamically and may be replaced with JVMTI.
 49 // Therefore, we take care to prelink only the ConstantPool entries that are
 50 // guatanteed to resolve to the same results at both dump time and run time.
 51 //
 52 // For example, a JVM_CONSTANT_Class reference to a supertype can be safely resolved
 53 // at dump time, because at run time we will load a class from the CDS archive only
 54 // if all of its supertypes are loaded from the CDS archive.
 55 class ClassPrelinker :  AllStatic {
 56   class PreloadedKlassRecorder;
 57   using ClassesTable = ResourceHashtable<InstanceKlass*, bool, 15889, AnyObj::C_HEAP, mtClassShared> ;
 58   static ClassesTable* _processed_classes;



 59 
 60 #ifdef ASSERT
 61   template <typename T> static bool is_in_archivebuilder_buffer(T p) {
 62     return is_in_archivebuilder_buffer((address)(p));
 63   }
 64   static bool is_in_archivebuilder_buffer(address p);
 65 #endif
 66 




 67   static void resolve_string(constantPoolHandle cp, int cp_index, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
 68   static bool is_class_resolution_deterministic(InstanceKlass* cp_holder, Klass* resolved_class);
 69   static bool is_indy_resolution_deterministic(ConstantPool* cp, int cp_index);
 70 
 71   // helper
 72   static Klass* resolve_boot_class_or_fail(const char* class_name, TRAPS);
 73 
 74   // java/lang/reflect/Proxy caching
 75   static void init_dynamic_proxy_cache(TRAPS);
 76 
 77   static Klass* find_loaded_class(Thread* current, oop class_loader, Symbol* name);
 78   static Klass* find_loaded_class(Thread* current, ConstantPool* cp, int class_cp_index);
 79 
 80   // fmi = FieldRef/MethodRef/InterfaceMethodRef
 81   static void maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m, Bytecodes::Code bc, int raw_index,
 82                                     GrowableArray<bool>* resolve_fmi_list, TRAPS);
 83 public:
 84   static void initialize();
 85   static void dispose();
 86 
 87   static void preresolve_class_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list);
 88   static void preresolve_field_and_method_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list);
 89   static void preresolve_indy_cp_entries(JavaThread* current, InstanceKlass* ik, GrowableArray<bool>* preresolve_list);
 90 
 91   // java/lang/Class$ReflectionData caching
 92   static int class_reflection_data_flags(InstanceKlass* ik, TRAPS);
 93   static void generate_reflection_data(JavaThread* current, InstanceKlass* ik, int rd_flags);
 94 
 95   // java/lang/reflect/Proxy caching
 96   static void trace_dynamic_proxy_class(oop loader, const char* proxy_name, objArrayOop interfaces, int access_flags);
 97   static void define_dynamic_proxy_class(Handle loader, Handle proxy_name, Handle interfaces, int access_flags, TRAPS);


 98 
 99   // Resolve all constant pool entries that are safe to be stored in the
100   // CDS archive.
101   static void dumptime_resolve_constants(InstanceKlass* ik, TRAPS);
102 
103   static bool is_resolution_deterministic(ConstantPool* cp, int cp_index);
104 };
105 
106 #endif // SHARE_CDS_CLASSPRELINKER_HPP
< prev index next >