hotspot/src/os/solaris/vm/os_solaris.cpp
changeset 6176 4d9030fe341f
parent 5922 883ecb03d008
child 6962 d49132ce025b
equal deleted inserted replaced
6175:86dbf3cacacc 6176:4d9030fe341f
  1837   // Copied from libhpi
  1837   // Copied from libhpi
  1838   const size_t pnamelen = pname ? strlen(pname) : 0;
  1838   const size_t pnamelen = pname ? strlen(pname) : 0;
  1839 
  1839 
  1840   // Quietly truncate on buffer overflow.  Should be an error.
  1840   // Quietly truncate on buffer overflow.  Should be an error.
  1841   if (pnamelen + strlen(fname) + 10 > (size_t) buflen) {
  1841   if (pnamelen + strlen(fname) + 10 > (size_t) buflen) {
  1842       *buffer = '\0';
  1842     *buffer = '\0';
  1843       return;
  1843     return;
  1844   }
  1844   }
  1845 
  1845 
  1846   if (pnamelen == 0) {
  1846   if (pnamelen == 0) {
  1847     snprintf(buffer, buflen, "lib%s.so", fname);
  1847     snprintf(buffer, buflen, "lib%s.so", fname);
  1848   } else if (strchr(pname, *os::path_separator()) != NULL) {
  1848   } else if (strchr(pname, *os::path_separator()) != NULL) {
  2049     {EM_X86_64,      EM_X86_64,  ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"},
  2049     {EM_X86_64,      EM_X86_64,  ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"},
  2050     {EM_SPARC,       EM_SPARC,   ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
  2050     {EM_SPARC,       EM_SPARC,   ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
  2051     {EM_SPARC32PLUS, EM_SPARC,   ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
  2051     {EM_SPARC32PLUS, EM_SPARC,   ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
  2052     {EM_SPARCV9,     EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"},
  2052     {EM_SPARCV9,     EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"},
  2053     {EM_PPC,         EM_PPC,     ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"},
  2053     {EM_PPC,         EM_PPC,     ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"},
  2054     {EM_PPC64,       EM_PPC64,   ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"}
  2054     {EM_PPC64,       EM_PPC64,   ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"},
       
  2055     {EM_ARM,         EM_ARM,     ELFCLASS32, ELFDATA2LSB, (char*)"ARM 32"}
  2055   };
  2056   };
  2056 
  2057 
  2057   #if  (defined IA32)
  2058   #if  (defined IA32)
  2058     static  Elf32_Half running_arch_code=EM_386;
  2059     static  Elf32_Half running_arch_code=EM_386;
  2059   #elif   (defined AMD64)
  2060   #elif   (defined AMD64)
  2066     static  Elf32_Half running_arch_code=EM_SPARC;
  2067     static  Elf32_Half running_arch_code=EM_SPARC;
  2067   #elif  (defined __powerpc64__)
  2068   #elif  (defined __powerpc64__)
  2068     static  Elf32_Half running_arch_code=EM_PPC64;
  2069     static  Elf32_Half running_arch_code=EM_PPC64;
  2069   #elif  (defined __powerpc__)
  2070   #elif  (defined __powerpc__)
  2070     static  Elf32_Half running_arch_code=EM_PPC;
  2071     static  Elf32_Half running_arch_code=EM_PPC;
       
  2072   #elif (defined ARM)
       
  2073     static  Elf32_Half running_arch_code=EM_ARM;
  2071   #else
  2074   #else
  2072     #error Method os::dll_load requires that one of following is defined:\
  2075     #error Method os::dll_load requires that one of following is defined:\
  2073          IA32, AMD64, IA64, __sparc, __powerpc__
  2076          IA32, AMD64, IA64, __sparc, __powerpc__, ARM, ARM
  2074   #endif
  2077   #endif
  2075 
  2078 
  2076   // Identify compatability class for VM's architecture and library's architecture
  2079   // Identify compatability class for VM's architecture and library's architecture
  2077   // Obtain string descriptions for architectures
  2080   // Obtain string descriptions for architectures
  2078 
  2081 
  3147 
  3150 
  3148   // Don't bother to probe page size because getpagesizes() comes with MPSS.
  3151   // Don't bother to probe page size because getpagesizes() comes with MPSS.
  3149   // ISM is only recommended on old Solaris where there is no MPSS support.
  3152   // ISM is only recommended on old Solaris where there is no MPSS support.
  3150   // Simply choose a conservative value as default.
  3153   // Simply choose a conservative value as default.
  3151   *page_size = LargePageSizeInBytes ? LargePageSizeInBytes :
  3154   *page_size = LargePageSizeInBytes ? LargePageSizeInBytes :
  3152                SPARC_ONLY(4 * M) IA32_ONLY(4 * M) AMD64_ONLY(2 * M);
  3155                SPARC_ONLY(4 * M) IA32_ONLY(4 * M) AMD64_ONLY(2 * M)
       
  3156                ARM_ONLY(2 * M);
  3153 
  3157 
  3154   // ISM is available on all supported Solaris versions
  3158   // ISM is available on all supported Solaris versions
  3155   return true;
  3159   return true;
  3156 }
  3160 }
  3157 
  3161 
  5005   init_pset_getloadavg_ptr();
  5009   init_pset_getloadavg_ptr();
  5006 
  5010 
  5007   return JNI_OK;
  5011   return JNI_OK;
  5008 }
  5012 }
  5009 
  5013 
       
  5014 void os::init_3(void) {
       
  5015   return;
       
  5016 }
  5010 
  5017 
  5011 // Mark the polling page as unreadable
  5018 // Mark the polling page as unreadable
  5012 void os::make_polling_page_unreadable(void) {
  5019 void os::make_polling_page_unreadable(void) {
  5013   if( mprotect((char *)_polling_page, page_size, PROT_NONE) != 0 )
  5020   if( mprotect((char *)_polling_page, page_size, PROT_NONE) != 0 )
  5014     fatal("Could not disable polling page");
  5021     fatal("Could not disable polling page");
  5410     return ::getloadavg(loadavg, nelem);
  5417     return ::getloadavg(loadavg, nelem);
  5411   }
  5418   }
  5412 }
  5419 }
  5413 
  5420 
  5414 //---------------------------------------------------------------------------------
  5421 //---------------------------------------------------------------------------------
  5415 #ifndef PRODUCT
       
  5416 
  5422 
  5417 static address same_page(address x, address y) {
  5423 static address same_page(address x, address y) {
  5418   intptr_t page_bits = -os::vm_page_size();
  5424   intptr_t page_bits = -os::vm_page_size();
  5419   if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
  5425   if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
  5420     return x;
  5426     return x;
  5422     return (address)(intptr_t(y) | ~page_bits) + 1;
  5428     return (address)(intptr_t(y) | ~page_bits) + 1;
  5423   else
  5429   else
  5424     return (address)(intptr_t(y) & page_bits);
  5430     return (address)(intptr_t(y) & page_bits);
  5425 }
  5431 }
  5426 
  5432 
  5427 bool os::find(address addr) {
  5433 bool os::find(address addr, outputStream* st) {
  5428   Dl_info dlinfo;
  5434   Dl_info dlinfo;
  5429   memset(&dlinfo, 0, sizeof(dlinfo));
  5435   memset(&dlinfo, 0, sizeof(dlinfo));
  5430   if (dladdr(addr, &dlinfo)) {
  5436   if (dladdr(addr, &dlinfo)) {
  5431 #ifdef _LP64
  5437 #ifdef _LP64
  5432     tty->print("0x%016lx: ", addr);
  5438     st->print("0x%016lx: ", addr);
  5433 #else
  5439 #else
  5434     tty->print("0x%08x: ", addr);
  5440     st->print("0x%08x: ", addr);
  5435 #endif
  5441 #endif
  5436     if (dlinfo.dli_sname != NULL)
  5442     if (dlinfo.dli_sname != NULL)
  5437       tty->print("%s+%#lx", dlinfo.dli_sname, addr-(intptr_t)dlinfo.dli_saddr);
  5443       st->print("%s+%#lx", dlinfo.dli_sname, addr-(intptr_t)dlinfo.dli_saddr);
  5438     else if (dlinfo.dli_fname)
  5444     else if (dlinfo.dli_fname)
  5439       tty->print("<offset %#lx>", addr-(intptr_t)dlinfo.dli_fbase);
  5445       st->print("<offset %#lx>", addr-(intptr_t)dlinfo.dli_fbase);
  5440     else
  5446     else
  5441       tty->print("<absolute address>");
  5447       st->print("<absolute address>");
  5442     if (dlinfo.dli_fname)  tty->print(" in %s", dlinfo.dli_fname);
  5448     if (dlinfo.dli_fname)  st->print(" in %s", dlinfo.dli_fname);
  5443 #ifdef _LP64
  5449 #ifdef _LP64
  5444     if (dlinfo.dli_fbase)  tty->print(" at 0x%016lx", dlinfo.dli_fbase);
  5450     if (dlinfo.dli_fbase)  st->print(" at 0x%016lx", dlinfo.dli_fbase);
  5445 #else
  5451 #else
  5446     if (dlinfo.dli_fbase)  tty->print(" at 0x%08x", dlinfo.dli_fbase);
  5452     if (dlinfo.dli_fbase)  st->print(" at 0x%08x", dlinfo.dli_fbase);
  5447 #endif
  5453 #endif
  5448     tty->cr();
  5454     st->cr();
  5449 
  5455 
  5450     if (Verbose) {
  5456     if (Verbose) {
  5451       // decode some bytes around the PC
  5457       // decode some bytes around the PC
  5452       address begin = same_page(addr-40, addr);
  5458       address begin = same_page(addr-40, addr);
  5453       address end   = same_page(addr+40, addr);
  5459       address end   = same_page(addr+40, addr);
  5456       if (begin < lowest)  begin = lowest;
  5462       if (begin < lowest)  begin = lowest;
  5457       Dl_info dlinfo2;
  5463       Dl_info dlinfo2;
  5458       if (dladdr(end, &dlinfo2) && dlinfo2.dli_saddr != dlinfo.dli_saddr
  5464       if (dladdr(end, &dlinfo2) && dlinfo2.dli_saddr != dlinfo.dli_saddr
  5459           && end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin)
  5465           && end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin)
  5460         end = (address) dlinfo2.dli_saddr;
  5466         end = (address) dlinfo2.dli_saddr;
  5461       Disassembler::decode(begin, end);
  5467       Disassembler::decode(begin, end, st);
  5462     }
  5468     }
  5463     return true;
  5469     return true;
  5464   }
  5470   }
  5465   return false;
  5471   return false;
  5466 }
  5472 }
  5467 
       
  5468 #endif
       
  5469 
       
  5470 
  5473 
  5471 // Following function has been added to support HotSparc's libjvm.so running
  5474 // Following function has been added to support HotSparc's libjvm.so running
  5472 // under Solaris production JDK 1.2.2 / 1.3.0.  These came from
  5475 // under Solaris production JDK 1.2.2 / 1.3.0.  These came from
  5473 // src/solaris/hpi/native_threads in the EVM codebase.
  5476 // src/solaris/hpi/native_threads in the EVM codebase.
  5474 //
  5477 //
  5908 
  5911 
  5909   // If externally suspended while waiting, re-suspend
  5912   // If externally suspended while waiting, re-suspend
  5910   if (jt->handle_special_suspend_equivalent_condition()) {
  5913   if (jt->handle_special_suspend_equivalent_condition()) {
  5911     jt->java_suspend_self();
  5914     jt->java_suspend_self();
  5912   }
  5915   }
  5913 
       
  5914   OrderAccess::fence();
  5916   OrderAccess::fence();
  5915 }
  5917 }
  5916 
  5918 
  5917 void Parker::unpark() {
  5919 void Parker::unpark() {
  5918   int s, status ;
  5920   int s, status ;
  5995        // Unknown exit code; pass it through
  5997        // Unknown exit code; pass it through
  5996        return status;
  5998        return status;
  5997     }
  5999     }
  5998   }
  6000   }
  5999 }
  6001 }
       
  6002 
       
  6003 // is_headless_jre()
       
  6004 //
       
  6005 // Test for the existence of libmawt in motif21 or xawt directories
       
  6006 // in order to report if we are running in a headless jre
       
  6007 //
       
  6008 bool os::is_headless_jre() {
       
  6009     struct stat statbuf;
       
  6010     char buf[MAXPATHLEN];
       
  6011     char libmawtpath[MAXPATHLEN];
       
  6012     const char *xawtstr  = "/xawt/libmawt.so";
       
  6013     const char *motifstr = "/motif21/libmawt.so";
       
  6014     char *p;
       
  6015 
       
  6016     // Get path to libjvm.so
       
  6017     os::jvm_path(buf, sizeof(buf));
       
  6018 
       
  6019     // Get rid of libjvm.so
       
  6020     p = strrchr(buf, '/');
       
  6021     if (p == NULL) return false;
       
  6022     else *p = '\0';
       
  6023 
       
  6024     // Get rid of client or server
       
  6025     p = strrchr(buf, '/');
       
  6026     if (p == NULL) return false;
       
  6027     else *p = '\0';
       
  6028 
       
  6029     // check xawt/libmawt.so
       
  6030     strcpy(libmawtpath, buf);
       
  6031     strcat(libmawtpath, xawtstr);
       
  6032     if (::stat(libmawtpath, &statbuf) == 0) return false;
       
  6033 
       
  6034     // check motif21/libmawt.so
       
  6035     strcpy(libmawtpath, buf);
       
  6036     strcat(libmawtpath, motifstr);
       
  6037     if (::stat(libmawtpath, &statbuf) == 0) return false;
       
  6038 
       
  6039     return true;
       
  6040 }
       
  6041 
       
  6042