mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 22:04:51 +02:00
8078513: [linux] Clean up code relevant to LinuxThreads implementation
Reviewed-by: dholmes, sla, coleenp, simonis
This commit is contained in:
parent
5b6281adb8
commit
b46373e827
10 changed files with 58 additions and 350 deletions
|
@ -637,11 +637,6 @@ void os::Bsd::hotspot_sigmask(Thread* thread) {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
@ -681,15 +676,6 @@ static void *java_start(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__
|
||||
|
@ -2278,8 +2264,6 @@ 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,
|
||||
|
@ -2302,23 +2286,9 @@ static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) {
|
|||
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;
|
||||
}
|
||||
|
@ -2492,15 +2462,7 @@ char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
|
|||
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;
|
||||
// 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.
|
||||
|
@ -2554,10 +2516,8 @@ char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -3717,12 +3677,6 @@ ExtendedPC os::get_thread_pc(Thread* thread) {
|
|||
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
|
||||
|
||||
|
@ -4288,7 +4242,7 @@ int os::PlatformEvent::park(jlong millis) {
|
|||
// In that case, we should propagate the notify to another waiter.
|
||||
|
||||
while (_Event < 0) {
|
||||
status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &abst);
|
||||
status = pthread_cond_timedwait(_cond, _mutex, &abst);
|
||||
if (status != 0 && WorkAroundNPTLTimedWaitHang) {
|
||||
pthread_cond_destroy(_cond);
|
||||
pthread_cond_init(_cond, NULL);
|
||||
|
@ -4494,7 +4448,7 @@ void Parker::park(bool isAbsolute, jlong time) {
|
|||
if (time == 0) {
|
||||
status = pthread_cond_wait(_cond, _mutex);
|
||||
} else {
|
||||
status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &absTime);
|
||||
status = pthread_cond_timedwait(_cond, _mutex, &absTime);
|
||||
if (status != 0 && WorkAroundNPTLTimedWaitHang) {
|
||||
pthread_cond_destroy(_cond);
|
||||
pthread_cond_init(_cond, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue