13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "aot/aotLoader.hpp"
28 #include "classfile/classFileParser.hpp"
29 #include "classfile/classFileStream.hpp"
30 #include "classfile/classLoader.hpp"
31 #include "classfile/classLoaderData.inline.hpp"
32 #include "classfile/classLoaderDataGraph.inline.hpp"
33 #include "classfile/classLoaderExt.hpp"
34 #include "classfile/dictionary.hpp"
35 #include "classfile/javaClasses.inline.hpp"
36 #include "classfile/klassFactory.hpp"
37 #include "classfile/loaderConstraints.hpp"
38 #include "classfile/packageEntry.hpp"
39 #include "classfile/placeholders.hpp"
40 #include "classfile/protectionDomainCache.hpp"
41 #include "classfile/resolutionErrors.hpp"
42 #include "classfile/stringTable.hpp"
43 #include "classfile/symbolTable.hpp"
44 #include "classfile/systemDictionary.hpp"
45 #include "classfile/vmSymbols.hpp"
46 #include "code/codeCache.hpp"
47 #include "compiler/compileBroker.hpp"
48 #include "gc/shared/gcTraceTime.inline.hpp"
49 #include "interpreter/bytecodeStream.hpp"
50 #include "interpreter/interpreter.hpp"
51 #include "jfr/jfrEvents.hpp"
52 #include "logging/log.hpp"
167 }
168
169 void SystemDictionary::compute_java_loaders(TRAPS) {
170 JavaValue result(T_OBJECT);
171 InstanceKlass* class_loader_klass = SystemDictionary::ClassLoader_klass();
172 JavaCalls::call_static(&result,
173 class_loader_klass,
174 vmSymbols::getSystemClassLoader_name(),
175 vmSymbols::void_classloader_signature(),
176 CHECK);
177
178 _java_system_loader = OopHandle(Universe::vm_global(), (oop)result.get_jobject());
179
180 JavaCalls::call_static(&result,
181 class_loader_klass,
182 vmSymbols::getPlatformClassLoader_name(),
183 vmSymbols::void_classloader_signature(),
184 CHECK);
185
186 _java_platform_loader = OopHandle(Universe::vm_global(), (oop)result.get_jobject());
187
188 #if INCLUDE_CDS_JAVA_HEAP
189 if (UseSharedSpaces && MetaspaceShared::use_full_module_graph()) {
190 Handle platform_loader(THREAD, java_platform_loader());
191 register_loader(platform_loader)->restore_java_platform_loader_from_archive();
192
193 Handle system_loader(THREAD, java_system_loader());
194 register_loader(system_loader)->restore_java_system_loader_from_archive();
195 }
196 #endif
197 }
198
199 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool create_mirror_cld) {
200 if (create_mirror_cld) {
201 // Add a new class loader data to the graph.
202 return ClassLoaderDataGraph::add(class_loader, true);
203 } else {
204 return (class_loader() == NULL) ? ClassLoaderData::the_null_class_loader_data() :
205 ClassLoaderDataGraph::find_or_create(class_loader);
206 }
207 }
208
209 // ----------------------------------------------------------------------------
210 // Parallel class loading check
211
212 bool SystemDictionary::is_parallelCapable(Handle class_loader) {
213 if (class_loader.is_null()) return true;
214 if (AlwaysLockClassLoader) return false;
215 return java_lang_ClassLoader::parallelCapable(class_loader());
216 }
2114 WKID scan = FIRST_WKID;
2115 // first do Object, then String, Class
2116 #if INCLUDE_CDS
2117 if (UseSharedSpaces) {
2118 resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
2119
2120 // It's unsafe to access the archived heap regions before they
2121 // are fixed up, so we must do the fixup as early as possible
2122 // before the archived java objects are accessed by functions
2123 // such as java_lang_Class::restore_archived_mirror and
2124 // ConstantPool::restore_unshareable_info (restores the archived
2125 // resolved_references array object).
2126 //
2127 // HeapShared::fixup_mapped_heap_regions() fills the empty
2128 // spaces in the archived heap regions and may use
2129 // SystemDictionary::Object_klass(), so we can do this only after
2130 // Object_klass is resolved. See the above resolve_wk_klasses_through()
2131 // call. No mirror objects are accessed/restored in the above call.
2132 // Mirrors are restored after java.lang.Class is loaded.
2133 HeapShared::fixup_mapped_heap_regions();
2134 CDS_JAVA_HEAP_ONLY(ClassLoaderData::restore_archived_oops_for_null_class_loader_data());
2135
2136 // Initialize the constant pool for the Object_class
2137 assert(Object_klass()->is_shared(), "must be");
2138 Object_klass()->constants()->restore_unshareable_info(CHECK);
2139 resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
2140 } else
2141 #endif
2142 {
2143 resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
2144 }
2145
2146 assert(WK_KLASS(Object_klass) != NULL, "well-known classes should now be initialized");
2147
2148 java_lang_Object::register_natives(CHECK);
2149
2150 // Calculate offsets for String and Class classes since they are loaded and
2151 // can be used after this point.
2152 java_lang_String::compute_offsets();
2153 java_lang_Class::compute_offsets();
2154
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "aot/aotLoader.hpp"
28 #include "classfile/classFileParser.hpp"
29 #include "classfile/classFileStream.hpp"
30 #include "classfile/classLoader.hpp"
31 #include "classfile/classLoaderData.inline.hpp"
32 #include "classfile/classLoaderDataGraph.inline.hpp"
33 #include "classfile/classLoaderDataShared.hpp"
34 #include "classfile/classLoaderExt.hpp"
35 #include "classfile/dictionary.hpp"
36 #include "classfile/javaClasses.inline.hpp"
37 #include "classfile/klassFactory.hpp"
38 #include "classfile/loaderConstraints.hpp"
39 #include "classfile/packageEntry.hpp"
40 #include "classfile/placeholders.hpp"
41 #include "classfile/protectionDomainCache.hpp"
42 #include "classfile/resolutionErrors.hpp"
43 #include "classfile/stringTable.hpp"
44 #include "classfile/symbolTable.hpp"
45 #include "classfile/systemDictionary.hpp"
46 #include "classfile/vmSymbols.hpp"
47 #include "code/codeCache.hpp"
48 #include "compiler/compileBroker.hpp"
49 #include "gc/shared/gcTraceTime.inline.hpp"
50 #include "interpreter/bytecodeStream.hpp"
51 #include "interpreter/interpreter.hpp"
52 #include "jfr/jfrEvents.hpp"
53 #include "logging/log.hpp"
168 }
169
170 void SystemDictionary::compute_java_loaders(TRAPS) {
171 JavaValue result(T_OBJECT);
172 InstanceKlass* class_loader_klass = SystemDictionary::ClassLoader_klass();
173 JavaCalls::call_static(&result,
174 class_loader_klass,
175 vmSymbols::getSystemClassLoader_name(),
176 vmSymbols::void_classloader_signature(),
177 CHECK);
178
179 _java_system_loader = OopHandle(Universe::vm_global(), (oop)result.get_jobject());
180
181 JavaCalls::call_static(&result,
182 class_loader_klass,
183 vmSymbols::getPlatformClassLoader_name(),
184 vmSymbols::void_classloader_signature(),
185 CHECK);
186
187 _java_platform_loader = OopHandle(Universe::vm_global(), (oop)result.get_jobject());
188 }
189
190 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool create_mirror_cld) {
191 if (create_mirror_cld) {
192 // Add a new class loader data to the graph.
193 return ClassLoaderDataGraph::add(class_loader, true);
194 } else {
195 return (class_loader() == NULL) ? ClassLoaderData::the_null_class_loader_data() :
196 ClassLoaderDataGraph::find_or_create(class_loader);
197 }
198 }
199
200 // ----------------------------------------------------------------------------
201 // Parallel class loading check
202
203 bool SystemDictionary::is_parallelCapable(Handle class_loader) {
204 if (class_loader.is_null()) return true;
205 if (AlwaysLockClassLoader) return false;
206 return java_lang_ClassLoader::parallelCapable(class_loader());
207 }
2105 WKID scan = FIRST_WKID;
2106 // first do Object, then String, Class
2107 #if INCLUDE_CDS
2108 if (UseSharedSpaces) {
2109 resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
2110
2111 // It's unsafe to access the archived heap regions before they
2112 // are fixed up, so we must do the fixup as early as possible
2113 // before the archived java objects are accessed by functions
2114 // such as java_lang_Class::restore_archived_mirror and
2115 // ConstantPool::restore_unshareable_info (restores the archived
2116 // resolved_references array object).
2117 //
2118 // HeapShared::fixup_mapped_heap_regions() fills the empty
2119 // spaces in the archived heap regions and may use
2120 // SystemDictionary::Object_klass(), so we can do this only after
2121 // Object_klass is resolved. See the above resolve_wk_klasses_through()
2122 // call. No mirror objects are accessed/restored in the above call.
2123 // Mirrors are restored after java.lang.Class is loaded.
2124 HeapShared::fixup_mapped_heap_regions();
2125 CDS_JAVA_HEAP_ONLY(ClassLoaderDataShared::restore_archived_oops_for_null_class_loader_data());
2126
2127 // Initialize the constant pool for the Object_class
2128 assert(Object_klass()->is_shared(), "must be");
2129 Object_klass()->constants()->restore_unshareable_info(CHECK);
2130 resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
2131 } else
2132 #endif
2133 {
2134 resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
2135 }
2136
2137 assert(WK_KLASS(Object_klass) != NULL, "well-known classes should now be initialized");
2138
2139 java_lang_Object::register_natives(CHECK);
2140
2141 // Calculate offsets for String and Class classes since they are loaded and
2142 // can be used after this point.
2143 java_lang_String::compute_offsets();
2144 java_lang_Class::compute_offsets();
2145
|