Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Automatic merge of jdk:master into master
  • Loading branch information
duke committed Jan 21, 2021
2 parents fb9b56b + 77a4302 commit 3d1cca4fc14726ab58028066cf2b89ed4fb573f9
Showing with 1,362 additions and 1,391 deletions.
  1. +14 −2 make/autoconf/flags-cflags.m4
  2. +2 −1 src/hotspot/os/bsd/os_bsd.cpp
  3. +1 −0 src/hotspot/os/linux/os_linux.cpp
  4. +12 −5 src/hotspot/os/posix/os_posix.cpp
  5. +5 −5 src/hotspot/os/posix/os_posix.hpp
  6. +1 −1 src/hotspot/os/posix/perfMemory_posix.cpp
  7. +8 −9 src/hotspot/os/windows/os_windows.cpp
  8. +14 −11 src/hotspot/os/windows/os_windows.hpp
  9. +1 −1 src/hotspot/share/gc/g1/g1CollectedHeap.cpp
  10. +0 −1 src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
  11. +1 −0 src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp
  12. +4 −2 src/hotspot/share/prims/nativeLookup.cpp
  13. +3 −10 src/hotspot/share/prims/unsafe.cpp
  14. +4 −2 src/hotspot/share/runtime/frame.cpp
  15. +1 −53 src/hotspot/share/runtime/park.cpp
  16. +17 −30 src/hotspot/share/runtime/park.hpp
  17. +4 −5 src/hotspot/share/runtime/thread.cpp
  18. +2 −4 src/hotspot/share/runtime/thread.hpp
  19. +1 −4 src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java
  20. +8 −7 src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystem.java
  21. +1 −4 src/java.base/macosx/classes/sun/nio/fs/MacOSXNativeDispatcher.java
  22. +2 −2 src/java.base/share/classes/java/lang/invoke/MethodHandles.java
  23. +7 −2 src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
  24. +36 −3 src/java.base/share/classes/java/util/zip/ZipCoder.java
  25. +3 −31 src/java.base/share/classes/java/util/zip/ZipFile.java
  26. +79 −409 src/java.base/share/classes/sun/security/provider/ByteArrayAccess.java
  27. +65 −56 src/java.base/share/classes/sun/security/provider/MD4.java
  28. +90 −79 src/java.base/share/classes/sun/security/provider/MD5.java
  29. +15 −9 src/java.base/share/classes/sun/security/provider/SHA.java
  30. +15 −9 src/java.base/share/classes/sun/security/provider/SHA2.java
  31. +15 −9 src/java.base/share/classes/sun/security/provider/SHA5.java
  32. +14 −9 src/java.base/share/classes/sun/security/provider/certpath/OCSPNonceExtension.java
  33. +49 −9 src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
  34. +2 −2 src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java
  35. +11 −42 src/java.base/unix/classes/sun/nio/fs/UnixPath.java
  36. +22 −0 src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java
  37. +2 −2 src/jdk.security.auth/unix/native/libjaas/Unix.c
  38. +3 −1 test/hotspot/jtreg/vmTestbase/gc/g1/unloading/loading/ClassLoadingHelper.java
  39. +3 −1 .../g1/unloading/tests/unloading_compilation_level1_inMemoryCompilation_keep_cl/TestDescription.java
  40. +3 −1 .../unloading/tests/unloading_compilation_level1_inMemoryCompilation_keep_class/TestDescription.java
  41. +3 −1 ...g1/unloading/tests/unloading_compilation_level1_inMemoryCompilation_keep_obj/TestDescription.java
  42. +3 −1 .../jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level1_keep_cl/TestDescription.java
  43. +3 −1 ...reg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level1_keep_class/TestDescription.java
  44. +3 −1 ...jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level1_keep_obj/TestDescription.java
  45. +3 −1 .../g1/unloading/tests/unloading_compilation_level2_inMemoryCompilation_keep_cl/TestDescription.java
  46. +3 −1 .../unloading/tests/unloading_compilation_level2_inMemoryCompilation_keep_class/TestDescription.java
  47. +3 −1 ...g1/unloading/tests/unloading_compilation_level2_inMemoryCompilation_keep_obj/TestDescription.java
  48. +3 −1 .../jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level2_keep_cl/TestDescription.java
  49. +3 −1 ...reg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level2_keep_class/TestDescription.java
  50. +3 −1 ...jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level2_keep_obj/TestDescription.java
  51. +3 −1 .../g1/unloading/tests/unloading_compilation_level3_inMemoryCompilation_keep_cl/TestDescription.java
  52. +3 −1 .../unloading/tests/unloading_compilation_level3_inMemoryCompilation_keep_class/TestDescription.java
  53. +3 −1 ...g1/unloading/tests/unloading_compilation_level3_inMemoryCompilation_keep_obj/TestDescription.java
  54. +3 −1 .../jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level3_keep_cl/TestDescription.java
  55. +3 −1 ...reg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level3_keep_class/TestDescription.java
  56. +3 −1 ...jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level3_keep_obj/TestDescription.java
  57. +2 −1 .../g1/unloading/tests/unloading_compilation_level4_inMemoryCompilation_keep_cl/TestDescription.java
  58. +2 −1 .../unloading/tests/unloading_compilation_level4_inMemoryCompilation_keep_class/TestDescription.java
  59. +2 −1 ...g1/unloading/tests/unloading_compilation_level4_inMemoryCompilation_keep_obj/TestDescription.java
  60. +2 −1 .../jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level4_keep_cl/TestDescription.java
  61. +2 −1 ...reg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level4_keep_class/TestDescription.java
  62. +2 −1 ...jtreg/vmTestbase/gc/g1/unloading/tests/unloading_compilation_level4_keep_obj/TestDescription.java
  63. +9 −1 test/jdk/java/lang/invoke/VarHandles/VarHandleBaseTest.java
  64. +29 −29 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java
  65. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java
  66. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java
  67. +23 −23 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java
  68. +23 −23 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java
  69. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java
  70. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java
  71. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java
  72. +20 −20 test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessString.java
  73. +9 −9 test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java
  74. +20 −20 test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java
  75. +20 −20 test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java
  76. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java
  77. +32 −32 test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java
  78. +9 −9 test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java
  79. +7 −7 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java
  80. +8 −8 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java
  81. +8 −8 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java
  82. +7 −7 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java
  83. +7 −7 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java
  84. +8 −8 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java
  85. +8 −8 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java
  86. +8 −8 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java
  87. +6 −6 test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java
  88. +32 −32 test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template
  89. +32 −32 test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template
  90. +8 −8 test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
  91. +156 −0 test/jdk/javax/swing/text/html/StyleSheet/TestWrongCSSFontSize.java
  92. +3 −2 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LuxTrustCA.java
  93. +3 −2 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java
  94. +8 −2 test/jdk/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java
  95. +41 −8 test/micro/org/openjdk/bench/java/io/FileOpen.java
  96. +14 −3 test/micro/org/openjdk/bench/java/security/MessageDigests.java
  97. +12 −2 test/micro/org/openjdk/bench/java/util/UUIDBench.java
