src/hotspot/share/aot/aotLoader.cpp
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File open Sdiff src/hotspot/share/aot

src/hotspot/share/aot/aotLoader.cpp

Print this page




 129   }
 130   if (UseAOT) {
 131     // EagerInitialization is not compatible with AOT
 132     if (EagerInitialization) {
 133       if (PrintAOT) {
 134         warning("EagerInitialization is not compatible with AOT (switching AOT off)");
 135       }
 136       FLAG_SET_DEFAULT(UseAOT, false);
 137       return;
 138     }
 139 
 140     // -Xint is not compatible with AOT
 141     if (Arguments::is_interpreter_only()) {
 142       if (PrintAOT) {
 143         warning("-Xint is not compatible with AOT (switching AOT off)");
 144       }
 145       FLAG_SET_DEFAULT(UseAOT, false);
 146       return;
 147     }
 148 
 149     const char* home = Arguments::get_java_home();
 150     const char* file_separator = os::file_separator();
 151 
 152     for (int i = 0; i < (int) (sizeof(modules) / sizeof(const char*)); i++) {
 153       char library[JVM_MAXPATHLEN];
 154       jio_snprintf(library, sizeof(library), "%s%slib%slib%s%s%s%s", home, file_separator, file_separator, modules[i], UseCompressedOops ? "-coop" : "", UseG1GC ? "" : "-nong1", os::dll_file_extension());
 155       load_library(library, false);
 156     }
 157 
 158     // Scan the AOTLibrary option.
 159     if (AOTLibrary != NULL) {
 160       const int len = (int)strlen(AOTLibrary);
 161       char* cp  = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
 162       if (cp != NULL) { // No memory?
 163         memcpy(cp, AOTLibrary, len);
 164         cp[len] = '\0';
 165         char* end = cp + len;
 166         while (cp < end) {
 167           const char* name = cp;
 168           while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != ':' && (*cp) != ';')  cp++;
 169           cp[0] = '\0';  // Terminate name
 170           cp++;
 171           load_library(name, true);
 172         }
 173       }
 174     }










 175   }
 176 }
 177 
 178 void AOTLoader::universe_init() {
 179   if (UseAOT && libraries_count() > 0) {
 180     // Shifts are static values which initialized by 0 until java heap initialization.
 181     // AOT libs are loaded before heap initialized so shift values are not set.
 182     // It is okay since ObjectAlignmentInBytes flag which defines shifts value is set before AOT libs are loaded.
 183     // Set shifts value based on first AOT library config.
 184     if (UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) {
 185       int oop_shift = Universe::narrow_oop_shift();
 186       if (oop_shift == 0) {
 187         Universe::set_narrow_oop_shift(AOTLib::narrow_oop_shift());
 188       } else {
 189         FOR_ALL_AOT_LIBRARIES(lib) {
 190           (*lib)->verify_flag(AOTLib::narrow_oop_shift(), oop_shift, "Universe::narrow_oop_shift");
 191         }
 192       }
 193       if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
 194         int klass_shift = Universe::narrow_klass_shift();


 222 
 223 void AOTLoader::set_narrow_klass_shift() {
 224   // This method could be called from Metaspace::set_narrow_klass_base_and_shift().
 225   // In case it is not called (during dump CDS, for example) the corresponding code in
 226   // AOTLoader::universe_init(), which is called later, will set the shift value.
 227   if (UseAOT && libraries_count() > 0 &&
 228       UseCompressedOops && AOTLib::narrow_oop_shift_initialized() &&
 229       UseCompressedClassPointers) {
 230     int klass_shift = Universe::narrow_klass_shift();
 231     if (klass_shift == 0) {
 232       Universe::set_narrow_klass_shift(AOTLib::narrow_klass_shift());
 233     } else {
 234       FOR_ALL_AOT_LIBRARIES(lib) {
 235         (*lib)->verify_flag(AOTLib::narrow_klass_shift(), klass_shift, "Universe::narrow_klass_shift");
 236       }
 237     }
 238   }
 239 }
 240 
 241 void AOTLoader::load_library(const char* name, bool exit_on_error) {















 242   char ebuf[1024];
 243   void* handle = os::dll_load(name, ebuf, sizeof ebuf);
 244   if (handle == NULL) {
 245     if (exit_on_error) {
 246       tty->print_cr("error opening file: %s", ebuf);
 247       vm_exit(1);
 248     }
 249     return;
 250   }
 251   const int dso_id = libraries_count() + 1;
 252   AOTLib* lib = new AOTLib(handle, name, dso_id);
 253   if (!lib->is_valid()) {
 254     delete lib;
 255     os::dll_unload(handle);
 256     return;
 257   }
 258   add_library(lib);
 259 }
 260 
 261 #ifndef PRODUCT




 129   }
 130   if (UseAOT) {
 131     // EagerInitialization is not compatible with AOT
 132     if (EagerInitialization) {
 133       if (PrintAOT) {
 134         warning("EagerInitialization is not compatible with AOT (switching AOT off)");
 135       }
 136       FLAG_SET_DEFAULT(UseAOT, false);
 137       return;
 138     }
 139 
 140     // -Xint is not compatible with AOT
 141     if (Arguments::is_interpreter_only()) {
 142       if (PrintAOT) {
 143         warning("-Xint is not compatible with AOT (switching AOT off)");
 144       }
 145       FLAG_SET_DEFAULT(UseAOT, false);
 146       return;
 147     }
 148 









 149     // Scan the AOTLibrary option.
 150     if (AOTLibrary != NULL) {
 151       const int len = (int)strlen(AOTLibrary);
 152       char* cp  = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
 153       if (cp != NULL) { // No memory?
 154         memcpy(cp, AOTLibrary, len);
 155         cp[len] = '\0';
 156         char* end = cp + len;
 157         while (cp < end) {
 158           const char* name = cp;
 159           while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != ':' && (*cp) != ';')  cp++;
 160           cp[0] = '\0';  // Terminate name
 161           cp++;
 162           load_library(name, true);
 163         }
 164       }
 165     }
 166 
 167     // Load well-know AOT libraries from Java installation directory.
 168     const char* home = Arguments::get_java_home();
 169     const char* file_separator = os::file_separator();
 170 
 171     for (int i = 0; i < (int) (sizeof(modules) / sizeof(const char*)); i++) {
 172       char library[JVM_MAXPATHLEN];
 173       jio_snprintf(library, sizeof(library), "%s%slib%slib%s%s%s%s", home, file_separator, file_separator, modules[i], UseCompressedOops ? "-coop" : "", UseG1GC ? "" : "-nong1", os::dll_file_extension());
 174       load_library(library, false);
 175     }
 176   }
 177 }
 178 
 179 void AOTLoader::universe_init() {
 180   if (UseAOT && libraries_count() > 0) {
 181     // Shifts are static values which initialized by 0 until java heap initialization.
 182     // AOT libs are loaded before heap initialized so shift values are not set.
 183     // It is okay since ObjectAlignmentInBytes flag which defines shifts value is set before AOT libs are loaded.
 184     // Set shifts value based on first AOT library config.
 185     if (UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) {
 186       int oop_shift = Universe::narrow_oop_shift();
 187       if (oop_shift == 0) {
 188         Universe::set_narrow_oop_shift(AOTLib::narrow_oop_shift());
 189       } else {
 190         FOR_ALL_AOT_LIBRARIES(lib) {
 191           (*lib)->verify_flag(AOTLib::narrow_oop_shift(), oop_shift, "Universe::narrow_oop_shift");
 192         }
 193       }
 194       if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
 195         int klass_shift = Universe::narrow_klass_shift();


 223 
 224 void AOTLoader::set_narrow_klass_shift() {
 225   // This method could be called from Metaspace::set_narrow_klass_base_and_shift().
 226   // In case it is not called (during dump CDS, for example) the corresponding code in
 227   // AOTLoader::universe_init(), which is called later, will set the shift value.
 228   if (UseAOT && libraries_count() > 0 &&
 229       UseCompressedOops && AOTLib::narrow_oop_shift_initialized() &&
 230       UseCompressedClassPointers) {
 231     int klass_shift = Universe::narrow_klass_shift();
 232     if (klass_shift == 0) {
 233       Universe::set_narrow_klass_shift(AOTLib::narrow_klass_shift());
 234     } else {
 235       FOR_ALL_AOT_LIBRARIES(lib) {
 236         (*lib)->verify_flag(AOTLib::narrow_klass_shift(), klass_shift, "Universe::narrow_klass_shift");
 237       }
 238     }
 239   }
 240 }
 241 
 242 void AOTLoader::load_library(const char* name, bool exit_on_error) {
 243   // Skip library if a library with the same name is already loaded.
 244   const int file_separator = *os::file_separator();
 245   const char* start = strrchr(name, file_separator);
 246   const char* new_name = (start == NULL) ? name : (start + 1); 
 247   FOR_ALL_AOT_LIBRARIES(lib) {
 248     const char* lib_name = (*lib)->name();
 249     start = strrchr(lib_name, file_separator);
 250     const char* old_name = (start == NULL) ? lib_name : (start + 1);
 251     if (strcmp(old_name, new_name) == 0) {
 252       if (PrintAOT) {
 253         warning("AOT library %s is already loaded as %s.", name, lib_name);
 254       }
 255       return;
 256     }
 257   }
 258   char ebuf[1024];
 259   void* handle = os::dll_load(name, ebuf, sizeof ebuf);
 260   if (handle == NULL) {
 261     if (exit_on_error) {
 262       tty->print_cr("error opening file: %s", ebuf);
 263       vm_exit(1);
 264     }
 265     return;
 266   }
 267   const int dso_id = libraries_count() + 1;
 268   AOTLib* lib = new AOTLib(handle, name, dso_id);
 269   if (!lib->is_valid()) {
 270     delete lib;
 271     os::dll_unload(handle);
 272     return;
 273   }
 274   add_library(lib);
 275 }
 276 
 277 #ifndef PRODUCT


src/hotspot/share/aot/aotLoader.cpp
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File