38 // to the JVM that creates the AOTCache (aka the "final image").
39 // - The recipes are recorded when CDSConfig::is_dumping_preimage_static_archive() is true.
40 // - The recipes are applied when CDSConfig::is_dumping_final_static_archive() is true.
41 // The following information are recorded:
42 // - The list of all classes that are stored in the AOTConfiguration file.
43 // - The list of all classes that require AOT resolution of invokedynamic call sites.
44 class FinalImageRecipes {
45 static constexpr int HAS_CLASS = 0x1;
46 static constexpr int HAS_FIELD_AND_METHOD = 0x2;
47 static constexpr int HAS_INDY = 0x4;
48
49 // A list of all the archived classes from the preimage. We want to transfer all of these
50 // into the final image.
51 Array<Klass*>* _all_klasses;
52
53 // For each klass k _all_klasses->at(i), _cp_recipes->at(i) lists all the {klass,field,method,indy}
54 // cp indices that were resolved for k during the training run.
55 Array<Array<int>*>* _cp_recipes;
56 Array<int>* _cp_flags;
57
58 FinalImageRecipes() : _all_klasses(nullptr), _cp_recipes(nullptr), _cp_flags(nullptr) {}
59
60 void* operator new(size_t size) throw();
61
62 // Called when dumping preimage
63 void record_all_classes();
64 void record_recipes_for_constantpool();
65
66 // Called when dumping final image
67 void apply_recipes_impl(TRAPS);
68 void load_all_classes(TRAPS);
69 void apply_recipes_for_constantpool(JavaThread* current);
70
71 public:
72 static void serialize(SerializeClosure* soc);
73
74 // Called when dumping preimage
75 static void record_recipes();
76
77 // Called when dumping final image
78 static void apply_recipes(TRAPS);
79 };
80
81 #endif // SHARE_CDS_FINALIMAGERECIPES_HPP
|
38 // to the JVM that creates the AOTCache (aka the "final image").
39 // - The recipes are recorded when CDSConfig::is_dumping_preimage_static_archive() is true.
40 // - The recipes are applied when CDSConfig::is_dumping_final_static_archive() is true.
41 // The following information are recorded:
42 // - The list of all classes that are stored in the AOTConfiguration file.
43 // - The list of all classes that require AOT resolution of invokedynamic call sites.
44 class FinalImageRecipes {
45 static constexpr int HAS_CLASS = 0x1;
46 static constexpr int HAS_FIELD_AND_METHOD = 0x2;
47 static constexpr int HAS_INDY = 0x4;
48
49 // A list of all the archived classes from the preimage. We want to transfer all of these
50 // into the final image.
51 Array<Klass*>* _all_klasses;
52
53 // For each klass k _all_klasses->at(i), _cp_recipes->at(i) lists all the {klass,field,method,indy}
54 // cp indices that were resolved for k during the training run.
55 Array<Array<int>*>* _cp_recipes;
56 Array<int>* _cp_flags;
57
58 // The RefectionData for _reflect_klasses[i] should be initialized with _reflect_flags[i]
59 Array<InstanceKlass*>* _reflect_klasses;
60 Array<int>* _reflect_flags;
61
62 static GrowableArray<InstanceKlass*>* _tmp_reflect_klasses;
63 static GrowableArray<int>* _tmp_reflect_flags;
64
65 struct TmpDynamicProxyClassInfo {
66 int _loader_type;
67 int _access_flags;
68 const char* _proxy_name;
69 GrowableArray<Klass*>* _interfaces;
70 };
71
72 struct DynamicProxyClassInfo {
73 int _loader_type;
74 int _access_flags;
75 const char* _proxy_name;
76 Array<Klass*>* _interfaces;
77 };
78
79 Array<DynamicProxyClassInfo>* _dynamic_proxy_classes;
80
81 static GrowableArray<TmpDynamicProxyClassInfo>* _tmp_dynamic_proxy_classes;
82
83 FinalImageRecipes() : _all_klasses(nullptr), _cp_recipes(nullptr), _cp_flags(nullptr),
84 _reflect_klasses(nullptr), _reflect_flags(nullptr),
85 _dynamic_proxy_classes(nullptr) {}
86
87 void* operator new(size_t size) throw();
88
89 // Called when dumping preimage
90 void record_all_classes();
91 void record_recipes_for_constantpool();
92 void record_recipes_for_reflection_data();
93 void record_recipes_for_dynamic_proxies();
94
95 // Called when dumping final image
96 void apply_recipes_impl(TRAPS);
97 void load_all_classes(TRAPS);
98 void apply_recipes_for_constantpool(JavaThread* current);
99 void apply_recipes_for_reflection_data(JavaThread* current);
100 void apply_recipes_for_dynamic_proxies(TRAPS);
101
102 public:
103 static void serialize(SerializeClosure* soc);
104
105 // Called when dumping preimage
106 static void add_dynamic_proxy_class(oop loader, const char* proxy_name, objArrayOop interfaces, int access_flags);
107 static void add_reflection_data_flags(InstanceKlass* ik, TRAPS);
108 static void record_recipes();
109
110 // Called when dumping final image
111 static void apply_recipes(TRAPS);
112 };
113
114 #endif // SHARE_CDS_FINALIMAGERECIPES_HPP
|