hotspot/src/os/posix/vm/os_posix.cpp
changeset 46346 4085295dcf51
parent 46331 e3017116b9e5
child 46451 a4a8613c08e9
equal deleted inserted replaced
46345:a5c7cfdd44e4 46346:4085295dcf51
  1156 // platform (os/cpu) dependent constant.
  1156 // platform (os/cpu) dependent constant.
  1157 // To this, space for guard mechanisms is added, which depends on the
  1157 // To this, space for guard mechanisms is added, which depends on the
  1158 // page size which again depends on the concrete system the VM is running
  1158 // page size which again depends on the concrete system the VM is running
  1159 // on. Space for libc guard pages is not included in this size.
  1159 // on. Space for libc guard pages is not included in this size.
  1160 jint os::Posix::set_minimum_stack_sizes() {
  1160 jint os::Posix::set_minimum_stack_sizes() {
       
  1161   size_t os_min_stack_allowed = SOLARIS_ONLY(thr_min_stack()) NOT_SOLARIS(PTHREAD_STACK_MIN);
       
  1162 
  1161   _java_thread_min_stack_allowed = _java_thread_min_stack_allowed +
  1163   _java_thread_min_stack_allowed = _java_thread_min_stack_allowed +
  1162                                    JavaThread::stack_guard_zone_size() +
  1164                                    JavaThread::stack_guard_zone_size() +
  1163                                    JavaThread::stack_shadow_zone_size();
  1165                                    JavaThread::stack_shadow_zone_size();
  1164 
  1166 
  1165   _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
  1167   _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size());
       
  1168   _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed, os_min_stack_allowed);
  1166 
  1169 
  1167   size_t stack_size_in_bytes = ThreadStackSize * K;
  1170   size_t stack_size_in_bytes = ThreadStackSize * K;
  1168   if (stack_size_in_bytes != 0 &&
  1171   if (stack_size_in_bytes != 0 &&
  1169       stack_size_in_bytes < _java_thread_min_stack_allowed) {
  1172       stack_size_in_bytes < _java_thread_min_stack_allowed) {
  1170     // The '-Xss' and '-XX:ThreadStackSize=N' options both set
  1173     // The '-Xss' and '-XX:ThreadStackSize=N' options both set
  1184   _compiler_thread_min_stack_allowed = _compiler_thread_min_stack_allowed +
  1187   _compiler_thread_min_stack_allowed = _compiler_thread_min_stack_allowed +
  1185                                        JavaThread::stack_guard_zone_size() +
  1188                                        JavaThread::stack_guard_zone_size() +
  1186                                        JavaThread::stack_shadow_zone_size();
  1189                                        JavaThread::stack_shadow_zone_size();
  1187 
  1190 
  1188   _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size());
  1191   _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size());
       
  1192   _compiler_thread_min_stack_allowed = MAX2(_compiler_thread_min_stack_allowed, os_min_stack_allowed);
  1189 
  1193 
  1190   stack_size_in_bytes = CompilerThreadStackSize * K;
  1194   stack_size_in_bytes = CompilerThreadStackSize * K;
  1191   if (stack_size_in_bytes != 0 &&
  1195   if (stack_size_in_bytes != 0 &&
  1192       stack_size_in_bytes < _compiler_thread_min_stack_allowed) {
  1196       stack_size_in_bytes < _compiler_thread_min_stack_allowed) {
  1193     tty->print_cr("\nThe CompilerThreadStackSize specified is too small. "
  1197     tty->print_cr("\nThe CompilerThreadStackSize specified is too small. "
  1195                   _compiler_thread_min_stack_allowed / K);
  1199                   _compiler_thread_min_stack_allowed / K);
  1196     return JNI_ERR;
  1200     return JNI_ERR;
  1197   }
  1201   }
  1198 
  1202 
  1199   _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size());
  1203   _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size());
       
  1204   _vm_internal_thread_min_stack_allowed = MAX2(_vm_internal_thread_min_stack_allowed, os_min_stack_allowed);
  1200 
  1205 
  1201   stack_size_in_bytes = VMThreadStackSize * K;
  1206   stack_size_in_bytes = VMThreadStackSize * K;
  1202   if (stack_size_in_bytes != 0 &&
  1207   if (stack_size_in_bytes != 0 &&
  1203       stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) {
  1208       stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) {
  1204     tty->print_cr("\nThe VMThreadStackSize specified is too small. "
  1209     tty->print_cr("\nThe VMThreadStackSize specified is too small. "
  1248     }
  1253     }
  1249 
  1254 
  1250     stack_size = MAX2(stack_size,
  1255     stack_size = MAX2(stack_size,
  1251                       _vm_internal_thread_min_stack_allowed);
  1256                       _vm_internal_thread_min_stack_allowed);
  1252     break;
  1257     break;
       
  1258   }
       
  1259 
       
  1260   // pthread_attr_setstacksize() may require that the size be rounded up to the OS page size.
       
  1261   // Be careful not to round up to 0. Align down in that case.
       
  1262   if (stack_size <= SIZE_MAX - vm_page_size()) {
       
  1263     stack_size = align_size_up(stack_size, vm_page_size());
       
  1264   } else {
       
  1265     stack_size = align_size_down(stack_size, vm_page_size());
  1253   }
  1266   }
  1254 
  1267 
  1255   return stack_size;
  1268   return stack_size;
  1256 }
  1269 }
  1257 
  1270