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 CP_RESOLVE_CLASS = 0x1 << 0; // CP has preresolved class entries
46 static constexpr int CP_RESOLVE_FIELD_AND_METHOD = 0x1 << 1; // CP has preresolved field/method entries
47 static constexpr int CP_RESOLVE_INDY = 0x1 << 2; // CP has preresolved indy entries
48 static constexpr int WAS_INITED = 0x1 << 3; // Class was initialized during training run
49
50 // A list of all the archived classes from the preimage. We want to transfer all of these
51 // into the final image.
52 Array<Klass*>* _all_klasses;
53
54 // For each klass k _all_klasses->at(i): _cp_recipes->at(i) lists all the {klass,field,method,indy}
55 // cp indices that were resolved for k during the training run; _flags->at(i) has extra info about k.
56 Array<Array<int>*>* _cp_recipes;
57 Array<int>* _flags;
58
59 FinalImageRecipes() : _all_klasses(nullptr), _cp_recipes(nullptr), _flags(nullptr) {}
60
61 void* operator new(size_t size) throw();
62
63 // Called when dumping preimage
64 void record_all_classes();
65 void record_recipes_for_constantpool();
66
67 // Called when dumping final image
68 void apply_recipes_impl(TRAPS);
69 void load_all_classes(TRAPS);
70 void apply_recipes_for_constantpool(JavaThread* current);
71
72 public:
73 static void serialize(SerializeClosure* soc);
74
75 // Called when dumping preimage
76 static void record_recipes();
77
78 // Called when dumping final image
79 static void apply_recipes(TRAPS);
80 };
81
82 #endif // SHARE_CDS_FINALIMAGERECIPES_HPP
|
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 CP_RESOLVE_CLASS = 0x1 << 0; // CP has preresolved class entries
46 static constexpr int CP_RESOLVE_FIELD_AND_METHOD = 0x1 << 1; // CP has preresolved field/method entries
47 static constexpr int CP_RESOLVE_INDY = 0x1 << 2; // CP has preresolved indy entries
48 static constexpr int WAS_INITED = 0x1 << 3; // Class was initialized during training run
49
50 // A list of all the archived classes from the preimage. We want to transfer all of these
51 // into the final image.
52 Array<Klass*>* _all_klasses;
53
54 // For each klass k _all_klasses->at(i): _cp_recipes->at(i) lists all the {klass,field,method,indy}
55 // cp indices that were resolved for k during the training run; _flags->at(i) has extra info about k.
56 Array<Array<int>*>* _cp_recipes;
57 Array<int>* _flags;
58
59 // The RefectionData for _reflect_klasses[i] should be initialized with _reflect_flags[i]
60 Array<InstanceKlass*>* _reflect_klasses;
61 Array<int>* _reflect_flags;
62
63 static GrowableArray<InstanceKlass*>* _tmp_reflect_klasses;
64 static GrowableArray<int>* _tmp_reflect_flags;
65
66 struct TmpDynamicProxyClassInfo {
67 int _loader_type;
68 int _access_flags;
69 const char* _proxy_name;
70 GrowableArray<Klass*>* _interfaces;
71 };
72
73 struct DynamicProxyClassInfo {
74 int _loader_type;
75 int _access_flags;
76 const char* _proxy_name;
77 Array<Klass*>* _interfaces;
78 };
79
80 Array<DynamicProxyClassInfo>* _dynamic_proxy_classes;
81
82 static GrowableArray<TmpDynamicProxyClassInfo>* _tmp_dynamic_proxy_classes;
83
84 FinalImageRecipes() : _all_klasses(nullptr), _cp_recipes(nullptr), _flags(nullptr),
85 _reflect_klasses(nullptr), _reflect_flags(nullptr),
86 _dynamic_proxy_classes(nullptr) {}
87
88 void* operator new(size_t size) throw();
89
90 // Called when dumping preimage
91 void record_all_classes();
92 void record_recipes_for_constantpool();
93 void record_recipes_for_reflection_data();
94 void record_recipes_for_dynamic_proxies();
95
96 // Called when dumping final image
97 void apply_recipes_impl(TRAPS);
98 void load_all_classes(TRAPS);
99 void apply_recipes_for_constantpool(JavaThread* current);
100 void apply_recipes_for_reflection_data(JavaThread* current);
101 void apply_recipes_for_dynamic_proxies(TRAPS);
102
103 public:
104 static void serialize(SerializeClosure* soc);
105
106 // Called when dumping preimage
107 static void add_dynamic_proxy_class(oop loader, const char* proxy_name, objArrayOop interfaces, int access_flags);
108 static void add_reflection_data_flags(InstanceKlass* ik, TRAPS);
109 static void record_recipes();
110
111 // Called when dumping final image
112 static void apply_recipes(TRAPS);
113 };
114
115 #endif // SHARE_CDS_FINALIMAGERECIPES_HPP
|