1116 return &allowdebug_blocked_sigs; |
1116 return &allowdebug_blocked_sigs; |
1117 } |
1117 } |
1118 |
1118 |
1119 |
1119 |
1120 void _handle_uncaught_cxx_exception() { |
1120 void _handle_uncaught_cxx_exception() { |
1121 VMError err("An uncaught C++ exception"); |
1121 VMError::report_and_die("An uncaught C++ exception"); |
1122 err.report_and_die(); |
|
1123 } |
1122 } |
1124 |
1123 |
1125 |
1124 |
1126 // First crack at OS-specific initialization, from inside the new thread. |
1125 // First crack at OS-specific initialization, from inside the new thread. |
1127 void os::initialize_thread(Thread* thr) { |
1126 void os::initialize_thread(Thread* thr) { |
1328 |
1327 |
1329 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis |
1328 // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis |
1330 jlong os::javaTimeMillis() { |
1329 jlong os::javaTimeMillis() { |
1331 timeval t; |
1330 timeval t; |
1332 if (gettimeofday(&t, NULL) == -1) { |
1331 if (gettimeofday(&t, NULL) == -1) { |
1333 fatal(err_msg("os::javaTimeMillis: gettimeofday (%s)", strerror(errno))); |
1332 fatal("os::javaTimeMillis: gettimeofday (%s)", strerror(errno)); |
1334 } |
1333 } |
1335 return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000; |
1334 return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000; |
1336 } |
1335 } |
1337 |
1336 |
1338 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) { |
1337 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) { |
1339 timeval t; |
1338 timeval t; |
1340 if (gettimeofday(&t, NULL) == -1) { |
1339 if (gettimeofday(&t, NULL) == -1) { |
1341 fatal(err_msg("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno))); |
1340 fatal("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno)); |
1342 } |
1341 } |
1343 seconds = jlong(t.tv_sec); |
1342 seconds = jlong(t.tv_sec); |
1344 nanos = jlong(t.tv_usec) * 1000; |
1343 nanos = jlong(t.tv_usec) * 1000; |
1345 } |
1344 } |
1346 |
1345 |
2390 assert(mesg != NULL, "mesg must be specified"); |
2389 assert(mesg != NULL, "mesg must be specified"); |
2391 int err = os::Solaris::commit_memory_impl(addr, bytes, exec); |
2390 int err = os::Solaris::commit_memory_impl(addr, bytes, exec); |
2392 if (err != 0) { |
2391 if (err != 0) { |
2393 // the caller wants all commit errors to exit with the specified mesg: |
2392 // the caller wants all commit errors to exit with the specified mesg: |
2394 warn_fail_commit_memory(addr, bytes, exec, err); |
2393 warn_fail_commit_memory(addr, bytes, exec, err); |
2395 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, mesg); |
2394 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg); |
2396 } |
2395 } |
2397 } |
2396 } |
2398 |
2397 |
2399 size_t os::Solaris::page_size_for_alignment(size_t alignment) { |
2398 size_t os::Solaris::page_size_for_alignment(size_t alignment) { |
2400 assert(is_size_aligned(alignment, (size_t) vm_page_size()), |
2399 assert(is_size_aligned(alignment, (size_t) vm_page_size()), |
2401 err_msg(SIZE_FORMAT " is not aligned to " SIZE_FORMAT, |
2400 SIZE_FORMAT " is not aligned to " SIZE_FORMAT, |
2402 alignment, (size_t) vm_page_size())); |
2401 alignment, (size_t) vm_page_size()); |
2403 |
2402 |
2404 for (int i = 0; _page_sizes[i] != 0; i++) { |
2403 for (int i = 0; _page_sizes[i] != 0; i++) { |
2405 if (is_size_aligned(alignment, _page_sizes[i])) { |
2404 if (is_size_aligned(alignment, _page_sizes[i])) { |
2406 return _page_sizes[i]; |
2405 return _page_sizes[i]; |
2407 } |
2406 } |
2413 int os::Solaris::commit_memory_impl(char* addr, size_t bytes, |
2412 int os::Solaris::commit_memory_impl(char* addr, size_t bytes, |
2414 size_t alignment_hint, bool exec) { |
2413 size_t alignment_hint, bool exec) { |
2415 int err = Solaris::commit_memory_impl(addr, bytes, exec); |
2414 int err = Solaris::commit_memory_impl(addr, bytes, exec); |
2416 if (err == 0 && UseLargePages && alignment_hint > 0) { |
2415 if (err == 0 && UseLargePages && alignment_hint > 0) { |
2417 assert(is_size_aligned(bytes, alignment_hint), |
2416 assert(is_size_aligned(bytes, alignment_hint), |
2418 err_msg(SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint)); |
2417 SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint); |
2419 |
2418 |
2420 // The syscall memcntl requires an exact page size (see man memcntl for details). |
2419 // The syscall memcntl requires an exact page size (see man memcntl for details). |
2421 size_t page_size = page_size_for_alignment(alignment_hint); |
2420 size_t page_size = page_size_for_alignment(alignment_hint); |
2422 if (page_size > (size_t) vm_page_size()) { |
2421 if (page_size > (size_t) vm_page_size()) { |
2423 (void)Solaris::setup_large_pages(addr, bytes, page_size); |
2422 (void)Solaris::setup_large_pages(addr, bytes, page_size); |
2437 assert(mesg != NULL, "mesg must be specified"); |
2436 assert(mesg != NULL, "mesg must be specified"); |
2438 int err = os::Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec); |
2437 int err = os::Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec); |
2439 if (err != 0) { |
2438 if (err != 0) { |
2440 // the caller wants all commit errors to exit with the specified mesg: |
2439 // the caller wants all commit errors to exit with the specified mesg: |
2441 warn_fail_commit_memory(addr, bytes, alignment_hint, exec, err); |
2440 warn_fail_commit_memory(addr, bytes, alignment_hint, exec, err); |
2442 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, mesg); |
2441 vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg); |
2443 } |
2442 } |
2444 } |
2443 } |
2445 |
2444 |
2446 // Uncommit the pages in a specified region. |
2445 // Uncommit the pages in a specified region. |
2447 void os::pd_free_memory(char* addr, size_t bytes, size_t alignment_hint) { |
2446 void os::pd_free_memory(char* addr, size_t bytes, size_t alignment_hint) { |
2967 } |
2966 } |
2968 return false; |
2967 return false; |
2969 } |
2968 } |
2970 |
2969 |
2971 bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) { |
2970 bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) { |
2972 assert(is_valid_page_size(align), err_msg(SIZE_FORMAT " is not a valid page size", align)); |
2971 assert(is_valid_page_size(align), SIZE_FORMAT " is not a valid page size", align); |
2973 assert(is_ptr_aligned((void*) start, align), |
2972 assert(is_ptr_aligned((void*) start, align), |
2974 err_msg(PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align)); |
2973 PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align); |
2975 assert(is_size_aligned(bytes, align), |
2974 assert(is_size_aligned(bytes, align), |
2976 err_msg(SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align)); |
2975 SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align); |
2977 |
2976 |
2978 // Signal to OS that we want large pages for addresses |
2977 // Signal to OS that we want large pages for addresses |
2979 // from addr, addr + bytes |
2978 // from addr, addr + bytes |
2980 struct memcntl_mha mpss_struct; |
2979 struct memcntl_mha mpss_struct; |
2981 mpss_struct.mha_cmd = MHA_MAPSIZE_VA; |
2980 mpss_struct.mha_cmd = MHA_MAPSIZE_VA; |
3954 vm_exit_during_initialization("Signal chaining not allowed for VM interrupt signal, try -XX:+UseAltSigs."); |
3953 vm_exit_during_initialization("Signal chaining not allowed for VM interrupt signal, try -XX:+UseAltSigs."); |
3955 } |
3954 } |
3956 // libjsig also interposes the sigaction() call below and saves the |
3955 // libjsig also interposes the sigaction() call below and saves the |
3957 // old sigaction on it own. |
3956 // old sigaction on it own. |
3958 } else { |
3957 } else { |
3959 fatal(err_msg("Encountered unexpected pre-existing sigaction handler " |
3958 fatal("Encountered unexpected pre-existing sigaction handler " |
3960 "%#lx for signal %d.", (long)oldhand, sig)); |
3959 "%#lx for signal %d.", (long)oldhand, sig); |
3961 } |
3960 } |
3962 } |
3961 } |
3963 |
3962 |
3964 struct sigaction sigAct; |
3963 struct sigaction sigAct; |
3965 sigfillset(&(sigAct.sa_mask)); |
3964 sigfillset(&(sigAct.sa_mask)); |
4401 |
4400 |
4402 init_random(1234567); |
4401 init_random(1234567); |
4403 |
4402 |
4404 page_size = sysconf(_SC_PAGESIZE); |
4403 page_size = sysconf(_SC_PAGESIZE); |
4405 if (page_size == -1) { |
4404 if (page_size == -1) { |
4406 fatal(err_msg("os_solaris.cpp: os::init: sysconf failed (%s)", |
4405 fatal("os_solaris.cpp: os::init: sysconf failed (%s)", strerror(errno)); |
4407 strerror(errno))); |
|
4408 } |
4406 } |
4409 init_page_sizes((size_t) page_size); |
4407 init_page_sizes((size_t) page_size); |
4410 |
4408 |
4411 Solaris::initialize_system_info(); |
4409 Solaris::initialize_system_info(); |
4412 |
4410 |
4414 // if we need them. |
4412 // if we need them. |
4415 Solaris::misc_sym_init(); |
4413 Solaris::misc_sym_init(); |
4416 |
4414 |
4417 int fd = ::open("/dev/zero", O_RDWR); |
4415 int fd = ::open("/dev/zero", O_RDWR); |
4418 if (fd < 0) { |
4416 if (fd < 0) { |
4419 fatal(err_msg("os::init: cannot open /dev/zero (%s)", strerror(errno))); |
4417 fatal("os::init: cannot open /dev/zero (%s)", strerror(errno)); |
4420 } else { |
4418 } else { |
4421 Solaris::set_dev_zero_fd(fd); |
4419 Solaris::set_dev_zero_fd(fd); |
4422 |
4420 |
4423 // Close on exec, child won't inherit. |
4421 // Close on exec, child won't inherit. |
4424 fcntl(fd, F_SETFD, FD_CLOEXEC); |
4422 fcntl(fd, F_SETFD, FD_CLOEXEC); |