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