hotspot/src/os/solaris/vm/os_solaris.cpp
changeset 46619 a3919f5e8d2b
parent 46618 d503911aa948
child 46625 edefffab74e2
equal deleted inserted replaced
46618:d503911aa948 46619:a3919f5e8d2b
   233     getrlimit(RLIMIT_STACK, &limits);
   233     getrlimit(RLIMIT_STACK, &limits);
   234     size = adjust_stack_size(os::Solaris::_main_stack_base, (size_t)limits.rlim_cur);
   234     size = adjust_stack_size(os::Solaris::_main_stack_base, (size_t)limits.rlim_cur);
   235   }
   235   }
   236   // base may not be page aligned
   236   // base may not be page aligned
   237   address base = current_stack_base();
   237   address base = current_stack_base();
   238   address bottom = align_ptr_up(base - size, os::vm_page_size());;
   238   address bottom = align_up(base - size, os::vm_page_size());;
   239   return (size_t)(base - bottom);
   239   return (size_t)(base - bottom);
   240 }
   240 }
   241 
   241 
   242 struct tm* os::localtime_pd(const time_t* clock, struct tm*  res) {
   242 struct tm* os::localtime_pd(const time_t* clock, struct tm*  res) {
   243   return localtime_r(clock, res);
   243   return localtime_r(clock, res);
  1120       size_t current_size = current_stack_size();
  1120       size_t current_size = current_stack_size();
  1121       // This should never happen, but just in case....
  1121       // This should never happen, but just in case....
  1122       if (current_size == 0) current_size = 2 * K * K;
  1122       if (current_size == 0) current_size = 2 * K * K;
  1123       stack_size = current_size > (8 * K * K) ? (8 * K * K) : current_size;
  1123       stack_size = current_size > (8 * K * K) ? (8 * K * K) : current_size;
  1124     }
  1124     }
  1125     address bottom = align_ptr_up(base - stack_size, os::vm_page_size());;
  1125     address bottom = align_up(base - stack_size, os::vm_page_size());;
  1126     stack_size = (size_t)(base - bottom);
  1126     stack_size = (size_t)(base - bottom);
  1127 
  1127 
  1128     assert(stack_size > 0, "Stack size calculation problem");
  1128     assert(stack_size > 0, "Stack size calculation problem");
  1129 
  1129 
  1130     if (stack_size > jt->stack_size()) {
  1130     if (stack_size > jt->stack_size()) {
  2329     vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg);
  2329     vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg);
  2330   }
  2330   }
  2331 }
  2331 }
  2332 
  2332 
  2333 size_t os::Solaris::page_size_for_alignment(size_t alignment) {
  2333 size_t os::Solaris::page_size_for_alignment(size_t alignment) {
  2334   assert(is_size_aligned(alignment, (size_t) vm_page_size()),
  2334   assert(is_aligned(alignment, (size_t) vm_page_size()),
  2335          SIZE_FORMAT " is not aligned to " SIZE_FORMAT,
  2335          SIZE_FORMAT " is not aligned to " SIZE_FORMAT,
  2336          alignment, (size_t) vm_page_size());
  2336          alignment, (size_t) vm_page_size());
  2337 
  2337 
  2338   for (int i = 0; _page_sizes[i] != 0; i++) {
  2338   for (int i = 0; _page_sizes[i] != 0; i++) {
  2339     if (is_size_aligned(alignment, _page_sizes[i])) {
  2339     if (is_aligned(alignment, _page_sizes[i])) {
  2340       return _page_sizes[i];
  2340       return _page_sizes[i];
  2341     }
  2341     }
  2342   }
  2342   }
  2343 
  2343 
  2344   return (size_t) vm_page_size();
  2344   return (size_t) vm_page_size();
  2346 
  2346 
  2347 int os::Solaris::commit_memory_impl(char* addr, size_t bytes,
  2347 int os::Solaris::commit_memory_impl(char* addr, size_t bytes,
  2348                                     size_t alignment_hint, bool exec) {
  2348                                     size_t alignment_hint, bool exec) {
  2349   int err = Solaris::commit_memory_impl(addr, bytes, exec);
  2349   int err = Solaris::commit_memory_impl(addr, bytes, exec);
  2350   if (err == 0 && UseLargePages && alignment_hint > 0) {
  2350   if (err == 0 && UseLargePages && alignment_hint > 0) {
  2351     assert(is_size_aligned(bytes, alignment_hint),
  2351     assert(is_aligned(bytes, alignment_hint),
  2352            SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint);
  2352            SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint);
  2353 
  2353 
  2354     // The syscall memcntl requires an exact page size (see man memcntl for details).
  2354     // The syscall memcntl requires an exact page size (see man memcntl for details).
  2355     size_t page_size = page_size_for_alignment(alignment_hint);
  2355     size_t page_size = page_size_for_alignment(alignment_hint);
  2356     if (page_size > (size_t) vm_page_size()) {
  2356     if (page_size > (size_t) vm_page_size()) {
  2763   size_t size = bytes;
  2763   size_t size = bytes;
  2764   return munmap(addr, size) == 0;
  2764   return munmap(addr, size) == 0;
  2765 }
  2765 }
  2766 
  2766 
  2767 static bool solaris_mprotect(char* addr, size_t bytes, int prot) {
  2767 static bool solaris_mprotect(char* addr, size_t bytes, int prot) {
  2768   assert(addr == (char*)align_size_down((uintptr_t)addr, os::vm_page_size()),
  2768   assert(addr == (char*)align_down((uintptr_t)addr, os::vm_page_size()),
  2769          "addr must be page aligned");
  2769          "addr must be page aligned");
  2770   int retVal = mprotect(addr, bytes, prot);
  2770   int retVal = mprotect(addr, bytes, prot);
  2771   return retVal == 0;
  2771   return retVal == 0;
  2772 }
  2772 }
  2773 
  2773 
  2900   return false;
  2900   return false;
  2901 }
  2901 }
  2902 
  2902 
  2903 bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
  2903 bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
  2904   assert(is_valid_page_size(align), SIZE_FORMAT " is not a valid page size", align);
  2904   assert(is_valid_page_size(align), SIZE_FORMAT " is not a valid page size", align);
  2905   assert(is_ptr_aligned((void*) start, align),
  2905   assert(is_aligned((void*) start, align),
  2906          PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align);
  2906          PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align);
  2907   assert(is_size_aligned(bytes, align),
  2907   assert(is_aligned(bytes, align),
  2908          SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align);
  2908          SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align);
  2909 
  2909 
  2910   // Signal to OS that we want large pages for addresses
  2910   // Signal to OS that we want large pages for addresses
  2911   // from addr, addr + bytes
  2911   // from addr, addr + bytes
  2912   struct memcntl_mha mpss_struct;
  2912   struct memcntl_mha mpss_struct;