< prev index next >
src/os/bsd/vm/os_bsd.cpp
Print this page
rev 8517 : 8078513: [linux] Clean up code relevant to LinuxThreads implementation
Reviewed-by: dholmes, sla, coleenp
*** 635,649 ****
//////////////////////////////////////////////////////////////////////////////
// create new thread
- // check if it's safe to start a new thread
- static bool _thread_safety_check(Thread* thread) {
- return true;
- }
-
#ifdef __APPLE__
// library handle for calling objc_registerThreadWithCollector()
// without static linking to the libobjc library
#define OBJC_LIB "/usr/lib/libobjc.dylib"
#define OBJC_GCREGISTER "objc_registerThreadWithCollector"
--- 635,644 ----
*** 679,697 ****
ThreadLocalStorage::set_thread(thread);
OSThread* osthread = thread->osthread();
Monitor* sync = osthread->startThread_lock();
- // non floating stack BsdThreads needs extra check, see above
- if (!_thread_safety_check(thread)) {
- // notify parent thread
- MutexLockerEx ml(sync, Mutex::_no_safepoint_check_flag);
- osthread->set_state(ZOMBIE);
- sync->notify_all();
- return NULL;
- }
-
osthread->set_thread_id(os::Bsd::gettid());
#ifdef __APPLE__
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id());
guarantee(unique_thread_id != 0, "unique thread id was not found");
--- 674,683 ----
*** 2274,2285 ****
// munmap()ping them. If not, just call uncommit_memory().
bool os::remove_stack_guard_pages(char* addr, size_t size) {
return os::uncommit_memory(addr, size);
}
- static address _highest_vm_reserved_address = NULL;
-
// If 'fixed' is true, anon_mmap() will attempt to reserve anonymous memory
// at 'requested_addr'. If there are existing memory mappings at the same
// location, however, they will be overwritten. If 'fixed' is false,
// 'requested_addr' is only treated as a hint, the return value may or
// may not start from the requested address. Unlike Bsd mmap(), this
--- 2260,2269 ----
*** 2298,2324 ****
// touch an uncommitted page. Otherwise, the read/write might
// succeed if we have enough swap space to back the physical page.
addr = (char*)::mmap(requested_addr, bytes, PROT_NONE,
flags, -1, 0);
- if (addr != MAP_FAILED) {
- // anon_mmap() should only get called during VM initialization,
- // don't need lock (actually we can skip locking even it can be called
- // from multiple threads, because _highest_vm_reserved_address is just a
- // hint about the upper limit of non-stack memory regions.)
- if ((address)addr + bytes > _highest_vm_reserved_address) {
- _highest_vm_reserved_address = (address)addr + bytes;
- }
- }
-
return addr == MAP_FAILED ? NULL : addr;
}
- // Don't update _highest_vm_reserved_address, because there might be memory
- // regions above addr + size. If so, releasing a memory region only creates
- // a hole in the address space, it doesn't help prevent heap-stack collision.
- //
static int anon_munmap(char * addr, size_t size) {
return ::munmap(addr, size) == 0;
}
char* os::pd_reserve_memory(size_t bytes, char* requested_addr,
--- 2282,2294 ----
*** 2488,2506 ****
// we can either pass an alignment to this method or verify alignment
// in one of the methods further up the call chain. See bug 5044738.
assert(bytes % os::vm_page_size() == 0, "reserving unexpected size block");
// Repeatedly allocate blocks until the block is allocated at the
! // right spot. Give up after max_tries. Note that reserve_memory() will
! // automatically update _highest_vm_reserved_address if the call is
! // successful. The variable tracks the highest memory address every reserved
! // by JVM. It is used to detect heap-stack collision if running with
! // fixed-stack BsdThreads. Because here we may attempt to reserve more
! // space than needed, it could confuse the collision detecting code. To
! // solve the problem, save current _highest_vm_reserved_address and
! // calculate the correct value before return.
! address old_highest = _highest_vm_reserved_address;
// Bsd mmap allows caller to pass an address as hint; give it a try first,
// if kernel honors the hint then we can return immediately.
char * addr = anon_mmap(requested_addr, bytes, false);
if (addr == requested_addr) {
--- 2458,2468 ----
// we can either pass an alignment to this method or verify alignment
// in one of the methods further up the call chain. See bug 5044738.
assert(bytes % os::vm_page_size() == 0, "reserving unexpected size block");
// Repeatedly allocate blocks until the block is allocated at the
! // right spot.
// Bsd mmap allows caller to pass an address as hint; give it a try first,
// if kernel honors the hint then we can return immediately.
char * addr = anon_mmap(requested_addr, bytes, false);
if (addr == requested_addr) {
*** 2550,2563 ****
unmap_memory(base[j], size[j]);
}
}
if (i < max_tries) {
- _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
return requested_addr;
} else {
- _highest_vm_reserved_address = old_highest;
return NULL;
}
}
size_t os::read(int fd, void *buf, unsigned int nBytes) {
--- 2512,2523 ----
*** 3713,3728 ****
PcFetcher fetcher(thread);
fetcher.run();
return fetcher.result();
}
- int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond,
- pthread_mutex_t *_mutex,
- const struct timespec *_abstime) {
- return pthread_cond_timedwait(_cond, _mutex, _abstime);
- }
-
////////////////////////////////////////////////////////////////////////////////
// debug support
bool os::find(address addr, outputStream* st) {
Dl_info dlinfo;
--- 3673,3682 ----
*** 4284,4294 ****
//
// TODO: properly differentiate simultaneous notify+interrupt.
// In that case, we should propagate the notify to another waiter.
while (_Event < 0) {
! status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &abst);
if (status != 0 && WorkAroundNPTLTimedWaitHang) {
pthread_cond_destroy(_cond);
pthread_cond_init(_cond, NULL);
}
assert_status(status == 0 || status == EINTR ||
--- 4238,4248 ----
//
// TODO: properly differentiate simultaneous notify+interrupt.
// In that case, we should propagate the notify to another waiter.
while (_Event < 0) {
! status = pthread_cond_timedwait(_cond, _mutex, &abst);
if (status != 0 && WorkAroundNPTLTimedWaitHang) {
pthread_cond_destroy(_cond);
pthread_cond_init(_cond, NULL);
}
assert_status(status == 0 || status == EINTR ||
*** 4490,4500 ****
// cleared by handle_special_suspend_equivalent_condition() or java_suspend_self()
if (time == 0) {
status = pthread_cond_wait(_cond, _mutex);
} else {
! status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &absTime);
if (status != 0 && WorkAroundNPTLTimedWaitHang) {
pthread_cond_destroy(_cond);
pthread_cond_init(_cond, NULL);
}
}
--- 4444,4454 ----
// cleared by handle_special_suspend_equivalent_condition() or java_suspend_self()
if (time == 0) {
status = pthread_cond_wait(_cond, _mutex);
} else {
! status = pthread_cond_timedwait(_cond, _mutex, &absTime);
if (status != 0 && WorkAroundNPTLTimedWaitHang) {
pthread_cond_destroy(_cond);
pthread_cond_init(_cond, NULL);
}
}
< prev index next >