@@ -684,9 +684,21 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
# CFLAGS PER CPU
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
# COMMON to gcc and clang
AC_MSG_CHECKING([if $1 is x86])
if test "x$FLAGS_CPU" = xx86; then
# Force compatibility with i586 on 32 bit intel platforms.
$1_CFLAGS_CPU="-march=i586"
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([if control flow protection is enabled by additional compiler flags])
if echo "${EXTRA_CFLAGS}${EXTRA_CXXFLAGS}${EXTRA_ASFLAGS}" | ${GREP} -q 'fcf-protection' ; then
# cf-protection requires CMOV and thus i686
$1_CFLAGS_CPU="-march=i686"
AC_MSG_RESULT([yes, forcing ${$1_CFLAGS_CPU}])
else
# Force compatibility with i586 on 32 bit intel platforms.
$1_CFLAGS_CPU="-march=i586"
AC_MSG_RESULT([no, forcing ${$1_CFLAGS_CPU}])
fi
else
AC_MSG_RESULT([no])
fi
fi
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1557,6 +1557,7 @@ void os::jvm_path(char *buf, jint buflen) {
}

char dli_fname[MAXPATHLEN];
dli_fname[0] = '\0';
bool ret = dll_address_to_library_name(
CAST_FROM_FN_PTR(address, os::jvm_path),
dli_fname, sizeof(dli_fname), NULL);
@@ -2637,6 +2637,7 @@ void os::jvm_path(char *buf, jint buflen) {
}

