2174
2175 thread->java_suspend_self();
2176 }
2177 } while (threadIsSuspended);
2178 }
2179 }
2180
2181 int os::signal_lookup() {
2182 return check_pending_signals(false);
2183 }
2184
2185 int os::signal_wait() {
2186 return check_pending_signals(true);
2187 }
2188
2189 ////////////////////////////////////////////////////////////////////////////////
2190 // Virtual Memory
2191
2192 static int page_size = -1;
2193
2194 // The mmap MAP_ALIGN flag is supported on Solaris 9 and later. init_2() will
2195 // clear this var if support is not available.
2196 static bool has_map_align = true;
2197
2198 int os::vm_page_size() {
2199 assert(page_size != -1, "must call os::init");
2200 return page_size;
2201 }
2202
2203 // Solaris allocates memory by pages.
2204 int os::vm_allocation_granularity() {
2205 assert(page_size != -1, "must call os::init");
2206 return page_size;
2207 }
2208
2209 static bool recoverable_mmap_error(int err) {
2210 // See if the error is one we can let the caller handle. This
2211 // list of errno values comes from the Solaris mmap(2) man page.
2212 switch (err) {
2213 case EBADF:
2214 case EINVAL:
2215 case ENOTSUP:
2216 // let the caller deal with these errors
2217 return true;
2544
2545 char* os::Solaris::mmap_chunk(char *addr, size_t size, int flags, int prot) {
2546 char *b = (char *)mmap(addr, size, prot, flags, os::Solaris::_dev_zero_fd, 0);
2547
2548 if (b == MAP_FAILED) {
2549 return NULL;
2550 }
2551 return b;
2552 }
2553
2554 char* os::Solaris::anon_mmap(char* requested_addr, size_t bytes,
2555 size_t alignment_hint, bool fixed) {
2556 char* addr = requested_addr;
2557 int flags = MAP_PRIVATE | MAP_NORESERVE;
2558
2559 assert(!(fixed && (alignment_hint > 0)),
2560 "alignment hint meaningless with fixed mmap");
2561
2562 if (fixed) {
2563 flags |= MAP_FIXED;
2564 } else if (has_map_align && (alignment_hint > (size_t) vm_page_size())) {
2565 flags |= MAP_ALIGN;
2566 addr = (char*) alignment_hint;
2567 }
2568
2569 // Map uncommitted pages PROT_NONE so we fail early if we touch an
2570 // uncommitted page. Otherwise, the read/write might succeed if we
2571 // have enough swap space to back the physical page.
2572 return mmap_chunk(addr, bytes, flags, PROT_NONE);
2573 }
2574
2575 char* os::pd_reserve_memory(size_t bytes, char* requested_addr,
2576 size_t alignment_hint) {
2577 char* addr = Solaris::anon_mmap(requested_addr, bytes, alignment_hint,
2578 (requested_addr != NULL));
2579
2580 guarantee(requested_addr == NULL || requested_addr == addr,
2581 "OS failed to return requested mmap address.");
2582 return addr;
2583 }
2584
|
2174
2175 thread->java_suspend_self();
2176 }
2177 } while (threadIsSuspended);
2178 }
2179 }
2180
2181 int os::signal_lookup() {
2182 return check_pending_signals(false);
2183 }
2184
2185 int os::signal_wait() {
2186 return check_pending_signals(true);
2187 }
2188
2189 ////////////////////////////////////////////////////////////////////////////////
2190 // Virtual Memory
2191
2192 static int page_size = -1;
2193
2194 int os::vm_page_size() {
2195 assert(page_size != -1, "must call os::init");
2196 return page_size;
2197 }
2198
2199 // Solaris allocates memory by pages.
2200 int os::vm_allocation_granularity() {
2201 assert(page_size != -1, "must call os::init");
2202 return page_size;
2203 }
2204
2205 static bool recoverable_mmap_error(int err) {
2206 // See if the error is one we can let the caller handle. This
2207 // list of errno values comes from the Solaris mmap(2) man page.
2208 switch (err) {
2209 case EBADF:
2210 case EINVAL:
2211 case ENOTSUP:
2212 // let the caller deal with these errors
2213 return true;
2540
2541 char* os::Solaris::mmap_chunk(char *addr, size_t size, int flags, int prot) {
2542 char *b = (char *)mmap(addr, size, prot, flags, os::Solaris::_dev_zero_fd, 0);
2543
2544 if (b == MAP_FAILED) {
2545 return NULL;
2546 }
2547 return b;
2548 }
2549
2550 char* os::Solaris::anon_mmap(char* requested_addr, size_t bytes,
2551 size_t alignment_hint, bool fixed) {
2552 char* addr = requested_addr;
2553 int flags = MAP_PRIVATE | MAP_NORESERVE;
2554
2555 assert(!(fixed && (alignment_hint > 0)),
2556 "alignment hint meaningless with fixed mmap");
2557
2558 if (fixed) {
2559 flags |= MAP_FIXED;
2560 } else if (alignment_hint > (size_t) vm_page_size()) {
2561 flags |= MAP_ALIGN;
2562 addr = (char*) alignment_hint;
2563 }
2564
2565 // Map uncommitted pages PROT_NONE so we fail early if we touch an
2566 // uncommitted page. Otherwise, the read/write might succeed if we
2567 // have enough swap space to back the physical page.
2568 return mmap_chunk(addr, bytes, flags, PROT_NONE);
2569 }
2570
2571 char* os::pd_reserve_memory(size_t bytes, char* requested_addr,
2572 size_t alignment_hint) {
2573 char* addr = Solaris::anon_mmap(requested_addr, bytes, alignment_hint,
2574 (requested_addr != NULL));
2575
2576 guarantee(requested_addr == NULL || requested_addr == addr,
2577 "OS failed to return requested mmap address.");
2578 return addr;
2579 }
2580
|