4190 size_t default_reserve_size = os::win32::default_stack_size();
4191 size_t actual_reserve_size = stack_commit_size;
4192 if (stack_commit_size < default_reserve_size) {
4193 // If stack_commit_size == 0, we want this too
4194 actual_reserve_size = default_reserve_size;
4195 }
4196
4197 // Check minimum allowable stack size for thread creation and to initialize
4198 // the java system classes, including StackOverflowError - depends on page
4199 // size. Add two 4K pages for compiler2 recursion in main thread.
4200 // Add in 4*BytesPerWord 4K pages to account for VM stack during
4201 // class initialization depending on 32 or 64 bit VM.
4202 size_t min_stack_allowed =
4203 (size_t)(JavaThread::stack_guard_zone_size() +
4204 JavaThread::stack_shadow_zone_size() +
4205 (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K);
4206
4207 min_stack_allowed = align_size_up(min_stack_allowed, os::vm_page_size());
4208
4209 if (actual_reserve_size < min_stack_allowed) {
4210 tty->print_cr("\nThe stack size specified is too small, "
4211 "Specify at least %dk",
4212 min_stack_allowed / K);
4213 return JNI_ERR;
4214 }
4215
4216 JavaThread::set_stack_size_at_create(stack_commit_size);
4217
4218 // Calculate theoretical max. size of Threads to guard gainst artifical
4219 // out-of-memory situations, where all available address-space has been
4220 // reserved by thread stacks.
4221 assert(actual_reserve_size != 0, "Must have a stack");
4222
4223 // Calculate the thread limit when we should start doing Virtual Memory
4224 // banging. Currently when the threads will have used all but 200Mb of space.
4225 //
4226 // TODO: consider performing a similar calculation for commit size instead
4227 // as reserve size, since on a 64-bit platform we'll run into that more
4228 // often than running out of virtual memory space. We can use the
4229 // lower value of the two calculations as the os_thread_limit.
4230 size_t max_address_space = ((size_t)1 << (BitsPerWord - 1)) - (200 * K * K);
|
4190 size_t default_reserve_size = os::win32::default_stack_size();
4191 size_t actual_reserve_size = stack_commit_size;
4192 if (stack_commit_size < default_reserve_size) {
4193 // If stack_commit_size == 0, we want this too
4194 actual_reserve_size = default_reserve_size;
4195 }
4196
4197 // Check minimum allowable stack size for thread creation and to initialize
4198 // the java system classes, including StackOverflowError - depends on page
4199 // size. Add two 4K pages for compiler2 recursion in main thread.
4200 // Add in 4*BytesPerWord 4K pages to account for VM stack during
4201 // class initialization depending on 32 or 64 bit VM.
4202 size_t min_stack_allowed =
4203 (size_t)(JavaThread::stack_guard_zone_size() +
4204 JavaThread::stack_shadow_zone_size() +
4205 (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K);
4206
4207 min_stack_allowed = align_size_up(min_stack_allowed, os::vm_page_size());
4208
4209 if (actual_reserve_size < min_stack_allowed) {
4210 tty->print_cr("\nThe Java thread stack size specified is too small. "
4211 "Specify at least %dk",
4212 min_stack_allowed / K);
4213 return JNI_ERR;
4214 }
4215
4216 JavaThread::set_stack_size_at_create(stack_commit_size);
4217
4218 // Calculate theoretical max. size of Threads to guard gainst artifical
4219 // out-of-memory situations, where all available address-space has been
4220 // reserved by thread stacks.
4221 assert(actual_reserve_size != 0, "Must have a stack");
4222
4223 // Calculate the thread limit when we should start doing Virtual Memory
4224 // banging. Currently when the threads will have used all but 200Mb of space.
4225 //
4226 // TODO: consider performing a similar calculation for commit size instead
4227 // as reserve size, since on a 64-bit platform we'll run into that more
4228 // often than running out of virtual memory space. We can use the
4229 // lower value of the two calculations as the os_thread_limit.
4230 size_t max_address_space = ((size_t)1 << (BitsPerWord - 1)) - (200 * K * K);
|