char dli_fname[MAXPATHLEN];
dli_fname[0] = '\0';
bool ret = dll_address_to_library_name(
CAST_FROM_FN_PTR(address, os::jvm_path),
dli_fname, sizeof(dli_fname), NULL);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1533,15 +1533,22 @@ void os::PlatformEvent::unpark() {

// JSR166 support

os::PlatformParker::PlatformParker() {
int status;
status = pthread_cond_init(&_cond[REL_INDEX], _condAttr);
os::PlatformParker::PlatformParker() : _counter(0), _cur_index(-1) {
int status = pthread_cond_init(&_cond[REL_INDEX], _condAttr);
assert_status(status == 0, status, "cond_init rel");
status = pthread_cond_init(&_cond[ABS_INDEX], NULL);
assert_status(status == 0, status, "cond_init abs");
status = pthread_mutex_init(_mutex, _mutexAttr);
assert_status(status == 0, status, "mutex_init");
_cur_index = -1; // mark as unused
}

os::PlatformParker::~PlatformParker() {
int status = pthread_cond_destroy(&_cond[REL_INDEX]);
assert_status(status == 0, status, "cond_destroy rel");
status = pthread_cond_destroy(&_cond[ABS_INDEX]);
assert_status(status == 0, status, "cond_destroy abs");
status = pthread_mutex_destroy(_mutex);
assert_status(status == 0, status, "mutex_destroy");
}

// Parker::park decrements count if > 0, else does a condvar wait. Unpark
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -184,21 +184,21 @@ class PlatformEvent : public CHeapObj<mtSynchronizer> {
// API updates of course). But Parker methods use fastpaths that break that
// level of encapsulation - so combining the two remains a future project.

class PlatformParker : public CHeapObj<mtSynchronizer> {
class PlatformParker {
NONCOPYABLE(PlatformParker);
protected:
enum {
REL_INDEX = 0,
ABS_INDEX = 1
};
volatile int _counter;
int _cur_index; // which cond is in use: -1, 0, 1
pthread_mutex_t _mutex[1];
pthread_cond_t _cond[2]; // one for relative times and one for absolute

public: // TODO-FIXME: make dtor private
~PlatformParker() { guarantee(false, "invariant"); }

public:
PlatformParker();
~PlatformParker();
};

// Workaround for a bug in macOSX kernel's pthread support (fixed in Mojave?).
@@ -461,7 +461,7 @@ static char* get_user_name(uid_t uid) {

char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);

struct passwd* p;
struct passwd* p = NULL;
int result = getpwuid_r(uid, &pwent, pwbuf, (size_t)bufsize, &p);

if (result != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
@@ -5431,11 +5431,10 @@ void os::PlatformEvent::unpark() {

// The Windows implementation of Park is very straightforward: Basic
// operations on Win32 Events turn out to have the right semantics to
// use them directly. We opportunistically resuse the event inherited
// from Monitor.
// use them directly.

void Parker::park(bool isAbsolute, jlong time) {
guarantee(_ParkEvent != NULL, "invariant");
guarantee(_ParkHandle != NULL, "invariant");
// First, demultiplex/decode time arguments
if (time < 0) { // don't wait
return;
@@ -5457,16 +5456,16 @@ void Parker::park(bool isAbsolute, jlong time) {

// Don't wait if interrupted or already triggered
if (thread->is_interrupted(false) ||
WaitForSingleObject(_ParkEvent, 0) == WAIT_OBJECT_0) {
ResetEvent(_ParkEvent);
WaitForSingleObject(_ParkHandle, 0) == WAIT_OBJECT_0) {
ResetEvent(_ParkHandle);
return;
} else {
ThreadBlockInVM tbivm(thread);
OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
thread->set_suspend_equivalent();

WaitForSingleObject(_ParkEvent, time);
ResetEvent(_ParkEvent);
WaitForSingleObject(_ParkHandle, time);
ResetEvent(_ParkHandle);

// If externally suspended while waiting, re-suspend
if (thread->handle_special_suspend_equivalent_condition()) {
@@ -5476,8 +5475,8 @@ void Parker::park(bool isAbsolute, jlong time) {
}

void Parker::unpark() {
guarantee(_ParkEvent != NULL, "invariant");
SetEvent(_ParkEvent);
guarantee(_ParkHandle != NULL, "invariant");
SetEvent(_ParkHandle);
}

// Platform Monitor implementation
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -188,18 +188,21 @@ class PlatformEvent : public CHeapObj<mtSynchronizer> {



class PlatformParker : public CHeapObj<mtSynchronizer> {
protected:
HANDLE _ParkEvent ;
class PlatformParker {
NONCOPYABLE(PlatformParker);

public:
~PlatformParker () { guarantee (0, "invariant") ; }
PlatformParker () {
_ParkEvent = CreateEvent (NULL, true, false, NULL) ;
guarantee (_ParkEvent != NULL, "invariant") ;
}
protected:
HANDLE _ParkHandle;

} ;
public:
PlatformParker() {
_ParkHandle = CreateEvent (NULL, true, false, NULL) ;
guarantee(_ParkHandle != NULL, "invariant") ;
}
~PlatformParker() {
CloseHandle(_ParkHandle);
}
};

// Platform specific implementations that underpin VM Mutex/Monitor classes.
// Note that CRITICAL_SECTION supports recursive locking, while the semantics
@@ -2842,7 +2842,7 @@ void G1CollectedHeap::expand_heap_after_young_collection(){
if (expand_bytes > 0) {
// No need for an ergo logging here,
// expansion_amount() does this when it returns a value > 0.
double expand_ms;
double expand_ms = 0.0;
if (!expand(expand_bytes, _workers, &expand_ms)) {
// We failed to expand the heap. Cannot do anything about it.
}
@@ -193,7 +193,6 @@ void ShenandoahConcurrentRootScanner::roots_do(OopClosure* oops, uint worker_id)
_vm_roots.oops_do(oops, worker_id);

if (!heap->unload_classes()) {
AlwaysTrueClosure always_true;
_cld_roots.cld_do(&clds_cl, worker_id);
ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
@@ -112,6 +112,7 @@ void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::cld_do_impl(Cl
_semaphore.claim_all();
}
} else {
ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CLDGRoots, worker_id);
f(clds);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -434,8 +434,10 @@ void* NativeLookup::dll_load(const methodHandle& method) {
address current_entry = method->native_function();

char dll_name[JVM_MAXPATHLEN];
dll_name[0] = '\0';
int offset;
if (os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset)) {
bool ret = os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset);
if (ret && dll_name[0] != '\0') {
char ebuf[32];
return os::dll_load(dll_name, ebuf, sizeof(ebuf));
}
@@ -1001,8 +1001,6 @@ UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute,
} UNSAFE_END

UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) {
Parker* p = NULL;

if (jthread != NULL) {
ThreadsListHandle tlh;
JavaThread* thr = NULL;
@@ -1012,18 +1010,13 @@ UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread))
// This is a valid oop.
if (thr != NULL) {
// The JavaThread is alive.
p = thr->parker();
Parker* p = thr->parker();
HOTSPOT_THREAD_UNPARK((uintptr_t) p);
p->unpark();
}
}
} // ThreadsListHandle is destroyed here.

// 'p' points to type-stable-memory if non-NULL. If the target
// thread terminates before we get here the new user of this
// Parker will get a 'spurious' unpark - which is perfectly valid.
if (p != NULL) {
HOTSPOT_THREAD_UNPARK((uintptr_t) p);
p->unpark();
}
} UNSAFE_END

UNSAFE_ENTRY(jint, Unsafe_GetLoadAverage0(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -540,9 +540,11 @@ void frame::print_C_frame(outputStream* st, char* buf, int buflen, address pc) {
int offset;
bool found;

if (buf == NULL || buflen < 1) return;
// libname
buf[0] = '\0';
found = os::dll_address_to_library_name(pc, buf, buflen, &offset);
if (found) {
if (found && buf[0] != '\0') {
// skip directory names
const char *p1, *p2;
p1 = buf;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -112,55 +112,3 @@ void ParkEvent::operator delete (void * a) {
// ParkEvents are type-stable and immortal ...
ShouldNotReachHere();
}


// 6399321 As a temporary measure we copied & modified the ParkEvent::
// allocate() and release() code for use by Parkers. The Parker:: forms
// will eventually be removed as we consolidate and shift over to ParkEvents
// for both builtin synchronization and JSR166 operations.

volatile int Parker::ListLock = 0 ;
Parker * volatile Parker::FreeList = NULL ;

Parker * Parker::Allocate (JavaThread * t) {
guarantee (t != NULL, "invariant") ;
Parker * p ;

// Start by trying to recycle an existing but unassociated
// Parker from the global free list.
// 8028280: using concurrent free list without memory management can leak
// pretty badly it turns out.
Thread::SpinAcquire(&ListLock, "ParkerFreeListAllocate");
{
p = FreeList;
if (p != NULL) {
FreeList = p->FreeNext;
}
}
Thread::SpinRelease(&ListLock);

if (p != NULL) {
guarantee (p->AssociatedWith == NULL, "invariant") ;
} else {
// Do this the hard way -- materialize a new Parker..
p = new Parker() ;
}
p->AssociatedWith = t ; // Associate p with t
p->FreeNext = NULL ;
return p ;
}


void Parker::Release (Parker * p) {
if (p == NULL) return ;
guarantee (p->AssociatedWith != NULL, "invariant") ;
guarantee (p->FreeNext == NULL , "invariant") ;
p->AssociatedWith = NULL ;

Thread::SpinAcquire(&ListLock, "ParkerFreeListRelease");
{
p->FreeNext = FreeList;
FreeList = p;
}
Thread::SpinRelease(&ListLock);
}

0 comments on commit 3d1cca4

Please sign in to comment.