mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-25 15:20:11 +00:00
Merge
This commit is contained in:
commit
d417fc4af1
@ -11,3 +11,5 @@ nbproject/private/
|
||||
test/nashorn/script/external
|
||||
test/nashorn/lib
|
||||
NashornProfile.txt
|
||||
.*/JTreport/.*
|
||||
.*/JTwork/.*
|
||||
|
||||
@ -113,6 +113,8 @@ ifeq ($(TOOLCHAIN_TYPE), solstudio)
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libHandshakeTransitionTest := -lc
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libHasNoEntryPoint := -lc
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libReturnError := -lc
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCNLookUp := -lc
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libTestCheckedEnsureLocalCapacity := -lc
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), linux)
|
||||
|
||||
@ -765,6 +765,11 @@ ALIGNED_(8) juint _log2_pow[] =
|
||||
0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL
|
||||
};
|
||||
|
||||
ALIGNED_(8) juint _DOUBLE2[] =
|
||||
{
|
||||
0x00000000UL, 0x40000000UL
|
||||
};
|
||||
|
||||
//registers,
|
||||
// input: xmm0, xmm1
|
||||
// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
|
||||
@ -803,6 +808,7 @@ void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xm
|
||||
address HIGHMASK_LOG_X = (address)_HIGHMASK_LOG_X;
|
||||
address HALFMASK = (address)_HALFMASK;
|
||||
address log2 = (address)_log2_pow;
|
||||
address DOUBLE2 = (address)_DOUBLE2;
|
||||
|
||||
|
||||
bind(start);
|
||||
@ -810,6 +816,13 @@ void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xm
|
||||
movsd(Address(rsp, 8), xmm0);
|
||||
movsd(Address(rsp, 16), xmm1);
|
||||
|
||||
// Special case: pow(x, 2.0) => x * x
|
||||
movdq(tmp1, xmm1);
|
||||
cmp64(tmp1, ExternalAddress(DOUBLE2));
|
||||
jccb(Assembler::notEqual, B1_2);
|
||||
mulsd(xmm0, xmm0);
|
||||
jmp(B1_5);
|
||||
|
||||
bind(B1_2);
|
||||
pextrw(eax, xmm0, 3);
|
||||
xorpd(xmm2, xmm2);
|
||||
|
||||
@ -433,7 +433,7 @@ class StubGenerator: public StubCodeGenerator {
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Support for jint Atomic::xchg(jint exchange_value, volatile jint* dest)
|
||||
// Support for int32_t Atomic::xchg(int32_t exchange_value, volatile int32_t* dest)
|
||||
//
|
||||
// xchg exists as far back as 8086, lock needed for MP only
|
||||
// Stack layout immediately after call:
|
||||
|
||||
@ -611,8 +611,8 @@ class StubGenerator: public StubCodeGenerator {
|
||||
return start;
|
||||
}
|
||||
|
||||
// Support for jbyte atomic::atomic_cmpxchg(jbyte exchange_value, volatile jbyte* dest,
|
||||
// jbyte compare_value)
|
||||
// Support for int8_t atomic::atomic_cmpxchg(int8_t exchange_value, volatile int8_t* dest,
|
||||
// int8_t compare_value)
|
||||
//
|
||||
// Arguments :
|
||||
// c_rarg0: exchange_value
|
||||
@ -637,9 +637,9 @@ class StubGenerator: public StubCodeGenerator {
|
||||
return start;
|
||||
}
|
||||
|
||||
// Support for jlong atomic::atomic_cmpxchg(jlong exchange_value,
|
||||
// volatile jlong* dest,
|
||||
// jlong compare_value)
|
||||
// Support for int64_t atomic::atomic_cmpxchg(int64_t exchange_value,
|
||||
// volatile int64_t* dest,
|
||||
// int64_t compare_value)
|
||||
// Arguments :
|
||||
// c_rarg0: exchange_value
|
||||
// c_rarg1: dest
|
||||
@ -694,8 +694,8 @@ class StubGenerator: public StubCodeGenerator {
|
||||
// Result:
|
||||
// *dest += add_value
|
||||
// return *dest;
|
||||
address generate_atomic_add_ptr() {
|
||||
StubCodeMark mark(this, "StubRoutines", "atomic_add_ptr");
|
||||
address generate_atomic_add_long() {
|
||||
StubCodeMark mark(this, "StubRoutines", "atomic_add_long");
|
||||
address start = __ pc();
|
||||
|
||||
__ movptr(rax, c_rarg0); // Copy to eax we need a return value anyhow
|
||||
@ -5015,14 +5015,14 @@ class StubGenerator: public StubCodeGenerator {
|
||||
StubRoutines::_catch_exception_entry = generate_catch_exception();
|
||||
|
||||
// atomic calls
|
||||
StubRoutines::_atomic_xchg_entry = generate_atomic_xchg();
|
||||
StubRoutines::_atomic_xchg_long_entry = generate_atomic_xchg_long();
|
||||
StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg();
|
||||
StubRoutines::_atomic_cmpxchg_byte_entry = generate_atomic_cmpxchg_byte();
|
||||
StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
|
||||
StubRoutines::_atomic_add_entry = generate_atomic_add();
|
||||
StubRoutines::_atomic_add_ptr_entry = generate_atomic_add_ptr();
|
||||
StubRoutines::_fence_entry = generate_orderaccess_fence();
|
||||
StubRoutines::_atomic_xchg_entry = generate_atomic_xchg();
|
||||
StubRoutines::_atomic_xchg_long_entry = generate_atomic_xchg_long();
|
||||
StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg();
|
||||
StubRoutines::_atomic_cmpxchg_byte_entry = generate_atomic_cmpxchg_byte();
|
||||
StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
|
||||
StubRoutines::_atomic_add_entry = generate_atomic_add();
|
||||
StubRoutines::_atomic_add_long_entry = generate_atomic_add_long();
|
||||
StubRoutines::_fence_entry = generate_orderaccess_fence();
|
||||
|
||||
// platform dependent
|
||||
StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp();
|
||||
|
||||
@ -258,7 +258,7 @@ class StubGenerator: public StubCodeGenerator {
|
||||
StubRoutines::_atomic_cmpxchg_byte_entry = ShouldNotCallThisStub();
|
||||
StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
|
||||
StubRoutines::_atomic_add_entry = ShouldNotCallThisStub();
|
||||
StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub();
|
||||
StubRoutines::_atomic_add_long_entry = ShouldNotCallThisStub();
|
||||
StubRoutines::_fence_entry = ShouldNotCallThisStub();
|
||||
}
|
||||
|
||||
|
||||
@ -132,8 +132,8 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
|
||||
extern "C" {
|
||||
// defined in bsd_x86.s
|
||||
jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong, bool);
|
||||
void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst);
|
||||
int64_t _Atomic_cmpxchg_long(int64_t, volatile int64_t*, int64_t, bool);
|
||||
void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst);
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -143,15 +143,15 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
T compare_value,
|
||||
cmpxchg_memory_order order) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
return cmpxchg_using_helper<jlong>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
|
||||
return cmpxchg_using_helper<int64_t>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
|
||||
}
|
||||
|
||||
template<>
|
||||
template<typename T>
|
||||
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
volatile jlong dest;
|
||||
_Atomic_move_long(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
|
||||
volatile int64_t dest;
|
||||
_Atomic_move_long(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
|
||||
return PrimitiveConversions::cast<T>(dest);
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ template<typename T>
|
||||
inline void Atomic::PlatformStore<8>::operator()(T store_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
_Atomic_move_long(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
|
||||
_Atomic_move_long(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
|
||||
}
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
@ -633,10 +633,10 @@ mmx_acs_CopyLeft:
|
||||
ret
|
||||
|
||||
|
||||
# Support for jlong Atomic::cmpxchg(jlong exchange_value,
|
||||
# volatile jlong* dest,
|
||||
# jlong compare_value,
|
||||
# bool is_MP)
|
||||
# Support for int64_t Atomic::cmpxchg(int64_t exchange_value,
|
||||
# volatile int64_t* dest,
|
||||
# int64_t compare_value,
|
||||
# bool is_MP)
|
||||
#
|
||||
.p2align 4,,15
|
||||
ELF_TYPE(_Atomic_cmpxchg_long,@function)
|
||||
@ -658,8 +658,8 @@ SYMBOL(_Atomic_cmpxchg_long):
|
||||
ret
|
||||
|
||||
|
||||
# Support for jlong Atomic::load and Atomic::store.
|
||||
# void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst)
|
||||
# Support for int64_t Atomic::load and Atomic::store.
|
||||
# void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst)
|
||||
.p2align 4,,15
|
||||
ELF_TYPE(_Atomic_move_long,@function)
|
||||
SYMBOL(_Atomic_move_long):
|
||||
|
||||
@ -265,8 +265,8 @@ template<>
|
||||
template<typename T>
|
||||
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
volatile jlong dest;
|
||||
os::atomic_copy64(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
|
||||
volatile int64_t dest;
|
||||
os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
|
||||
return PrimitiveConversions::cast<T>(dest);
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ template<typename T>
|
||||
inline void Atomic::PlatformStore<8>::operator()(T store_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
os::atomic_copy64(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
|
||||
os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
|
||||
}
|
||||
|
||||
#endif // OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_HPP
|
||||
|
||||
@ -50,7 +50,7 @@ template<typename T>
|
||||
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
return PrimitiveConversions::cast<T>(
|
||||
(*os::atomic_load_long_func)(reinterpret_cast<const volatile jlong*>(src)));
|
||||
(*os::atomic_load_long_func)(reinterpret_cast<const volatile int64_t*>(src)));
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -59,7 +59,7 @@ inline void Atomic::PlatformStore<8>::operator()(T store_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
(*os::atomic_store_long_func)(
|
||||
PrimitiveConversions::cast<jlong>(store_value), reinterpret_cast<volatile jlong*>(dest));
|
||||
PrimitiveConversions::cast<int64_t>(store_value), reinterpret_cast<volatile int64_t*>(dest));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -103,7 +103,7 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co
|
||||
: "memory");
|
||||
return val;
|
||||
#else
|
||||
return add_using_helper<jint>(os::atomic_add_func, add_value, dest);
|
||||
return add_using_helper<int32_t>(os::atomic_add_func, add_value, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
|
||||
: "memory");
|
||||
return old_val;
|
||||
#else
|
||||
return xchg_using_helper<jint>(os::atomic_xchg_func, exchange_value, dest);
|
||||
return xchg_using_helper<int32_t>(os::atomic_xchg_func, exchange_value, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -178,17 +178,17 @@ struct Atomic::PlatformCmpxchg<1> : Atomic::CmpxchgByteUsingInt {};
|
||||
|
||||
#ifndef AARCH64
|
||||
|
||||
inline jint reorder_cmpxchg_func(jint exchange_value,
|
||||
jint volatile* dest,
|
||||
jint compare_value) {
|
||||
inline int32_t reorder_cmpxchg_func(int32_t exchange_value,
|
||||
int32_t volatile* dest,
|
||||
int32_t compare_value) {
|
||||
// Warning: Arguments are swapped to avoid moving them for kernel call
|
||||
return (*os::atomic_cmpxchg_func)(compare_value, exchange_value, dest);
|
||||
}
|
||||
|
||||
inline jlong reorder_cmpxchg_long_func(jlong exchange_value,
|
||||
jlong volatile* dest,
|
||||
jlong compare_value) {
|
||||
assert(VM_Version::supports_cx8(), "Atomic compare and exchange jlong not supported on this architecture!");
|
||||
inline int64_t reorder_cmpxchg_long_func(int64_t exchange_value,
|
||||
int64_t volatile* dest,
|
||||
int64_t compare_value) {
|
||||
assert(VM_Version::supports_cx8(), "Atomic compare and exchange int64_t not supported on this architecture!");
|
||||
// Warning: Arguments are swapped to avoid moving them for kernel call
|
||||
return (*os::atomic_cmpxchg_long_func)(compare_value, exchange_value, dest);
|
||||
}
|
||||
@ -221,7 +221,7 @@ inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
|
||||
: "memory");
|
||||
return rv;
|
||||
#else
|
||||
return cmpxchg_using_helper<jint>(reorder_cmpxchg_func, exchange_value, dest, compare_value);
|
||||
return cmpxchg_using_helper<int32_t>(reorder_cmpxchg_func, exchange_value, dest, compare_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
: "memory");
|
||||
return rv;
|
||||
#else
|
||||
return cmpxchg_using_helper<jlong>(reorder_cmpxchg_long_func, exchange_value, dest, compare_value);
|
||||
return cmpxchg_using_helper<int64_t>(reorder_cmpxchg_long_func, exchange_value, dest, compare_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -598,11 +598,11 @@ void os::print_register_info(outputStream *st, const void *context) {
|
||||
|
||||
#ifndef AARCH64
|
||||
|
||||
typedef jlong cmpxchg_long_func_t(jlong, jlong, volatile jlong*);
|
||||
typedef int64_t cmpxchg_long_func_t(int64_t, int64_t, volatile int64_t*);
|
||||
|
||||
cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
|
||||
|
||||
jlong os::atomic_cmpxchg_long_bootstrap(jlong compare_value, jlong exchange_value, volatile jlong* dest) {
|
||||
int64_t os::atomic_cmpxchg_long_bootstrap(int64_t compare_value, int64_t exchange_value, volatile int64_t* dest) {
|
||||
// try to use the stub:
|
||||
cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
|
||||
|
||||
@ -612,16 +612,16 @@ jlong os::atomic_cmpxchg_long_bootstrap(jlong compare_value, jlong exchange_valu
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jlong old_value = *dest;
|
||||
int64_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
typedef jlong load_long_func_t(const volatile jlong*);
|
||||
typedef int64_t load_long_func_t(const volatile int64_t*);
|
||||
|
||||
load_long_func_t* os::atomic_load_long_func = os::atomic_load_long_bootstrap;
|
||||
|
||||
jlong os::atomic_load_long_bootstrap(const volatile jlong* src) {
|
||||
int64_t os::atomic_load_long_bootstrap(const volatile int64_t* src) {
|
||||
// try to use the stub:
|
||||
load_long_func_t* func = CAST_TO_FN_PTR(load_long_func_t*, StubRoutines::atomic_load_long_entry());
|
||||
|
||||
@ -631,15 +631,15 @@ jlong os::atomic_load_long_bootstrap(const volatile jlong* src) {
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jlong old_value = *src;
|
||||
int64_t old_value = *src;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
typedef void store_long_func_t(jlong, volatile jlong*);
|
||||
typedef void store_long_func_t(int64_t, volatile int64_t*);
|
||||
|
||||
store_long_func_t* os::atomic_store_long_func = os::atomic_store_long_bootstrap;
|
||||
|
||||
void os::atomic_store_long_bootstrap(jlong val, volatile jlong* dest) {
|
||||
void os::atomic_store_long_bootstrap(int64_t val, volatile int64_t* dest) {
|
||||
// try to use the stub:
|
||||
store_long_func_t* func = CAST_TO_FN_PTR(store_long_func_t*, StubRoutines::atomic_store_long_entry());
|
||||
|
||||
@ -652,11 +652,11 @@ void os::atomic_store_long_bootstrap(jlong val, volatile jlong* dest) {
|
||||
*dest = val;
|
||||
}
|
||||
|
||||
typedef jint atomic_add_func_t(jint add_value, volatile jint *dest);
|
||||
typedef int32_t atomic_add_func_t(int32_t add_value, volatile int32_t *dest);
|
||||
|
||||
atomic_add_func_t * os::atomic_add_func = os::atomic_add_bootstrap;
|
||||
|
||||
jint os::atomic_add_bootstrap(jint add_value, volatile jint *dest) {
|
||||
int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t *dest) {
|
||||
atomic_add_func_t * func = CAST_TO_FN_PTR(atomic_add_func_t*,
|
||||
StubRoutines::atomic_add_entry());
|
||||
if (func != NULL) {
|
||||
@ -664,16 +664,16 @@ jint os::atomic_add_bootstrap(jint add_value, volatile jint *dest) {
|
||||
return (*func)(add_value, dest);
|
||||
}
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
*dest = old_value + add_value;
|
||||
return (old_value + add_value);
|
||||
}
|
||||
|
||||
typedef jint atomic_xchg_func_t(jint exchange_value, volatile jint *dest);
|
||||
typedef int32_t atomic_xchg_func_t(int32_t exchange_value, volatile int32_t *dest);
|
||||
|
||||
atomic_xchg_func_t * os::atomic_xchg_func = os::atomic_xchg_bootstrap;
|
||||
|
||||
jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint *dest) {
|
||||
int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t *dest) {
|
||||
atomic_xchg_func_t * func = CAST_TO_FN_PTR(atomic_xchg_func_t*,
|
||||
StubRoutines::atomic_xchg_entry());
|
||||
if (func != NULL) {
|
||||
@ -681,16 +681,16 @@ jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint *dest) {
|
||||
return (*func)(exchange_value, dest);
|
||||
}
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
*dest = exchange_value;
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
typedef jint cmpxchg_func_t(jint, jint, volatile jint*);
|
||||
typedef int32_t cmpxchg_func_t(int32_t, int32_t, volatile int32_t*);
|
||||
|
||||
cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
|
||||
|
||||
jint os::atomic_cmpxchg_bootstrap(jint compare_value, jint exchange_value, volatile jint* dest) {
|
||||
int32_t os::atomic_cmpxchg_bootstrap(int32_t compare_value, int32_t exchange_value, volatile int32_t* dest) {
|
||||
// try to use the stub:
|
||||
cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
|
||||
|
||||
@ -700,7 +700,7 @@ jint os::atomic_cmpxchg_bootstrap(jint compare_value, jint exchange_value, volat
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
|
||||
@ -45,35 +45,35 @@
|
||||
static bool register_code_area(char *low, char *high) { return true; }
|
||||
|
||||
#ifndef AARCH64
|
||||
static jlong (*atomic_cmpxchg_long_func)(jlong compare_value,
|
||||
jlong exchange_value,
|
||||
volatile jlong *dest);
|
||||
static int64_t (*atomic_cmpxchg_long_func)(int64_t compare_value,
|
||||
int64_t exchange_value,
|
||||
volatile int64_t *dest);
|
||||
|
||||
static jlong (*atomic_load_long_func)(const volatile jlong*);
|
||||
static int64_t (*atomic_load_long_func)(const volatile int64_t*);
|
||||
|
||||
static void (*atomic_store_long_func)(jlong, volatile jlong*);
|
||||
static void (*atomic_store_long_func)(int64_t, volatile int64_t*);
|
||||
|
||||
static jint (*atomic_add_func)(jint add_value, volatile jint *dest);
|
||||
static int32_t (*atomic_add_func)(int32_t add_value, volatile int32_t *dest);
|
||||
|
||||
static jint (*atomic_xchg_func)(jint exchange_value, volatile jint *dest);
|
||||
static int32_t (*atomic_xchg_func)(int32_t exchange_value, volatile int32_t *dest);
|
||||
|
||||
static jint (*atomic_cmpxchg_func)(jint compare_value,
|
||||
jint exchange_value,
|
||||
volatile jint *dest);
|
||||
static int32_t (*atomic_cmpxchg_func)(int32_t compare_value,
|
||||
int32_t exchange_value,
|
||||
volatile int32_t *dest);
|
||||
|
||||
static jlong atomic_cmpxchg_long_bootstrap(jlong, jlong, volatile jlong*);
|
||||
static int64_t atomic_cmpxchg_long_bootstrap(int64_t, int64_t, volatile int64_t*);
|
||||
|
||||
static jlong atomic_load_long_bootstrap(const volatile jlong*);
|
||||
static int64_t atomic_load_long_bootstrap(const volatile int64_t*);
|
||||
|
||||
static void atomic_store_long_bootstrap(jlong, volatile jlong*);
|
||||
static void atomic_store_long_bootstrap(int64_t, volatile int64_t*);
|
||||
|
||||
static jint atomic_add_bootstrap(jint add_value, volatile jint *dest);
|
||||
static int32_t atomic_add_bootstrap(int32_t add_value, volatile int32_t *dest);
|
||||
|
||||
static jint atomic_xchg_bootstrap(jint exchange_value, volatile jint *dest);
|
||||
static int32_t atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t *dest);
|
||||
|
||||
static jint atomic_cmpxchg_bootstrap(jint compare_value,
|
||||
jint exchange_value,
|
||||
volatile jint *dest);
|
||||
static int32_t atomic_cmpxchg_bootstrap(int32_t compare_value,
|
||||
int32_t exchange_value,
|
||||
volatile int32_t *dest);
|
||||
#endif // !AARCH64
|
||||
|
||||
#endif // OS_CPU_LINUX_ARM_VM_OS_LINUX_ARM_HPP
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2017, 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
|
||||
@ -28,15 +28,15 @@
|
||||
//
|
||||
// NOTE: we are back in class os here, not Linux
|
||||
//
|
||||
static jint (*atomic_xchg_func) (jint, volatile jint*);
|
||||
static jint (*atomic_cmpxchg_func) (jint, volatile jint*, jint);
|
||||
static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
|
||||
static jint (*atomic_add_func) (jint, volatile jint*);
|
||||
static int32_t (*atomic_xchg_func) (int32_t, volatile int32_t*);
|
||||
static int32_t (*atomic_cmpxchg_func) (int32_t, volatile int32_t*, int32_t);
|
||||
static int64_t (*atomic_cmpxchg_long_func)(int64_t, volatile int64_t*, int64_t);
|
||||
static int32_t (*atomic_add_func) (int32_t, volatile int32_t*);
|
||||
|
||||
static jint atomic_xchg_bootstrap (jint, volatile jint*);
|
||||
static jint atomic_cmpxchg_bootstrap (jint, volatile jint*, jint);
|
||||
static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
|
||||
static jint atomic_add_bootstrap (jint, volatile jint*);
|
||||
static int32_t atomic_xchg_bootstrap (int32_t, volatile int32_t*);
|
||||
static int32_t atomic_cmpxchg_bootstrap (int32_t, volatile int32_t*, int32_t);
|
||||
static int64_t atomic_cmpxchg_long_bootstrap(int64_t, volatile int64_t*, int64_t);
|
||||
static int32_t atomic_add_bootstrap (int32_t, volatile int32_t*);
|
||||
|
||||
static void setup_fpu() {}
|
||||
|
||||
|
||||
@ -133,8 +133,8 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
|
||||
extern "C" {
|
||||
// defined in linux_x86.s
|
||||
jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong);
|
||||
void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst);
|
||||
int64_t _Atomic_cmpxchg_long(int64_t, volatile int64_t*, int64_t);
|
||||
void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst);
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -144,15 +144,15 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
T compare_value,
|
||||
cmpxchg_memory_order order) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
return cmpxchg_using_helper<jlong>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
|
||||
return cmpxchg_using_helper<int64_t>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
|
||||
}
|
||||
|
||||
template<>
|
||||
template<typename T>
|
||||
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
volatile jlong dest;
|
||||
_Atomic_move_long(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
|
||||
volatile int64_t dest;
|
||||
_Atomic_move_long(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
|
||||
return PrimitiveConversions::cast<T>(dest);
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ template<typename T>
|
||||
inline void Atomic::PlatformStore<8>::operator()(T store_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
_Atomic_move_long(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
|
||||
_Atomic_move_long(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
|
||||
}
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
@ -185,8 +185,8 @@ template<>
|
||||
template<typename T>
|
||||
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
volatile jlong dest;
|
||||
os::atomic_copy64(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
|
||||
volatile int64_t dest;
|
||||
os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
|
||||
return PrimitiveConversions::cast<T>(dest);
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ template<typename T>
|
||||
inline void Atomic::PlatformStore<8>::operator()(T store_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
os::atomic_copy64(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
|
||||
os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
|
||||
}
|
||||
|
||||
#endif // OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_HPP
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2017, 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
|
||||
@ -28,15 +28,15 @@
|
||||
//
|
||||
// NOTE: we are back in class os here, not Solaris
|
||||
//
|
||||
static jint (*atomic_xchg_func) (jint, volatile jint*);
|
||||
static jint (*atomic_cmpxchg_func) (jint, volatile jint*, jint);
|
||||
static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
|
||||
static jint (*atomic_add_func) (jint, volatile jint*);
|
||||
static int32_t (*atomic_xchg_func) (int32_t, volatile int32_t*);
|
||||
static int32_t (*atomic_cmpxchg_func) (int32_t, volatile int32_t*, int32_t);
|
||||
static int64_t (*atomic_cmpxchg_long_func)(int64_t, volatile int64_t*, int64_t);
|
||||
static int32_t (*atomic_add_func) (int32_t, volatile int32_t*);
|
||||
|
||||
static jint atomic_xchg_bootstrap (jint, volatile jint*);
|
||||
static jint atomic_cmpxchg_bootstrap (jint, volatile jint*, jint);
|
||||
static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
|
||||
static jint atomic_add_bootstrap (jint, volatile jint*);
|
||||
static int32_t atomic_xchg_bootstrap (int32_t, volatile int32_t*);
|
||||
static int32_t atomic_cmpxchg_bootstrap (int32_t, volatile int32_t*, int32_t);
|
||||
static int64_t atomic_cmpxchg_long_bootstrap(int64_t, volatile int64_t*, int64_t);
|
||||
static int32_t atomic_add_bootstrap (int32_t, volatile int32_t*);
|
||||
|
||||
static void setup_fpu() {}
|
||||
|
||||
|
||||
@ -28,16 +28,16 @@
|
||||
// For Sun Studio - implementation is in solaris_x86_64.il.
|
||||
|
||||
extern "C" {
|
||||
jint _Atomic_add(jint add_value, volatile jint* dest);
|
||||
jlong _Atomic_add_long(jlong add_value, volatile jlong* dest);
|
||||
int32_t _Atomic_add(int32_t add_value, volatile int32_t* dest);
|
||||
int64_t _Atomic_add_long(int64_t add_value, volatile int64_t* dest);
|
||||
|
||||
jint _Atomic_xchg(jint exchange_value, volatile jint* dest);
|
||||
jbyte _Atomic_cmpxchg_byte(jbyte exchange_value, volatile jbyte* dest,
|
||||
jbyte compare_value);
|
||||
jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest,
|
||||
jint compare_value);
|
||||
jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest,
|
||||
jlong compare_value);
|
||||
int32_t _Atomic_xchg(int32_t exchange_value, volatile int32_t* dest);
|
||||
int8_t _Atomic_cmpxchg_byte(int8_t exchange_value, volatile int8_t* dest,
|
||||
int8_t compare_value);
|
||||
int32_t _Atomic_cmpxchg(int32_t exchange_value, volatile int32_t* dest,
|
||||
int32_t compare_value);
|
||||
int64_t _Atomic_cmpxchg_long(int64_t exchange_value, volatile int64_t* dest,
|
||||
int64_t compare_value);
|
||||
}
|
||||
|
||||
template<size_t byte_size>
|
||||
@ -55,8 +55,8 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co
|
||||
STATIC_ASSERT(4 == sizeof(I));
|
||||
STATIC_ASSERT(4 == sizeof(D));
|
||||
return PrimitiveConversions::cast<D>(
|
||||
_Atomic_add(PrimitiveConversions::cast<jint>(add_value),
|
||||
reinterpret_cast<jint volatile*>(dest)));
|
||||
_Atomic_add(PrimitiveConversions::cast<int32_t>(add_value),
|
||||
reinterpret_cast<int32_t volatile*>(dest)));
|
||||
}
|
||||
|
||||
// Not using add_using_helper; see comment for cmpxchg.
|
||||
@ -66,8 +66,8 @@ inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) co
|
||||
STATIC_ASSERT(8 == sizeof(I));
|
||||
STATIC_ASSERT(8 == sizeof(D));
|
||||
return PrimitiveConversions::cast<D>(
|
||||
_Atomic_add_long(PrimitiveConversions::cast<jlong>(add_value),
|
||||
reinterpret_cast<jlong volatile*>(dest)));
|
||||
_Atomic_add_long(PrimitiveConversions::cast<int64_t>(add_value),
|
||||
reinterpret_cast<int64_t volatile*>(dest)));
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -76,11 +76,11 @@ inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(4 == sizeof(T));
|
||||
return PrimitiveConversions::cast<T>(
|
||||
_Atomic_xchg(PrimitiveConversions::cast<jint>(exchange_value),
|
||||
reinterpret_cast<jint volatile*>(dest)));
|
||||
_Atomic_xchg(PrimitiveConversions::cast<int32_t>(exchange_value),
|
||||
reinterpret_cast<int32_t volatile*>(dest)));
|
||||
}
|
||||
|
||||
extern "C" jlong _Atomic_xchg_long(jlong exchange_value, volatile jlong* dest);
|
||||
extern "C" int64_t _Atomic_xchg_long(int64_t exchange_value, volatile int64_t* dest);
|
||||
|
||||
template<>
|
||||
template<typename T>
|
||||
@ -88,8 +88,8 @@ inline T Atomic::PlatformXchg<8>::operator()(T exchange_value,
|
||||
T volatile* dest) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
return PrimitiveConversions::cast<T>(
|
||||
_Atomic_xchg_long(PrimitiveConversions::cast<jlong>(exchange_value),
|
||||
reinterpret_cast<jlong volatile*>(dest)));
|
||||
_Atomic_xchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
|
||||
reinterpret_cast<int64_t volatile*>(dest)));
|
||||
}
|
||||
|
||||
// Not using cmpxchg_using_helper here, because some configurations of
|
||||
@ -106,9 +106,9 @@ inline T Atomic::PlatformCmpxchg<1>::operator()(T exchange_value,
|
||||
cmpxchg_memory_order order) const {
|
||||
STATIC_ASSERT(1 == sizeof(T));
|
||||
return PrimitiveConversions::cast<T>(
|
||||
_Atomic_cmpxchg_byte(PrimitiveConversions::cast<jbyte>(exchange_value),
|
||||
reinterpret_cast<jbyte volatile*>(dest),
|
||||
PrimitiveConversions::cast<jbyte>(compare_value)));
|
||||
_Atomic_cmpxchg_byte(PrimitiveConversions::cast<int8_t>(exchange_value),
|
||||
reinterpret_cast<int8_t volatile*>(dest),
|
||||
PrimitiveConversions::cast<int8_t>(compare_value)));
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -119,9 +119,9 @@ inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
|
||||
cmpxchg_memory_order order) const {
|
||||
STATIC_ASSERT(4 == sizeof(T));
|
||||
return PrimitiveConversions::cast<T>(
|
||||
_Atomic_cmpxchg(PrimitiveConversions::cast<jint>(exchange_value),
|
||||
reinterpret_cast<jint volatile*>(dest),
|
||||
PrimitiveConversions::cast<jint>(compare_value)));
|
||||
_Atomic_cmpxchg(PrimitiveConversions::cast<int32_t>(exchange_value),
|
||||
reinterpret_cast<int32_t volatile*>(dest),
|
||||
PrimitiveConversions::cast<int32_t>(compare_value)));
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -132,9 +132,9 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
cmpxchg_memory_order order) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
return PrimitiveConversions::cast<T>(
|
||||
_Atomic_cmpxchg_long(PrimitiveConversions::cast<jlong>(exchange_value),
|
||||
reinterpret_cast<jlong volatile*>(dest),
|
||||
PrimitiveConversions::cast<jlong>(compare_value)));
|
||||
_Atomic_cmpxchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
|
||||
reinterpret_cast<int64_t volatile*>(dest),
|
||||
PrimitiveConversions::cast<int64_t>(compare_value)));
|
||||
}
|
||||
|
||||
#endif // OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_HPP
|
||||
|
||||
@ -904,12 +904,12 @@ void os::Solaris::init_thread_fpu_state(void) {
|
||||
// until initialization is complete.
|
||||
// TODO - replace with .il implementation when compiler supports it.
|
||||
|
||||
typedef jint xchg_func_t (jint, volatile jint*);
|
||||
typedef jint cmpxchg_func_t (jint, volatile jint*, jint);
|
||||
typedef jlong cmpxchg_long_func_t(jlong, volatile jlong*, jlong);
|
||||
typedef jint add_func_t (jint, volatile jint*);
|
||||
typedef int32_t xchg_func_t (int32_t, volatile int32_t*);
|
||||
typedef int32_t cmpxchg_func_t (int32_t, volatile int32_t*, int32_t);
|
||||
typedef int64_t cmpxchg_long_func_t(int64_t, volatile int64_t*, int64_t);
|
||||
typedef int32_t add_func_t (int32_t, volatile int32_t*);
|
||||
|
||||
jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
|
||||
int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t* dest) {
|
||||
// try to use the stub:
|
||||
xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
|
||||
|
||||
@ -919,12 +919,12 @@ jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
|
||||
int32_t os::atomic_cmpxchg_bootstrap(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) {
|
||||
// try to use the stub:
|
||||
cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
|
||||
|
||||
@ -934,13 +934,13 @@ jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
|
||||
int64_t os::atomic_cmpxchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) {
|
||||
// try to use the stub:
|
||||
cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
|
||||
|
||||
@ -950,13 +950,13 @@ jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* de
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jlong old_value = *dest;
|
||||
int64_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
|
||||
int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t* dest) {
|
||||
// try to use the stub:
|
||||
add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2017, 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
|
||||
@ -31,15 +31,15 @@
|
||||
#ifdef AMD64
|
||||
static void setup_fpu() {}
|
||||
#else
|
||||
static jint (*atomic_xchg_func) (jint, volatile jint*);
|
||||
static jint (*atomic_cmpxchg_func) (jint, volatile jint*, jint);
|
||||
static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
|
||||
static jint (*atomic_add_func) (jint, volatile jint*);
|
||||
static int32_t (*atomic_xchg_func) (int32_t, volatile int32_t*);
|
||||
static int32_t (*atomic_cmpxchg_func) (int32_t, volatile int32_t*, int32_t);
|
||||
static int64_t (*atomic_cmpxchg_long_func)(int64_t, volatile int64_t*, int64_t);
|
||||
static int32_t (*atomic_add_func) (int32_t, volatile int32_t*);
|
||||
|
||||
static jint atomic_xchg_bootstrap (jint, volatile jint*);
|
||||
static jint atomic_cmpxchg_bootstrap (jint, volatile jint*, jint);
|
||||
static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
|
||||
static jint atomic_add_bootstrap (jint, volatile jint*);
|
||||
static int32_t atomic_xchg_bootstrap (int32_t, volatile int32_t*);
|
||||
static int32_t atomic_cmpxchg_bootstrap (int32_t, volatile int32_t*, int32_t);
|
||||
static int64_t atomic_cmpxchg_long_bootstrap(int64_t, volatile int64_t*, int64_t);
|
||||
static int32_t atomic_add_bootstrap (int32_t, volatile int32_t*);
|
||||
|
||||
static void setup_fpu();
|
||||
#endif // AMD64
|
||||
|
||||
@ -54,13 +54,13 @@ struct Atomic::PlatformAdd
|
||||
template<>
|
||||
template<typename I, typename D>
|
||||
inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
|
||||
return add_using_helper<jint>(os::atomic_add_func, add_value, dest);
|
||||
return add_using_helper<int32_t>(os::atomic_add_func, add_value, dest);
|
||||
}
|
||||
|
||||
template<>
|
||||
template<typename I, typename D>
|
||||
inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
|
||||
return add_using_helper<intptr_t>(os::atomic_add_ptr_func, add_value, dest);
|
||||
return add_using_helper<int64_t>(os::atomic_add_long_func, add_value, dest);
|
||||
}
|
||||
|
||||
#define DEFINE_STUB_XCHG(ByteSize, StubType, StubName) \
|
||||
@ -72,8 +72,8 @@ inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) co
|
||||
return xchg_using_helper<StubType>(StubName, exchange_value, dest); \
|
||||
}
|
||||
|
||||
DEFINE_STUB_XCHG(4, jint, os::atomic_xchg_func)
|
||||
DEFINE_STUB_XCHG(8, jlong, os::atomic_xchg_long_func)
|
||||
DEFINE_STUB_XCHG(4, int32_t, os::atomic_xchg_func)
|
||||
DEFINE_STUB_XCHG(8, int64_t, os::atomic_xchg_long_func)
|
||||
|
||||
#undef DEFINE_STUB_XCHG
|
||||
|
||||
@ -88,9 +88,9 @@ DEFINE_STUB_XCHG(8, jlong, os::atomic_xchg_long_func)
|
||||
return cmpxchg_using_helper<StubType>(StubName, exchange_value, dest, compare_value); \
|
||||
}
|
||||
|
||||
DEFINE_STUB_CMPXCHG(1, jbyte, os::atomic_cmpxchg_byte_func)
|
||||
DEFINE_STUB_CMPXCHG(4, jint, os::atomic_cmpxchg_func)
|
||||
DEFINE_STUB_CMPXCHG(8, jlong, os::atomic_cmpxchg_long_func)
|
||||
DEFINE_STUB_CMPXCHG(1, int8_t, os::atomic_cmpxchg_byte_func)
|
||||
DEFINE_STUB_CMPXCHG(4, int32_t, os::atomic_cmpxchg_func)
|
||||
DEFINE_STUB_CMPXCHG(8, int64_t, os::atomic_cmpxchg_long_func)
|
||||
|
||||
#undef DEFINE_STUB_CMPXCHG
|
||||
|
||||
@ -162,10 +162,10 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
|
||||
T compare_value,
|
||||
cmpxchg_memory_order order) const {
|
||||
STATIC_ASSERT(8 == sizeof(T));
|
||||
jint ex_lo = (jint)exchange_value;
|
||||
jint ex_hi = *( ((jint*)&exchange_value) + 1 );
|
||||
jint cmp_lo = (jint)compare_value;
|
||||
jint cmp_hi = *( ((jint*)&compare_value) + 1 );
|
||||
int32_t ex_lo = (int32_t)exchange_value;
|
||||
int32_t ex_hi = *( ((int32_t*)&exchange_value) + 1 );
|
||||
int32_t cmp_lo = (int32_t)compare_value;
|
||||
int32_t cmp_hi = *( ((int32_t*)&compare_value) + 1 );
|
||||
__asm {
|
||||
push ebx
|
||||
push edi
|
||||
|
||||
@ -218,17 +218,17 @@ void os::initialize_thread(Thread* thr) {
|
||||
|
||||
// Atomics and Stub Functions
|
||||
|
||||
typedef jint xchg_func_t (jint, volatile jint*);
|
||||
typedef intptr_t xchg_long_func_t (jlong, volatile jlong*);
|
||||
typedef jint cmpxchg_func_t (jint, volatile jint*, jint);
|
||||
typedef jbyte cmpxchg_byte_func_t (jbyte, volatile jbyte*, jbyte);
|
||||
typedef jlong cmpxchg_long_func_t (jlong, volatile jlong*, jlong);
|
||||
typedef jint add_func_t (jint, volatile jint*);
|
||||
typedef intptr_t add_ptr_func_t (intptr_t, volatile intptr_t*);
|
||||
typedef int32_t xchg_func_t (int32_t, volatile int32_t*);
|
||||
typedef int64_t xchg_long_func_t (int64_t, volatile int64_t*);
|
||||
typedef int32_t cmpxchg_func_t (int32_t, volatile int32_t*, int32_t);
|
||||
typedef int8_t cmpxchg_byte_func_t (int8_t, volatile int8_t*, int8_t);
|
||||
typedef int64_t cmpxchg_long_func_t (int64_t, volatile int64_t*, int64_t);
|
||||
typedef int32_t add_func_t (int32_t, volatile int32_t*);
|
||||
typedef int64_t add_long_func_t (int64_t, volatile int64_t*);
|
||||
|
||||
#ifdef AMD64
|
||||
|
||||
jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
|
||||
int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t* dest) {
|
||||
// try to use the stub:
|
||||
xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
|
||||
|
||||
@ -238,12 +238,12 @@ jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
intptr_t os::atomic_xchg_long_bootstrap(jlong exchange_value, volatile jlong* dest) {
|
||||
int64_t os::atomic_xchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest) {
|
||||
// try to use the stub:
|
||||
xchg_long_func_t* func = CAST_TO_FN_PTR(xchg_long_func_t*, StubRoutines::atomic_xchg_long_entry());
|
||||
|
||||
@ -253,13 +253,13 @@ intptr_t os::atomic_xchg_long_bootstrap(jlong exchange_value, volatile jlong* de
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
intptr_t old_value = *dest;
|
||||
int64_t old_value = *dest;
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
|
||||
jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
|
||||
int32_t os::atomic_cmpxchg_bootstrap(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) {
|
||||
// try to use the stub:
|
||||
cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
|
||||
|
||||
@ -269,13 +269,13 @@ jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jint old_value = *dest;
|
||||
int32_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
}
|
||||
|
||||
jbyte os::atomic_cmpxchg_byte_bootstrap(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) {
|
||||
int8_t os::atomic_cmpxchg_byte_bootstrap(int8_t exchange_value, volatile int8_t* dest, int8_t compare_value) {
|
||||
// try to use the stub:
|
||||
cmpxchg_byte_func_t* func = CAST_TO_FN_PTR(cmpxchg_byte_func_t*, StubRoutines::atomic_cmpxchg_byte_entry());
|
||||
|
||||
@ -285,7 +285,7 @@ jbyte os::atomic_cmpxchg_byte_bootstrap(jbyte exchange_value, volatile jbyte* de
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jbyte old_value = *dest;
|
||||
int8_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
@ -293,7 +293,7 @@ jbyte os::atomic_cmpxchg_byte_bootstrap(jbyte exchange_value, volatile jbyte* de
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
|
||||
int64_t os::atomic_cmpxchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) {
|
||||
// try to use the stub:
|
||||
cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
|
||||
|
||||
@ -303,7 +303,7 @@ jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* de
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
|
||||
jlong old_value = *dest;
|
||||
int64_t old_value = *dest;
|
||||
if (old_value == compare_value)
|
||||
*dest = exchange_value;
|
||||
return old_value;
|
||||
@ -311,7 +311,7 @@ jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* de
|
||||
|
||||
#ifdef AMD64
|
||||
|
||||
jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
|
||||
int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t* dest) {
|
||||
// try to use the stub:
|
||||
add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
|
||||
|
||||
@ -324,12 +324,12 @@ jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
|
||||
return (*dest) += add_value;
|
||||
}
|
||||
|
||||
intptr_t os::atomic_add_ptr_bootstrap(intptr_t add_value, volatile intptr_t* dest) {
|
||||
int64_t os::atomic_add_long_bootstrap(int64_t add_value, volatile int64_t* dest) {
|
||||
// try to use the stub:
|
||||
add_ptr_func_t* func = CAST_TO_FN_PTR(add_ptr_func_t*, StubRoutines::atomic_add_ptr_entry());
|
||||
add_long_func_t* func = CAST_TO_FN_PTR(add_long_func_t*, StubRoutines::atomic_add_long_entry());
|
||||
|
||||
if (func != NULL) {
|
||||
os::atomic_add_ptr_func = func;
|
||||
os::atomic_add_long_func = func;
|
||||
return (*func)(add_value, dest);
|
||||
}
|
||||
assert(Threads::number_of_threads() == 0, "for bootstrap only");
|
||||
@ -342,7 +342,7 @@ xchg_long_func_t* os::atomic_xchg_long_func = os::atomic_xchg_long_bootstr
|
||||
cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
|
||||
cmpxchg_byte_func_t* os::atomic_cmpxchg_byte_func = os::atomic_cmpxchg_byte_bootstrap;
|
||||
add_func_t* os::atomic_add_func = os::atomic_add_bootstrap;
|
||||
add_ptr_func_t* os::atomic_add_ptr_func = os::atomic_add_ptr_bootstrap;
|
||||
add_long_func_t* os::atomic_add_long_func = os::atomic_add_long_bootstrap;
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
|
||||
@ -29,32 +29,32 @@
|
||||
// NOTE: we are back in class os here, not win32
|
||||
//
|
||||
#ifdef AMD64
|
||||
static jint (*atomic_xchg_func) (jint, volatile jint*);
|
||||
static intptr_t (*atomic_xchg_long_func) (jlong, volatile jlong*);
|
||||
static int32_t (*atomic_xchg_func) (int32_t, volatile int32_t*);
|
||||
static int64_t (*atomic_xchg_long_func) (int64_t, volatile int64_t*);
|
||||
|
||||
static jint (*atomic_cmpxchg_func) (jint, volatile jint*, jint);
|
||||
static jbyte (*atomic_cmpxchg_byte_func) (jbyte, volatile jbyte*, jbyte);
|
||||
static jlong (*atomic_cmpxchg_long_func) (jlong, volatile jlong*, jlong);
|
||||
static int32_t (*atomic_cmpxchg_func) (int32_t, volatile int32_t*, int32_t);
|
||||
static int8_t (*atomic_cmpxchg_byte_func) (int8_t, volatile int8_t*, int8_t);
|
||||
static int64_t (*atomic_cmpxchg_long_func) (int64_t, volatile int64_t*, int64_t);
|
||||
|
||||
static jint (*atomic_add_func) (jint, volatile jint*);
|
||||
static intptr_t (*atomic_add_ptr_func) (intptr_t, volatile intptr_t*);
|
||||
static int32_t (*atomic_add_func) (int32_t, volatile int32_t*);
|
||||
static int64_t (*atomic_add_long_func) (int64_t, volatile int64_t*);
|
||||
|
||||
static jint atomic_xchg_bootstrap (jint, volatile jint*);
|
||||
static intptr_t atomic_xchg_long_bootstrap (jlong, volatile jlong*);
|
||||
static int32_t atomic_xchg_bootstrap (int32_t, volatile int32_t*);
|
||||
static int64_t atomic_xchg_long_bootstrap (int64_t, volatile int64_t*);
|
||||
|
||||
static jint atomic_cmpxchg_bootstrap (jint, volatile jint*, jint);
|
||||
static jbyte atomic_cmpxchg_byte_bootstrap(jbyte, volatile jbyte*, jbyte);
|
||||
static int32_t atomic_cmpxchg_bootstrap (int32_t, volatile int32_t*, int32_t);
|
||||
static int8_t atomic_cmpxchg_byte_bootstrap(int8_t, volatile int8_t*, int8_t);
|
||||
#else
|
||||
|
||||
static jlong (*atomic_cmpxchg_long_func) (jlong, volatile jlong*, jlong);
|
||||
static int64_t (*atomic_cmpxchg_long_func) (int64_t, volatile int64_t*, int64_t);
|
||||
|
||||
#endif // AMD64
|
||||
|
||||
static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
|
||||
static int64_t atomic_cmpxchg_long_bootstrap(int64_t, volatile int64_t*, int64_t);
|
||||
|
||||
#ifdef AMD64
|
||||
static jint atomic_add_bootstrap (jint, volatile jint*);
|
||||
static intptr_t atomic_add_ptr_bootstrap (intptr_t, volatile intptr_t*);
|
||||
static int32_t atomic_add_bootstrap (int32_t, volatile int32_t*);
|
||||
static int64_t atomic_add_long_bootstrap (int64_t, volatile int64_t*);
|
||||
#endif // AMD64
|
||||
|
||||
static void setup_fpu();
|
||||
|
||||
@ -315,12 +315,13 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
|
||||
return k;
|
||||
}
|
||||
|
||||
InstanceKlass* ClassListParser::load_current_class(TRAPS) {
|
||||
Klass* ClassListParser::load_current_class(TRAPS) {
|
||||
TempNewSymbol class_name_symbol = SymbolTable::new_symbol(_class_name, THREAD);
|
||||
guarantee(!HAS_PENDING_EXCEPTION, "Exception creating a symbol.");
|
||||
|
||||
InstanceKlass *klass = NULL;
|
||||
Klass *klass = NULL;
|
||||
if (!is_loading_from_source()) {
|
||||
// Load classes for the boot/platform/app loaders only.
|
||||
if (is_super_specified()) {
|
||||
error("If source location is not specified, super class must not be specified");
|
||||
}
|
||||
@ -330,40 +331,36 @@ InstanceKlass* ClassListParser::load_current_class(TRAPS) {
|
||||
|
||||
bool non_array = !FieldType::is_array(class_name_symbol);
|
||||
|
||||
Handle s = java_lang_String::create_from_symbol(class_name_symbol, CHECK_0);
|
||||
// Translate to external class name format, i.e., convert '/' chars to '.'
|
||||
Handle string = java_lang_String::externalize_classname(s, CHECK_0);
|
||||
JavaValue result(T_OBJECT);
|
||||
InstanceKlass* spec_klass = non_array ?
|
||||
SystemDictionary::ClassLoader_klass() : SystemDictionary::Class_klass();
|
||||
Symbol* method_name = non_array ?
|
||||
vmSymbols::loadClass_name() : vmSymbols::forName_name();
|
||||
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
|
||||
|
||||
if (non_array) {
|
||||
// At this point, we are executing in the context of the boot loader. We
|
||||
// cannot call Class.forName because that is context dependent and
|
||||
// would load only classes for the boot loader.
|
||||
//
|
||||
// Instead, let's call java_system_loader().loadClass() directly, which will
|
||||
// delegate to the correct loader (boot, platform or app) depending on
|
||||
// the class name.
|
||||
|
||||
Handle s = java_lang_String::create_from_symbol(class_name_symbol, CHECK_0);
|
||||
// ClassLoader.loadClass() wants external class name format, i.e., convert '/' chars to '.'
|
||||
Handle ext_class_name = java_lang_String::externalize_classname(s, CHECK_0);
|
||||
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
|
||||
|
||||
JavaCalls::call_virtual(&result,
|
||||
loader, //SystemDictionary::java_system_loader(),
|
||||
spec_klass,
|
||||
method_name, //vmSymbols::loadClass_name(),
|
||||
SystemDictionary::ClassLoader_klass(),
|
||||
vmSymbols::loadClass_name(),
|
||||
vmSymbols::string_class_signature(),
|
||||
string,
|
||||
ext_class_name,
|
||||
THREAD);
|
||||
} else {
|
||||
JavaCalls::call_static(&result,
|
||||
spec_klass,
|
||||
method_name,
|
||||
vmSymbols::string_class_signature(),
|
||||
string,
|
||||
CHECK_NULL);
|
||||
// array classes are not supported in class list.
|
||||
THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
|
||||
}
|
||||
assert(result.get_type() == T_OBJECT, "just checking");
|
||||
oop obj = (oop) result.get_jobject();
|
||||
if (!HAS_PENDING_EXCEPTION && (obj != NULL)) {
|
||||
if (non_array) {
|
||||
klass = InstanceKlass::cast(java_lang_Class::as_Klass(obj));
|
||||
} else {
|
||||
klass = static_cast<InstanceKlass*>(java_lang_Class::array_klass_acquire(obj));
|
||||
}
|
||||
klass = java_lang_Class::as_Klass(obj);
|
||||
} else { // load classes in bootclasspath/a
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
CLEAR_PENDING_EXCEPTION;
|
||||
@ -372,7 +369,7 @@ InstanceKlass* ClassListParser::load_current_class(TRAPS) {
|
||||
if (non_array) {
|
||||
Klass* k = SystemDictionary::resolve_or_null(class_name_symbol, CHECK_NULL);
|
||||
if (k != NULL) {
|
||||
klass = InstanceKlass::cast(k);
|
||||
klass = k;
|
||||
} else {
|
||||
if (!HAS_PENDING_EXCEPTION) {
|
||||
THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
|
||||
@ -388,14 +385,15 @@ InstanceKlass* ClassListParser::load_current_class(TRAPS) {
|
||||
}
|
||||
}
|
||||
|
||||
if (klass != NULL && is_id_specified()) {
|
||||
if (klass != NULL && klass->is_instance_klass() && is_id_specified()) {
|
||||
InstanceKlass* ik = InstanceKlass::cast(klass);
|
||||
int id = this->id();
|
||||
SystemDictionaryShared::update_shared_entry(klass, id);
|
||||
SystemDictionaryShared::update_shared_entry(ik, id);
|
||||
InstanceKlass* old = table()->lookup(id);
|
||||
if (old != NULL && old != klass) {
|
||||
if (old != NULL && old != ik) {
|
||||
error("Duplicated ID %d for class %s", id, _class_name);
|
||||
}
|
||||
table()->add(id, klass);
|
||||
table()->add(id, ik);
|
||||
}
|
||||
|
||||
return klass;
|
||||
|
||||
@ -136,7 +136,7 @@ public:
|
||||
return _class_name;
|
||||
}
|
||||
|
||||
InstanceKlass* load_current_class(TRAPS);
|
||||
Klass* load_current_class(TRAPS);
|
||||
|
||||
bool is_loading_from_source();
|
||||
|
||||
|
||||
@ -802,6 +802,14 @@ void ClassLoader::setup_boot_search_path(const char *class_path) {
|
||||
int end = 0;
|
||||
bool set_base_piece = true;
|
||||
|
||||
#if INCLUDE_CDS
|
||||
if (DumpSharedSpaces) {
|
||||
if (!Arguments::has_jimage()) {
|
||||
vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Iterate over class path entries
|
||||
for (int start = 0; start < len; start = end) {
|
||||
while (class_path[end] && class_path[end] != os::path_separator()[0]) {
|
||||
|
||||
@ -574,9 +574,9 @@ void ClassLoaderData::unload() {
|
||||
ls.cr();
|
||||
}
|
||||
|
||||
// In some rare cases items added to this list will not be freed elsewhere.
|
||||
// To keep it simple, just free everything in it here.
|
||||
free_deallocate_list();
|
||||
// Some items on the _deallocate_list need to free their C heap structures
|
||||
// if they are not already on the _klasses list.
|
||||
unload_deallocate_list();
|
||||
|
||||
// Clean up global class iterator for compiler
|
||||
static_klass_iterator.adjust_saved_class(this);
|
||||
@ -755,6 +755,7 @@ OopHandle ClassLoaderData::add_handle(Handle h) {
|
||||
}
|
||||
|
||||
void ClassLoaderData::remove_handle(OopHandle h) {
|
||||
assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading");
|
||||
oop* ptr = h.ptr_raw();
|
||||
if (ptr != NULL) {
|
||||
assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
|
||||
@ -799,6 +800,7 @@ void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
|
||||
void ClassLoaderData::free_deallocate_list() {
|
||||
// Don't need lock, at safepoint
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
||||
assert(!is_unloading(), "only called for ClassLoaderData that are not unloading");
|
||||
if (_deallocate_list == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -828,6 +830,29 @@ void ClassLoaderData::free_deallocate_list() {
|
||||
}
|
||||
}
|
||||
|
||||
// This is distinct from free_deallocate_list. For class loader data that are
|
||||
// unloading, this frees the C heap memory for constant pools on the list. If there
|
||||
// were C heap memory allocated for methods, it would free that too. The C heap memory
|
||||
// for InstanceKlasses on this list is freed in the ClassLoaderData destructor.
|
||||
void ClassLoaderData::unload_deallocate_list() {
|
||||
// Don't need lock, at safepoint
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
||||
assert(is_unloading(), "only called for ClassLoaderData that are unloading");
|
||||
if (_deallocate_list == NULL) {
|
||||
return;
|
||||
}
|
||||
// Go backwards because this removes entries that are freed.
|
||||
for (int i = _deallocate_list->length() - 1; i >= 0; i--) {
|
||||
Metadata* m = _deallocate_list->at(i);
|
||||
assert (!m->on_stack(), "wouldn't be unloading if this were so");
|
||||
_deallocate_list->remove_at(i);
|
||||
// Only constant pool entries have C heap memory to free.
|
||||
if (m->is_constantPool()) {
|
||||
((ConstantPool*)m)->release_C_heap_structures();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// These anonymous class loaders are to contain classes used for JSR292
|
||||
ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(oop loader, TRAPS) {
|
||||
// Add a new class loader data to the graph.
|
||||
|
||||
@ -307,7 +307,8 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
void packages_do(void f(PackageEntry*));
|
||||
|
||||
// Deallocate free list during class unloading.
|
||||
void free_deallocate_list();
|
||||
void free_deallocate_list(); // for the classes that are not unloaded
|
||||
void unload_deallocate_list(); // for the classes that are unloaded
|
||||
|
||||
// Allocate out of this class loader data
|
||||
MetaWord* allocate(size_t size);
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "classfile/bytecodeAssembler.hpp"
|
||||
#include "classfile/defaultMethods.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
@ -683,10 +684,11 @@ class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> {
|
||||
Symbol* _method_name;
|
||||
Symbol* _method_signature;
|
||||
StatefulMethodFamily* _family;
|
||||
bool _cur_class_is_interface;
|
||||
|
||||
public:
|
||||
FindMethodsByErasedSig(Symbol* name, Symbol* signature) :
|
||||
_method_name(name), _method_signature(signature),
|
||||
FindMethodsByErasedSig(Symbol* name, Symbol* signature, bool is_interf) :
|
||||
_method_name(name), _method_signature(signature), _cur_class_is_interface(is_interf),
|
||||
_family(NULL) {}
|
||||
|
||||
void get_discovered_family(MethodFamily** family) {
|
||||
@ -709,14 +711,17 @@ class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> {
|
||||
InstanceKlass* iklass = current_class();
|
||||
|
||||
Method* m = iklass->find_method(_method_name, _method_signature);
|
||||
// private interface methods are not candidates for default methods
|
||||
// invokespecial to private interface methods doesn't use default method logic
|
||||
// private class methods are not candidates for default methods,
|
||||
// private methods do not override default methods, so need to perform
|
||||
// default method inheritance without including private methods
|
||||
// The overpasses are your supertypes' errors, we do not include them
|
||||
// future: take access controls into account for superclass methods
|
||||
if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private()) {
|
||||
// Private interface methods are not candidates for default methods.
|
||||
// invokespecial to private interface methods doesn't use default method logic.
|
||||
// Private class methods are not candidates for default methods.
|
||||
// Private methods do not override default methods, so need to perform
|
||||
// default method inheritance without including private methods.
|
||||
// The overpasses are your supertypes' errors, we do not include them.
|
||||
// Non-public methods in java.lang.Object are not candidates for default
|
||||
// methods.
|
||||
// Future: take access controls into account for superclass methods
|
||||
if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private() &&
|
||||
(!_cur_class_is_interface || !SystemDictionary::is_nonpublic_Object_method(m))) {
|
||||
if (_family == NULL) {
|
||||
_family = new StatefulMethodFamily();
|
||||
}
|
||||
@ -726,8 +731,8 @@ class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> {
|
||||
scope->add_mark(restorer);
|
||||
} else {
|
||||
// This is the rule that methods in classes "win" (bad word) over
|
||||
// methods in interfaces. This works because of single inheritance
|
||||
// private methods in classes do not "win", they will be found
|
||||
// methods in interfaces. This works because of single inheritance.
|
||||
// Private methods in classes do not "win", they will be found
|
||||
// first on searching, but overriding for invokevirtual needs
|
||||
// to find default method candidates for the same signature
|
||||
_family->set_target_if_empty(m);
|
||||
@ -745,10 +750,10 @@ static void create_defaults_and_exceptions(
|
||||
|
||||
static void generate_erased_defaults(
|
||||
InstanceKlass* klass, GrowableArray<EmptyVtableSlot*>* empty_slots,
|
||||
EmptyVtableSlot* slot, TRAPS) {
|
||||
EmptyVtableSlot* slot, bool is_intf, TRAPS) {
|
||||
|
||||
// sets up a set of methods with the same exact erased signature
|
||||
FindMethodsByErasedSig visitor(slot->name(), slot->signature());
|
||||
FindMethodsByErasedSig visitor(slot->name(), slot->signature(), is_intf);
|
||||
visitor.run(klass);
|
||||
|
||||
MethodFamily* family;
|
||||
@ -817,7 +822,7 @@ void DefaultMethods::generate_default_methods(
|
||||
slot->print_on(&ls);
|
||||
ls.cr();
|
||||
}
|
||||
generate_erased_defaults(klass, empty_slots, slot, CHECK);
|
||||
generate_erased_defaults(klass, empty_slots, slot, klass->is_interface(), CHECK);
|
||||
}
|
||||
log_debug(defaultmethods)("Creating defaults and overpasses...");
|
||||
create_defaults_and_exceptions(empty_slots, klass, CHECK);
|
||||
|
||||
@ -649,6 +649,12 @@ public:
|
||||
static bool is_platform_class_loader(oop class_loader);
|
||||
static void clear_invoke_method_table();
|
||||
|
||||
// Returns TRUE if the method is a non-public member of class java.lang.Object.
|
||||
static bool is_nonpublic_Object_method(Method* m) {
|
||||
assert(m != NULL, "Unexpected NULL Method*");
|
||||
return !m->is_public() && m->method_holder() == SystemDictionary::Object_klass();
|
||||
}
|
||||
|
||||
protected:
|
||||
static InstanceKlass* find_shared_class(Symbol* class_name);
|
||||
|
||||
|
||||
@ -1852,17 +1852,23 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
|
||||
TraceTime t1("compilation", &time);
|
||||
EventCompilation event;
|
||||
|
||||
JVMCIEnv env(task, system_dictionary_modification_counter);
|
||||
methodHandle method(thread, target_handle);
|
||||
jvmci->compile_method(method, osr_bci, &env);
|
||||
// Skip redefined methods
|
||||
if (target_handle->is_old()) {
|
||||
failure_reason = "redefined method";
|
||||
retry_message = "not retryable";
|
||||
compilable = ciEnv::MethodCompilable_never;
|
||||
} else {
|
||||
JVMCIEnv env(task, system_dictionary_modification_counter);
|
||||
methodHandle method(thread, target_handle);
|
||||
jvmci->compile_method(method, osr_bci, &env);
|
||||
|
||||
post_compile(thread, task, event, task->code() != NULL, NULL);
|
||||
|
||||
failure_reason = env.failure_reason();
|
||||
if (!env.retryable()) {
|
||||
retry_message = "not retryable";
|
||||
compilable = ciEnv::MethodCompilable_not_at_tier;
|
||||
failure_reason = env.failure_reason();
|
||||
if (!env.retryable()) {
|
||||
retry_message = "not retryable";
|
||||
compilable = ciEnv::MethodCompilable_not_at_tier;
|
||||
}
|
||||
}
|
||||
post_compile(thread, task, event, task->code() != NULL, NULL);
|
||||
|
||||
} else
|
||||
#endif // INCLUDE_JVMCI
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2017, 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
|
||||
@ -42,17 +42,17 @@ void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) {
|
||||
|
||||
// Make sure that any allocation attempt on this region will fail
|
||||
// and will not trigger any asserts.
|
||||
assert(allocate(dummy_region, 1, false) == NULL, "should fail");
|
||||
assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
|
||||
assert(allocate(dummy_region, 1, true) == NULL, "should fail");
|
||||
assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
|
||||
assert(dummy_region->allocate_no_bot_updates(1) == NULL, "should fail");
|
||||
assert(dummy_region->allocate(1) == NULL, "should fail");
|
||||
DEBUG_ONLY(size_t assert_tmp);
|
||||
assert(dummy_region->par_allocate_no_bot_updates(1, 1, &assert_tmp) == NULL, "should fail");
|
||||
assert(dummy_region->par_allocate(1, 1, &assert_tmp) == NULL, "should fail");
|
||||
|
||||
_g1h = g1h;
|
||||
_dummy_region = dummy_region;
|
||||
}
|
||||
|
||||
size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region,
|
||||
bool bot_updates) {
|
||||
size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region) {
|
||||
assert(alloc_region != NULL && alloc_region != _dummy_region,
|
||||
"pre-condition");
|
||||
size_t result = 0;
|
||||
@ -74,7 +74,7 @@ size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region,
|
||||
size_t min_word_size_to_fill = CollectedHeap::min_fill_size();
|
||||
|
||||
while (free_word_size >= min_word_size_to_fill) {
|
||||
HeapWord* dummy = par_allocate(alloc_region, free_word_size, bot_updates);
|
||||
HeapWord* dummy = par_allocate(alloc_region, free_word_size);
|
||||
if (dummy != NULL) {
|
||||
// If the allocation was successful we should fill in the space.
|
||||
CollectedHeap::fill_with_object(dummy, free_word_size);
|
||||
@ -110,7 +110,7 @@ size_t G1AllocRegion::retire(bool fill_up) {
|
||||
"the alloc region should never be empty");
|
||||
|
||||
if (fill_up) {
|
||||
result = fill_up_remaining_space(alloc_region, _bot_updates);
|
||||
result = fill_up_remaining_space(alloc_region);
|
||||
}
|
||||
|
||||
assert_alloc_region(alloc_region->used() >= _used_bytes_before, "invariant");
|
||||
@ -135,7 +135,7 @@ HeapWord* G1AllocRegion::new_alloc_region_and_allocate(size_t word_size,
|
||||
new_alloc_region->reset_pre_dummy_top();
|
||||
// Need to do this before the allocation
|
||||
_used_bytes_before = new_alloc_region->used();
|
||||
HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates);
|
||||
HeapWord* result = allocate(new_alloc_region, word_size);
|
||||
assert_alloc_region(result != NULL, "the allocation should succeeded");
|
||||
|
||||
OrderAccess::storestore();
|
||||
@ -301,7 +301,7 @@ HeapRegion* OldGCAllocRegion::release() {
|
||||
// possible object. In this case this region will not be retained, so the
|
||||
// original problem cannot occur.
|
||||
if (to_allocate_words >= G1CollectedHeap::min_fill_size()) {
|
||||
HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */);
|
||||
HeapWord* dummy = attempt_allocation(to_allocate_words);
|
||||
CollectedHeap::fill_with_object(dummy, to_allocate_words);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2017, 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
|
||||
@ -83,37 +83,27 @@ private:
|
||||
// whether the _alloc_region is NULL or not.
|
||||
static HeapRegion* _dummy_region;
|
||||
|
||||
// Some of the methods below take a bot_updates parameter. Its value
|
||||
// should be the same as the _bot_updates field. The idea is that
|
||||
// the parameter will be a constant for a particular alloc region
|
||||
// and, given that these methods will be hopefully inlined, the
|
||||
// compiler should compile out the test.
|
||||
|
||||
// Perform a non-MT-safe allocation out of the given region.
|
||||
static inline HeapWord* allocate(HeapRegion* alloc_region,
|
||||
size_t word_size,
|
||||
bool bot_updates);
|
||||
inline HeapWord* allocate(HeapRegion* alloc_region,
|
||||
size_t word_size);
|
||||
|
||||
// Perform a MT-safe allocation out of the given region.
|
||||
static inline HeapWord* par_allocate(HeapRegion* alloc_region,
|
||||
size_t word_size,
|
||||
bool bot_updates);
|
||||
inline HeapWord* par_allocate(HeapRegion* alloc_region,
|
||||
size_t word_size);
|
||||
// Perform a MT-safe allocation out of the given region, with the given
|
||||
// minimum and desired size. Returns the actual size allocated (between
|
||||
// minimum and desired size) in actual_word_size if the allocation has been
|
||||
// successful.
|
||||
static inline HeapWord* par_allocate(HeapRegion* alloc_region,
|
||||
size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size,
|
||||
bool bot_updates);
|
||||
inline HeapWord* par_allocate(HeapRegion* alloc_region,
|
||||
size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size);
|
||||
|
||||
// Ensure that the region passed as a parameter has been filled up
|
||||
// so that noone else can allocate out of it any more.
|
||||
// Returns the number of bytes that have been wasted by filled up
|
||||
// the space.
|
||||
static size_t fill_up_remaining_space(HeapRegion* alloc_region,
|
||||
bool bot_updates);
|
||||
size_t fill_up_remaining_space(HeapRegion* alloc_region);
|
||||
|
||||
// After a region is allocated by alloc_new_region, this
|
||||
// method is used to set it as the active alloc_region
|
||||
@ -160,8 +150,7 @@ public:
|
||||
// First-level allocation: Should be called without holding a
|
||||
// lock. It will try to allocate lock-free out of the active region,
|
||||
// or return NULL if it was unable to.
|
||||
inline HeapWord* attempt_allocation(size_t word_size,
|
||||
bool bot_updates);
|
||||
inline HeapWord* attempt_allocation(size_t word_size);
|
||||
// Perform an allocation out of the current allocation region, with the given
|
||||
// minimum and desired size. Returns the actual size allocated (between
|
||||
// minimum and desired size) in actual_word_size if the allocation has been
|
||||
@ -170,8 +159,7 @@ public:
|
||||
// out of the active region, or return NULL if it was unable to.
|
||||
inline HeapWord* attempt_allocation(size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size,
|
||||
bool bot_updates);
|
||||
size_t* actual_word_size);
|
||||
|
||||
// Second-level allocation: Should be called while holding a
|
||||
// lock. It will try to first allocate lock-free out of the active
|
||||
@ -179,23 +167,20 @@ public:
|
||||
// alloc region with a new one. We require that the caller takes the
|
||||
// appropriate lock before calling this so that it is easier to make
|
||||
// it conform to its locking protocol.
|
||||
inline HeapWord* attempt_allocation_locked(size_t word_size,
|
||||
bool bot_updates);
|
||||
inline HeapWord* attempt_allocation_locked(size_t word_size);
|
||||
// Same as attempt_allocation_locked(size_t, bool), but allowing specification
|
||||
// of minimum word size of the block in min_word_size, and the maximum word
|
||||
// size of the allocation in desired_word_size. The actual size of the block is
|
||||
// returned in actual_word_size.
|
||||
inline HeapWord* attempt_allocation_locked(size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size,
|
||||
bool bot_updates);
|
||||
size_t* actual_word_size);
|
||||
|
||||
// Should be called to allocate a new region even if the max of this
|
||||
// type of regions has been reached. Should only be called if other
|
||||
// allocation attempts have failed and we are not holding a valid
|
||||
// active region.
|
||||
inline HeapWord* attempt_allocation_force(size_t word_size,
|
||||
bool bot_updates);
|
||||
inline HeapWord* attempt_allocation_force(size_t word_size);
|
||||
|
||||
// Should be called before we start using this object.
|
||||
void init();
|
||||
@ -236,7 +221,7 @@ protected:
|
||||
virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes);
|
||||
|
||||
virtual size_t retire(bool fill_up);
|
||||
public:
|
||||
|
||||
G1GCAllocRegion(const char* name, bool bot_updates, G1EvacStats* stats, InCSetState::in_cset_state_t purpose)
|
||||
: G1AllocRegion(name, bot_updates), _stats(stats), _purpose(purpose) {
|
||||
assert(stats != NULL, "Must pass non-NULL PLAB statistics");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2017, 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
|
||||
@ -37,52 +37,47 @@
|
||||
|
||||
|
||||
inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
|
||||
size_t word_size,
|
||||
bool bot_updates) {
|
||||
size_t word_size) {
|
||||
assert(alloc_region != NULL, "pre-condition");
|
||||
|
||||
if (!bot_updates) {
|
||||
if (!_bot_updates) {
|
||||
return alloc_region->allocate_no_bot_updates(word_size);
|
||||
} else {
|
||||
return alloc_region->allocate(word_size);
|
||||
}
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size, bool bot_updates) {
|
||||
inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size) {
|
||||
size_t temp;
|
||||
return par_allocate(alloc_region, word_size, word_size, &temp, bot_updates);
|
||||
return par_allocate(alloc_region, word_size, word_size, &temp);
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
|
||||
size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size,
|
||||
bool bot_updates) {
|
||||
size_t* actual_word_size) {
|
||||
assert(alloc_region != NULL, "pre-condition");
|
||||
assert(!alloc_region->is_empty(), "pre-condition");
|
||||
|
||||
if (!bot_updates) {
|
||||
if (!_bot_updates) {
|
||||
return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
|
||||
} else {
|
||||
return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
|
||||
}
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size, bool bot_updates) {
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size) {
|
||||
size_t temp;
|
||||
return attempt_allocation(word_size, word_size, &temp, bot_updates);
|
||||
return attempt_allocation(word_size, word_size, &temp);
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size,
|
||||
bool bot_updates) {
|
||||
assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
|
||||
|
||||
size_t* actual_word_size) {
|
||||
HeapRegion* alloc_region = _alloc_region;
|
||||
assert_alloc_region(alloc_region != NULL, "not initialized properly");
|
||||
|
||||
HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
|
||||
HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size);
|
||||
if (result != NULL) {
|
||||
trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
|
||||
return result;
|
||||
@ -91,19 +86,18 @@ inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size, bool bot_updates) {
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size) {
|
||||
size_t temp;
|
||||
return attempt_allocation_locked(word_size, word_size, &temp, bot_updates);
|
||||
return attempt_allocation_locked(word_size, word_size, &temp);
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
|
||||
size_t desired_word_size,
|
||||
size_t* actual_word_size,
|
||||
bool bot_updates) {
|
||||
size_t* actual_word_size) {
|
||||
// First we have to redo the allocation, assuming we're holding the
|
||||
// appropriate lock, in case another thread changed the region while
|
||||
// we were waiting to get the lock.
|
||||
HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size, bot_updates);
|
||||
HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
@ -119,9 +113,7 @@ inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
|
||||
bool bot_updates) {
|
||||
assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
|
||||
inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size) {
|
||||
assert_alloc_region(_alloc_region != NULL, "not initialized properly");
|
||||
|
||||
trace("forcing alloc", word_size, word_size);
|
||||
|
||||
@ -190,14 +190,12 @@ HeapWord* G1Allocator::survivor_attempt_allocation(size_t min_word_size,
|
||||
|
||||
HeapWord* result = survivor_gc_alloc_region(context)->attempt_allocation(min_word_size,
|
||||
desired_word_size,
|
||||
actual_word_size,
|
||||
false /* bot_updates */);
|
||||
actual_word_size);
|
||||
if (result == NULL && !survivor_is_full(context)) {
|
||||
MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
|
||||
result = survivor_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
|
||||
desired_word_size,
|
||||
actual_word_size,
|
||||
false /* bot_updates */);
|
||||
actual_word_size);
|
||||
if (result == NULL) {
|
||||
set_survivor_full(context);
|
||||
}
|
||||
@ -217,14 +215,12 @@ HeapWord* G1Allocator::old_attempt_allocation(size_t min_word_size,
|
||||
|
||||
HeapWord* result = old_gc_alloc_region(context)->attempt_allocation(min_word_size,
|
||||
desired_word_size,
|
||||
actual_word_size,
|
||||
true /* bot_updates */);
|
||||
actual_word_size);
|
||||
if (result == NULL && !old_is_full(context)) {
|
||||
MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
|
||||
result = old_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
|
||||
desired_word_size,
|
||||
actual_word_size,
|
||||
true /* bot_updates */);
|
||||
actual_word_size);
|
||||
if (result == NULL) {
|
||||
set_old_full(context);
|
||||
}
|
||||
|
||||
@ -30,18 +30,18 @@
|
||||
#include "gc/shared/plab.inline.hpp"
|
||||
|
||||
HeapWord* G1Allocator::attempt_allocation(size_t word_size, AllocationContext_t context) {
|
||||
return mutator_alloc_region(context)->attempt_allocation(word_size, false /* bot_updates */);
|
||||
return mutator_alloc_region(context)->attempt_allocation(word_size);
|
||||
}
|
||||
|
||||
HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size, AllocationContext_t context) {
|
||||
HeapWord* result = mutator_alloc_region(context)->attempt_allocation_locked(word_size, false /* bot_updates */);
|
||||
HeapWord* result = mutator_alloc_region(context)->attempt_allocation_locked(word_size);
|
||||
assert(result != NULL || mutator_alloc_region(context)->get() == NULL,
|
||||
"Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region(context)->get()));
|
||||
return result;
|
||||
}
|
||||
|
||||
HeapWord* G1Allocator::attempt_allocation_force(size_t word_size, AllocationContext_t context) {
|
||||
return mutator_alloc_region(context)->attempt_allocation_force(word_size, false /* bot_updates */);
|
||||
return mutator_alloc_region(context)->attempt_allocation_force(word_size);
|
||||
}
|
||||
|
||||
inline HeapWord* G1PLABAllocator::plab_allocate(InCSetState dest,
|
||||
|
||||
@ -761,6 +761,10 @@ C2V_END
|
||||
|
||||
C2V_VMENTRY(jboolean, isCompilable,(JNIEnv *, jobject, jobject jvmci_method))
|
||||
methodHandle method = CompilerToVM::asMethod(jvmci_method);
|
||||
// Skip redefined methods
|
||||
if (method->is_old()) {
|
||||
return false;
|
||||
}
|
||||
return !method->is_not_compilable(CompLevel_full_optimization);
|
||||
C2V_END
|
||||
|
||||
|
||||
@ -3695,7 +3695,6 @@ void Metaspace::ergo_initialize() {
|
||||
MaxMetaspaceExpansion = align_down_bounded(MaxMetaspaceExpansion, _commit_alignment);
|
||||
|
||||
CompressedClassSpaceSize = align_down_bounded(CompressedClassSpaceSize, _reserve_alignment);
|
||||
set_compressed_class_space_size(CompressedClassSpaceSize);
|
||||
|
||||
// Initial virtual space size will be calculated at global_initialize()
|
||||
size_t min_metaspace_sz =
|
||||
@ -3714,6 +3713,7 @@ void Metaspace::ergo_initialize() {
|
||||
min_metaspace_sz);
|
||||
}
|
||||
|
||||
set_compressed_class_space_size(CompressedClassSpaceSize);
|
||||
}
|
||||
|
||||
void Metaspace::global_initialize() {
|
||||
|
||||
@ -1627,14 +1627,16 @@ int MetaspaceShared::preload_classes(const char* class_list_path, TRAPS) {
|
||||
log_trace(cds)("Shared spaces preloaded: %s", klass->external_name());
|
||||
}
|
||||
|
||||
InstanceKlass* ik = InstanceKlass::cast(klass);
|
||||
if (klass->is_instance_klass()) {
|
||||
InstanceKlass* ik = InstanceKlass::cast(klass);
|
||||
|
||||
// Link the class to cause the bytecodes to be rewritten and the
|
||||
// cpcache to be created. The linking is done as soon as classes
|
||||
// are loaded in order that the related data structures (klass and
|
||||
// cpCache) are located together.
|
||||
try_link_class(ik, THREAD);
|
||||
guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");
|
||||
// Link the class to cause the bytecodes to be rewritten and the
|
||||
// cpcache to be created. The linking is done as soon as classes
|
||||
// are loaded in order that the related data structures (klass and
|
||||
// cpCache) are located together.
|
||||
try_link_class(ik, THREAD);
|
||||
guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");
|
||||
}
|
||||
|
||||
class_count++;
|
||||
}
|
||||
|
||||
@ -177,6 +177,7 @@ void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_co
|
||||
// instruction somehow links to a non-interface method (in Object).
|
||||
// In that case, the method has no itable index and must be invoked as a virtual.
|
||||
// Set a flag to keep track of this corner case.
|
||||
assert(method->is_public(), "Calling non-public method in Object with invokeinterface");
|
||||
change_to_virtual = true;
|
||||
|
||||
// ...and fall through as if we were handling invokevirtual:
|
||||
|
||||
@ -86,13 +86,14 @@ void klassVtable::compute_vtable_size_and_num_mirandas(
|
||||
|
||||
GrowableArray<Method*> new_mirandas(20);
|
||||
// compute the number of mirandas methods that must be added to the end
|
||||
get_mirandas(&new_mirandas, all_mirandas, super, methods, NULL, local_interfaces);
|
||||
get_mirandas(&new_mirandas, all_mirandas, super, methods, NULL, local_interfaces,
|
||||
class_flags.is_interface());
|
||||
*num_new_mirandas = new_mirandas.length();
|
||||
|
||||
// Interfaces do not need interface methods in their vtables
|
||||
// This includes miranda methods and during later processing, default methods
|
||||
if (!class_flags.is_interface()) {
|
||||
vtable_length += *num_new_mirandas * vtableEntry::size();
|
||||
vtable_length += *num_new_mirandas * vtableEntry::size();
|
||||
}
|
||||
|
||||
if (Universe::is_bootstrapping() && vtable_length == 0) {
|
||||
@ -454,8 +455,13 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, const methodHand
|
||||
} else {
|
||||
super_method = method_at(i);
|
||||
}
|
||||
// Check if method name matches
|
||||
if (super_method->name() == name && super_method->signature() == signature) {
|
||||
// Check if method name matches. Ignore match if klass is an interface and the
|
||||
// matching method is a non-public java.lang.Object method. (See JVMS 5.4.3.4)
|
||||
// This is safe because the method at this slot should never get invoked.
|
||||
// (TBD: put in a method to throw NoSuchMethodError if this slot is ever used.)
|
||||
if (super_method->name() == name && super_method->signature() == signature &&
|
||||
(!_klass->is_interface() ||
|
||||
!SystemDictionary::is_nonpublic_Object_method(super_method))) {
|
||||
|
||||
// get super_klass for method_holder for the found method
|
||||
InstanceKlass* super_klass = super_method->method_holder();
|
||||
@ -713,7 +719,7 @@ bool klassVtable::is_miranda_entry_at(int i) {
|
||||
if (mhk->is_interface()) {
|
||||
assert(m->is_public(), "should be public");
|
||||
assert(ik()->implements_interface(method_holder) , "this class should implement the interface");
|
||||
if (is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->super())) {
|
||||
if (is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->super(), klass()->is_interface())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -738,7 +744,10 @@ bool klassVtable::is_miranda_entry_at(int i) {
|
||||
// During the first run, the current instanceKlass has not yet been
|
||||
// created, the superclasses and superinterfaces do have instanceKlasses
|
||||
// but may not have vtables, the default_methods list is empty, no overpasses.
|
||||
// This is seen by default method creation.
|
||||
// Default method generation uses the all_mirandas array as the starter set for
|
||||
// maximally-specific default method calculation. So, for both classes and
|
||||
// interfaces, it is necessary that the first pass will find all non-private
|
||||
// interface instance methods, whether or not they are concrete.
|
||||
//
|
||||
// Pass 2: recalculated during vtable initialization: only include abstract methods.
|
||||
// The goal of pass 2 is to walk through the superinterfaces to see if any of
|
||||
@ -772,7 +781,8 @@ bool klassVtable::is_miranda_entry_at(int i) {
|
||||
// Part of the Miranda Rights in the US mean that if you do not have
|
||||
// an attorney one will be appointed for you.
|
||||
bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
|
||||
Array<Method*>* default_methods, const Klass* super) {
|
||||
Array<Method*>* default_methods, const Klass* super,
|
||||
bool is_interface) {
|
||||
if (m->is_static() || m->is_private() || m->is_overpass()) {
|
||||
return false;
|
||||
}
|
||||
@ -800,8 +810,11 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
|
||||
|
||||
for (const Klass* cursuper = super; cursuper != NULL; cursuper = cursuper->super())
|
||||
{
|
||||
if (InstanceKlass::cast(cursuper)->find_local_method(name, signature,
|
||||
Klass::find_overpass, Klass::skip_static, Klass::skip_private) != NULL) {
|
||||
Method* found_mth = InstanceKlass::cast(cursuper)->find_local_method(name, signature,
|
||||
Klass::find_overpass, Klass::skip_static, Klass::skip_private);
|
||||
// Ignore non-public methods in java.lang.Object if klass is an interface.
|
||||
if (found_mth != NULL && (!is_interface ||
|
||||
!SystemDictionary::is_nonpublic_Object_method(found_mth))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -820,7 +833,7 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
|
||||
void klassVtable::add_new_mirandas_to_lists(
|
||||
GrowableArray<Method*>* new_mirandas, GrowableArray<Method*>* all_mirandas,
|
||||
Array<Method*>* current_interface_methods, Array<Method*>* class_methods,
|
||||
Array<Method*>* default_methods, const Klass* super) {
|
||||
Array<Method*>* default_methods, const Klass* super, bool is_interface) {
|
||||
|
||||
// iterate thru the current interface's method to see if it a miranda
|
||||
int num_methods = current_interface_methods->length();
|
||||
@ -839,7 +852,7 @@ void klassVtable::add_new_mirandas_to_lists(
|
||||
}
|
||||
|
||||
if (!is_duplicate) { // we don't want duplicate miranda entries in the vtable
|
||||
if (is_miranda(im, class_methods, default_methods, super)) { // is it a miranda at all?
|
||||
if (is_miranda(im, class_methods, default_methods, super, is_interface)) { // is it a miranda at all?
|
||||
const InstanceKlass *sk = InstanceKlass::cast(super);
|
||||
// check if it is a duplicate of a super's miranda
|
||||
if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::find_defaults) == NULL) {
|
||||
@ -858,7 +871,8 @@ void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
|
||||
const Klass* super,
|
||||
Array<Method*>* class_methods,
|
||||
Array<Method*>* default_methods,
|
||||
Array<Klass*>* local_interfaces) {
|
||||
Array<Klass*>* local_interfaces,
|
||||
bool is_interface) {
|
||||
assert((new_mirandas->length() == 0) , "current mirandas must be 0");
|
||||
|
||||
// iterate thru the local interfaces looking for a miranda
|
||||
@ -867,7 +881,7 @@ void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
|
||||
InstanceKlass *ik = InstanceKlass::cast(local_interfaces->at(i));
|
||||
add_new_mirandas_to_lists(new_mirandas, all_mirandas,
|
||||
ik->methods(), class_methods,
|
||||
default_methods, super);
|
||||
default_methods, super, is_interface);
|
||||
// iterate thru each local's super interfaces
|
||||
Array<Klass*>* super_ifs = ik->transitive_interfaces();
|
||||
int num_super_ifs = super_ifs->length();
|
||||
@ -875,7 +889,7 @@ void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
|
||||
InstanceKlass *sik = InstanceKlass::cast(super_ifs->at(j));
|
||||
add_new_mirandas_to_lists(new_mirandas, all_mirandas,
|
||||
sik->methods(), class_methods,
|
||||
default_methods, super);
|
||||
default_methods, super, is_interface);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -888,7 +902,8 @@ void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
|
||||
int klassVtable::fill_in_mirandas(int initialized) {
|
||||
GrowableArray<Method*> mirandas(20);
|
||||
get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
|
||||
ik()->default_methods(), ik()->local_interfaces());
|
||||
ik()->default_methods(), ik()->local_interfaces(),
|
||||
klass()->is_interface());
|
||||
for (int i = 0; i < mirandas.length(); i++) {
|
||||
if (log_develop_is_enabled(Trace, vtables)) {
|
||||
Method* meth = mirandas.at(i);
|
||||
|
||||
@ -144,21 +144,24 @@ class klassVtable VALUE_OBJ_CLASS_SPEC {
|
||||
bool is_miranda_entry_at(int i);
|
||||
int fill_in_mirandas(int initialized);
|
||||
static bool is_miranda(Method* m, Array<Method*>* class_methods,
|
||||
Array<Method*>* default_methods, const Klass* super);
|
||||
Array<Method*>* default_methods, const Klass* super,
|
||||
bool is_interface);
|
||||
static void add_new_mirandas_to_lists(
|
||||
GrowableArray<Method*>* new_mirandas,
|
||||
GrowableArray<Method*>* all_mirandas,
|
||||
Array<Method*>* current_interface_methods,
|
||||
Array<Method*>* class_methods,
|
||||
Array<Method*>* default_methods,
|
||||
const Klass* super);
|
||||
const Klass* super,
|
||||
bool is_interface);
|
||||
static void get_mirandas(
|
||||
GrowableArray<Method*>* new_mirandas,
|
||||
GrowableArray<Method*>* all_mirandas,
|
||||
const Klass* super,
|
||||
Array<Method*>* class_methods,
|
||||
Array<Method*>* default_methods,
|
||||
Array<Klass*>* local_interfaces);
|
||||
Array<Klass*>* local_interfaces,
|
||||
bool is_interface);
|
||||
void verify_against(outputStream* st, klassVtable* vt, int index);
|
||||
inline InstanceKlass* ik() const;
|
||||
// When loading a class from CDS archive at run time, and no class redefintion
|
||||
|
||||
@ -1789,10 +1789,19 @@ bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) {
|
||||
return StubRoutines::dexp() != NULL ?
|
||||
runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dexp(), "dexp") :
|
||||
runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp), "EXP");
|
||||
case vmIntrinsics::_dpow:
|
||||
return StubRoutines::dpow() != NULL ?
|
||||
runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(), "dpow") :
|
||||
case vmIntrinsics::_dpow: {
|
||||
Node* exp = round_double_node(argument(2));
|
||||
const TypeD* d = _gvn.type(exp)->isa_double_constant();
|
||||
if (d != NULL && d->getd() == 2.0) {
|
||||
// Special case: pow(x, 2.0) => x * x
|
||||
Node* base = round_double_node(argument(0));
|
||||
set_result(_gvn.transform(new MulDNode(base, base)));
|
||||
return true;
|
||||
}
|
||||
return StubRoutines::dexp() != NULL ?
|
||||
runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(), "dpow") :
|
||||
runtime_math(OptoRuntime::Math_DD_D_Type(), FN_PTR(SharedRuntime::dpow), "POW");
|
||||
}
|
||||
#undef FN_PTR
|
||||
|
||||
// These intrinsics are not yet correctly implemented
|
||||
|
||||
@ -826,7 +826,10 @@ JNI_ENTRY_CHECKED(jint,
|
||||
}
|
||||
jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
|
||||
if (result == JNI_OK) {
|
||||
add_planned_handle_capacity(thr->active_handles(), capacity);
|
||||
// increase local ref capacity if needed
|
||||
if ((size_t)capacity > thr->active_handles()->get_planned_capacity()) {
|
||||
add_planned_handle_capacity(thr->active_handles(), capacity);
|
||||
}
|
||||
}
|
||||
functionExit(thr);
|
||||
return result;
|
||||
|
||||
@ -1727,10 +1727,16 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsCDSIncludedInVmBuild(JNIEnv* env))
|
||||
#if INCLUDE_CDS
|
||||
# ifdef _LP64
|
||||
if (!UseCompressedOops || !UseCompressedClassPointers) {
|
||||
// On 64-bit VMs, CDS is supported only with compressed oops/pointers
|
||||
return false;
|
||||
}
|
||||
# endif // _LP64
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif // INCLUDE_CDS
|
||||
WB_END
|
||||
|
||||
|
||||
|
||||
@ -200,7 +200,9 @@ SystemProperty::SystemProperty(const char* key, const char* value, bool writeabl
|
||||
_writeable = writeable;
|
||||
}
|
||||
|
||||
AgentLibrary::AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
|
||||
AgentLibrary::AgentLibrary(const char* name, const char* options,
|
||||
bool is_absolute_path, void* os_lib,
|
||||
bool instrument_lib) {
|
||||
_name = AllocateHeap(strlen(name)+1, mtArguments);
|
||||
strcpy(_name, name);
|
||||
if (options == NULL) {
|
||||
@ -214,6 +216,7 @@ AgentLibrary::AgentLibrary(const char* name, const char* options, bool is_absolu
|
||||
_next = NULL;
|
||||
_state = agent_invalid;
|
||||
_is_static_lib = false;
|
||||
_is_instrument_lib = instrument_lib;
|
||||
}
|
||||
|
||||
// Check if head of 'option' matches 'name', and sets 'tail' to the remaining
|
||||
@ -290,6 +293,10 @@ void Arguments::add_init_agent(const char* name, char* options, bool absolute_pa
|
||||
_agentList.add(new AgentLibrary(name, options, absolute_path, NULL));
|
||||
}
|
||||
|
||||
void Arguments::add_instrument_agent(const char* name, char* options, bool absolute_path) {
|
||||
_agentList.add(new AgentLibrary(name, options, absolute_path, NULL, true));
|
||||
}
|
||||
|
||||
// Late-binding agents not started via arguments
|
||||
void Arguments::add_loaded_agent(AgentLibrary *agentLib) {
|
||||
_agentList.add(agentLib);
|
||||
@ -497,7 +504,7 @@ static SpecialFlag const special_jvm_flags[] = {
|
||||
{ "MaxRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||
{ "MinRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||
{ "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||
{ "UseMembar", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
|
||||
{ "UseMembar", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||
{ "FastTLABRefill", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
|
||||
{ "SafepointSpinBeforeYield", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
|
||||
{ "DeferThrSuspendLoopCount", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
|
||||
@ -2797,7 +2804,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
size_t length = strlen(tail) + 1;
|
||||
char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
|
||||
jio_snprintf(options, length, "%s", tail);
|
||||
add_init_agent("instrument", options, false);
|
||||
add_instrument_agent("instrument", options, false);
|
||||
// java agents need module java.instrument
|
||||
if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
|
||||
return JNI_ENOMEM;
|
||||
|
||||
@ -142,6 +142,7 @@ public:
|
||||
void* _os_lib;
|
||||
bool _is_absolute_path;
|
||||
bool _is_static_lib;
|
||||
bool _is_instrument_lib;
|
||||
AgentState _state;
|
||||
AgentLibrary* _next;
|
||||
|
||||
@ -154,13 +155,15 @@ public:
|
||||
void set_os_lib(void* os_lib) { _os_lib = os_lib; }
|
||||
AgentLibrary* next() const { return _next; }
|
||||
bool is_static_lib() const { return _is_static_lib; }
|
||||
bool is_instrument_lib() const { return _is_instrument_lib; }
|
||||
void set_static_lib(bool is_static_lib) { _is_static_lib = is_static_lib; }
|
||||
bool valid() { return (_state == agent_valid); }
|
||||
void set_valid() { _state = agent_valid; }
|
||||
void set_invalid() { _state = agent_invalid; }
|
||||
|
||||
// Constructor
|
||||
AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib);
|
||||
AgentLibrary(const char* name, const char* options, bool is_absolute_path,
|
||||
void* os_lib, bool instrument_lib=false);
|
||||
};
|
||||
|
||||
// maintain an order of entry list of AgentLibrary
|
||||
@ -337,6 +340,7 @@ class Arguments : AllStatic {
|
||||
// -agentlib and -agentpath arguments
|
||||
static AgentLibraryList _agentList;
|
||||
static void add_init_agent(const char* name, char* options, bool absolute_path);
|
||||
static void add_instrument_agent(const char* name, char* options, bool absolute_path);
|
||||
|
||||
// Late-binding agents not started via arguments
|
||||
static void add_loaded_agent(AgentLibrary *agentLib);
|
||||
|
||||
@ -45,8 +45,8 @@ enum cmpxchg_memory_order {
|
||||
|
||||
class Atomic : AllStatic {
|
||||
public:
|
||||
// Atomic operations on jlong types are not available on all 32-bit
|
||||
// platforms. If atomic ops on jlongs are defined here they must only
|
||||
// Atomic operations on int64 types are not available on all 32-bit
|
||||
// platforms. If atomic ops on int64 are defined here they must only
|
||||
// be used from code that verifies they are available at runtime and
|
||||
// can provide an alternative action if not - see supports_cx8() for
|
||||
// a means to test availability.
|
||||
@ -639,16 +639,16 @@ struct Atomic::AddImpl<
|
||||
//
|
||||
// Use the ATOMIC_SHORT_PAIR macro (see macros.hpp) to get the desired alignment.
|
||||
template<>
|
||||
struct Atomic::AddImpl<jshort, jshort> VALUE_OBJ_CLASS_SPEC {
|
||||
jshort operator()(jshort add_value, jshort volatile* dest) const {
|
||||
struct Atomic::AddImpl<short, short> VALUE_OBJ_CLASS_SPEC {
|
||||
short operator()(short add_value, short volatile* dest) const {
|
||||
#ifdef VM_LITTLE_ENDIAN
|
||||
assert((intx(dest) & 0x03) == 0x02, "wrong alignment");
|
||||
jint new_value = Atomic::add(add_value << 16, (volatile jint*)(dest-1));
|
||||
int new_value = Atomic::add(add_value << 16, (volatile int*)(dest-1));
|
||||
#else
|
||||
assert((intx(dest) & 0x03) == 0x00, "wrong alignment");
|
||||
jint new_value = Atomic::add(add_value << 16, (volatile jint*)(dest));
|
||||
int new_value = Atomic::add(add_value << 16, (volatile int*)(dest));
|
||||
#endif
|
||||
return (jshort)(new_value >> 16); // preserves sign
|
||||
return (short)(new_value >> 16); // preserves sign
|
||||
}
|
||||
};
|
||||
|
||||
@ -807,7 +807,7 @@ inline T Atomic::CmpxchgByteUsingInt::operator()(T exchange_value,
|
||||
do {
|
||||
// value to swap in matches current value ...
|
||||
uint32_t new_value = cur;
|
||||
// ... except for the one jbyte we want to update
|
||||
// ... except for the one byte we want to update
|
||||
reinterpret_cast<uint8_t*>(&new_value)[offset] = canon_exchange_value;
|
||||
|
||||
uint32_t res = cmpxchg(new_value, aligned_dest, cur, order);
|
||||
|
||||
@ -357,7 +357,7 @@ void print_statistics() {
|
||||
MemTracker::final_report(tty);
|
||||
}
|
||||
|
||||
ThreadsSMRSupport::log_smr_statistics();
|
||||
ThreadsSMRSupport::log_statistics();
|
||||
}
|
||||
|
||||
#else // PRODUCT MODE STATISTICS
|
||||
@ -399,7 +399,7 @@ void print_statistics() {
|
||||
Method::print_touched_methods(tty);
|
||||
}
|
||||
|
||||
ThreadsSMRSupport::log_smr_statistics();
|
||||
ThreadsSMRSupport::log_statistics();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -47,6 +47,7 @@ jobject JNIHandles::make_local(oop obj) {
|
||||
} else {
|
||||
Thread* thread = Thread::current();
|
||||
assert(Universe::heap()->is_in_reserved(obj), "sanity check");
|
||||
assert(!current_thread_in_native(), "must not be in native");
|
||||
return thread->active_handles()->allocate_handle(obj);
|
||||
}
|
||||
}
|
||||
@ -59,6 +60,8 @@ jobject JNIHandles::make_local(Thread* thread, oop obj) {
|
||||
return NULL; // ignore null handles
|
||||
} else {
|
||||
assert(Universe::heap()->is_in_reserved(obj), "sanity check");
|
||||
assert(thread->is_Java_thread(), "not a Java thread");
|
||||
assert(!current_thread_in_native(), "must not be in native");
|
||||
return thread->active_handles()->allocate_handle(obj);
|
||||
}
|
||||
}
|
||||
@ -70,6 +73,7 @@ jobject JNIHandles::make_local(JNIEnv* env, oop obj) {
|
||||
} else {
|
||||
JavaThread* thread = JavaThread::thread_from_jni_environment(env);
|
||||
assert(Universe::heap()->is_in_reserved(obj), "sanity check");
|
||||
assert(!current_thread_in_native(), "must not be in native");
|
||||
return thread->active_handles()->allocate_handle(obj);
|
||||
}
|
||||
}
|
||||
@ -77,6 +81,7 @@ jobject JNIHandles::make_local(JNIEnv* env, oop obj) {
|
||||
|
||||
jobject JNIHandles::make_global(Handle obj) {
|
||||
assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
|
||||
assert(!current_thread_in_native(), "must not be in native");
|
||||
jobject res = NULL;
|
||||
if (!obj.is_null()) {
|
||||
// ignore null handles
|
||||
@ -93,6 +98,7 @@ jobject JNIHandles::make_global(Handle obj) {
|
||||
|
||||
jobject JNIHandles::make_weak_global(Handle obj) {
|
||||
assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
|
||||
assert(!current_thread_in_native(), "must not be in native");
|
||||
jobject res = NULL;
|
||||
if (!obj.is_null()) {
|
||||
// ignore null handles
|
||||
@ -265,6 +271,13 @@ void JNIHandles::verify() {
|
||||
weak_oops_do(&verify_handle);
|
||||
}
|
||||
|
||||
// This method is implemented here to avoid circular includes between
|
||||
// jniHandles.hpp and thread.hpp.
|
||||
bool JNIHandles::current_thread_in_native() {
|
||||
Thread* thread = Thread::current();
|
||||
return (thread->is_Java_thread() &&
|
||||
JavaThread::current()->thread_state() == _thread_in_native);
|
||||
}
|
||||
|
||||
|
||||
void jni_handles_init() {
|
||||
|
||||
@ -48,6 +48,10 @@ class JNIHandles : AllStatic {
|
||||
template<bool external_guard> inline static oop resolve_impl(jobject handle);
|
||||
template<bool external_guard> static oop resolve_jweak(jweak handle);
|
||||
|
||||
// This method is not inlined in order to avoid circular includes between
|
||||
// this header file and thread.hpp.
|
||||
static bool current_thread_in_native();
|
||||
|
||||
public:
|
||||
// Low tag bit in jobject used to distinguish a jweak. jweak is
|
||||
// type equivalent to jobject, but there are places where we need to
|
||||
@ -230,6 +234,7 @@ inline oop JNIHandles::guard_value(oop value) {
|
||||
template<bool external_guard>
|
||||
inline oop JNIHandles::resolve_impl(jobject handle) {
|
||||
assert(handle != NULL, "precondition");
|
||||
assert(!current_thread_in_native(), "must not be in native");
|
||||
oop result;
|
||||
if (is_jweak(handle)) { // Unlikely
|
||||
result = resolve_jweak<external_guard>(handle);
|
||||
|
||||
@ -103,7 +103,7 @@ void SafepointSynchronize::begin() {
|
||||
|
||||
int nof_threads = Threads::number_of_threads();
|
||||
|
||||
log_debug(safepoint)("Safepoint synchronization initiated. (%d)", nof_threads);
|
||||
log_debug(safepoint)("Safepoint synchronization initiated. (%d threads)", nof_threads);
|
||||
|
||||
RuntimeService::record_safepoint_begin();
|
||||
|
||||
@ -407,9 +407,7 @@ void SafepointSynchronize::begin() {
|
||||
// Update the count of active JNI critical regions
|
||||
GCLocker::set_jni_lock_count(_current_jni_active_count);
|
||||
|
||||
if (log_is_enabled(Debug, safepoint)) {
|
||||
log_debug(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description());
|
||||
}
|
||||
log_info(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description());
|
||||
|
||||
RuntimeService::record_safepoint_synchronized();
|
||||
if (PrintSafepointStatistics) {
|
||||
@ -496,14 +494,14 @@ void SafepointSynchronize::end() {
|
||||
cur_state->restart(); // TSS _running
|
||||
SafepointMechanism::disarm_local_poll(current); // release store, local state -> polling page
|
||||
}
|
||||
log_debug(safepoint)("Leaving safepoint region");
|
||||
log_info(safepoint)("Leaving safepoint region");
|
||||
} else {
|
||||
// Set to not synchronized, so the threads will not go into the signal_thread_blocked method
|
||||
// when they get restarted.
|
||||
_state = _not_synchronized;
|
||||
OrderAccess::fence();
|
||||
|
||||
log_debug(safepoint)("Leaving safepoint region");
|
||||
log_info(safepoint)("Leaving safepoint region");
|
||||
|
||||
// Start suspended threads
|
||||
jtiwh.rewind();
|
||||
|
||||
@ -62,12 +62,11 @@ address StubRoutines::_verify_oop_subroutine_entry = NULL;
|
||||
address StubRoutines::_atomic_xchg_entry = NULL;
|
||||
address StubRoutines::_atomic_xchg_long_entry = NULL;
|
||||
address StubRoutines::_atomic_store_entry = NULL;
|
||||
address StubRoutines::_atomic_store_ptr_entry = NULL;
|
||||
address StubRoutines::_atomic_cmpxchg_entry = NULL;
|
||||
address StubRoutines::_atomic_cmpxchg_byte_entry = NULL;
|
||||
address StubRoutines::_atomic_cmpxchg_long_entry = NULL;
|
||||
address StubRoutines::_atomic_add_entry = NULL;
|
||||
address StubRoutines::_atomic_add_ptr_entry = NULL;
|
||||
address StubRoutines::_atomic_add_long_entry = NULL;
|
||||
address StubRoutines::_fence_entry = NULL;
|
||||
address StubRoutines::_d2i_wrapper = NULL;
|
||||
address StubRoutines::_d2l_wrapper = NULL;
|
||||
|
||||
@ -103,12 +103,11 @@ class StubRoutines: AllStatic {
|
||||
static address _atomic_xchg_entry;
|
||||
static address _atomic_xchg_long_entry;
|
||||
static address _atomic_store_entry;
|
||||
static address _atomic_store_ptr_entry;
|
||||
static address _atomic_cmpxchg_entry;
|
||||
static address _atomic_cmpxchg_byte_entry;
|
||||
static address _atomic_cmpxchg_long_entry;
|
||||
static address _atomic_add_entry;
|
||||
static address _atomic_add_ptr_entry;
|
||||
static address _atomic_add_long_entry;
|
||||
static address _fence_entry;
|
||||
static address _d2i_wrapper;
|
||||
static address _d2l_wrapper;
|
||||
@ -277,12 +276,11 @@ class StubRoutines: AllStatic {
|
||||
static address atomic_xchg_entry() { return _atomic_xchg_entry; }
|
||||
static address atomic_xchg_long_entry() { return _atomic_xchg_long_entry; }
|
||||
static address atomic_store_entry() { return _atomic_store_entry; }
|
||||
static address atomic_store_ptr_entry() { return _atomic_store_ptr_entry; }
|
||||
static address atomic_cmpxchg_entry() { return _atomic_cmpxchg_entry; }
|
||||
static address atomic_cmpxchg_byte_entry() { return _atomic_cmpxchg_byte_entry; }
|
||||
static address atomic_cmpxchg_long_entry() { return _atomic_cmpxchg_long_entry; }
|
||||
static address atomic_add_entry() { return _atomic_add_entry; }
|
||||
static address atomic_add_ptr_entry() { return _atomic_add_ptr_entry; }
|
||||
static address atomic_add_long_entry() { return _atomic_add_long_entry; }
|
||||
static address fence_entry() { return _fence_entry; }
|
||||
|
||||
static address d2i_wrapper() { return _d2i_wrapper; }
|
||||
|
||||
@ -3473,7 +3473,7 @@ static inline void *prefetch_and_load_ptr(void **addr, intx prefetch_interval) {
|
||||
X = (JavaThread*)prefetch_and_load_ptr((void**)MACRO_current_p, (intx)MACRO_scan_interval))
|
||||
|
||||
// All JavaThreads
|
||||
#define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_smr_java_thread_list(), X)
|
||||
#define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_java_thread_list(), X)
|
||||
|
||||
// All JavaThreads + all non-JavaThreads (i.e., every thread in the system)
|
||||
void Threads::threads_do(ThreadClosure* tc) {
|
||||
@ -4038,9 +4038,16 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent,
|
||||
}
|
||||
if (library == NULL) {
|
||||
const char *sub_msg = " on the library path, with error: ";
|
||||
size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
|
||||
const char *sub_msg2 = "\nModule java.instrument may be missing from runtime image.";
|
||||
|
||||
size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) +
|
||||
strlen(ebuf) + strlen(sub_msg2) + 1;
|
||||
char *buf = NEW_C_HEAP_ARRAY(char, len, mtThread);
|
||||
jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
|
||||
if (!agent->is_instrument_lib()) {
|
||||
jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
|
||||
} else {
|
||||
jio_snprintf(buf, len, "%s%s%s%s%s", msg, name, sub_msg, ebuf, sub_msg2);
|
||||
}
|
||||
// If we can't find the agent, exit.
|
||||
vm_exit_during_initialization(buf, NULL);
|
||||
FREE_C_HEAP_ARRAY(char, buf);
|
||||
@ -4382,7 +4389,7 @@ void Threads::remove(JavaThread* p) {
|
||||
// that we do not remove thread without safepoint code notice
|
||||
{ MutexLocker ml(Threads_lock);
|
||||
|
||||
assert(ThreadsSMRSupport::get_smr_java_thread_list()->includes(p), "p must be present");
|
||||
assert(ThreadsSMRSupport::get_java_thread_list()->includes(p), "p must be present");
|
||||
|
||||
// Maintain fast thread list
|
||||
ThreadsSMRSupport::remove_thread(p);
|
||||
@ -4610,7 +4617,7 @@ void Threads::print_on(outputStream* st, bool print_stacks,
|
||||
}
|
||||
#endif // INCLUDE_SERVICES
|
||||
|
||||
ThreadsSMRSupport::print_smr_info_on(st);
|
||||
ThreadsSMRSupport::print_info_on(st);
|
||||
st->cr();
|
||||
|
||||
ALL_JAVA_THREADS(p) {
|
||||
@ -4679,7 +4686,7 @@ class PrintOnErrorClosure : public ThreadClosure {
|
||||
// memory (even in resource area), it might deadlock the error handler.
|
||||
void Threads::print_on_error(outputStream* st, Thread* current, char* buf,
|
||||
int buflen) {
|
||||
ThreadsSMRSupport::print_smr_info_on(st);
|
||||
ThreadsSMRSupport::print_info_on(st);
|
||||
st->cr();
|
||||
|
||||
bool found_current = false;
|
||||
|
||||
@ -31,131 +31,131 @@
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/resourceHash.hpp"
|
||||
|
||||
Monitor* ThreadsSMRSupport::_smr_delete_lock =
|
||||
new Monitor(Monitor::special, "smr_delete_lock",
|
||||
Monitor* ThreadsSMRSupport::_delete_lock =
|
||||
new Monitor(Monitor::special, "Thread_SMR_delete_lock",
|
||||
false /* allow_vm_block */,
|
||||
Monitor::_safepoint_check_never);
|
||||
// The '_cnt', '_max' and '_times" fields are enabled via
|
||||
// -XX:+EnableThreadSMRStatistics:
|
||||
|
||||
// # of parallel threads in _smr_delete_lock->wait().
|
||||
// # of parallel threads in _delete_lock->wait().
|
||||
// Impl note: Hard to imagine > 64K waiting threads so this could be 16-bit,
|
||||
// but there is no nice 16-bit _FORMAT support.
|
||||
uint ThreadsSMRSupport::_smr_delete_lock_wait_cnt = 0;
|
||||
uint ThreadsSMRSupport::_delete_lock_wait_cnt = 0;
|
||||
|
||||
// Max # of parallel threads in _smr_delete_lock->wait().
|
||||
// Impl note: See _smr_delete_lock_wait_cnt note.
|
||||
uint ThreadsSMRSupport::_smr_delete_lock_wait_max = 0;
|
||||
// Max # of parallel threads in _delete_lock->wait().
|
||||
// Impl note: See _delete_lock_wait_cnt note.
|
||||
uint ThreadsSMRSupport::_delete_lock_wait_max = 0;
|
||||
|
||||
// Flag to indicate when an _smr_delete_lock->notify() is needed.
|
||||
// Impl note: See _smr_delete_lock_wait_cnt note.
|
||||
volatile uint ThreadsSMRSupport::_smr_delete_notify = 0;
|
||||
// Flag to indicate when an _delete_lock->notify() is needed.
|
||||
// Impl note: See _delete_lock_wait_cnt note.
|
||||
volatile uint ThreadsSMRSupport::_delete_notify = 0;
|
||||
|
||||
// # of threads deleted over VM lifetime.
|
||||
// Impl note: Atomically incremented over VM lifetime so use unsigned for more
|
||||
// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
|
||||
// isn't available everywhere (or is it?).
|
||||
volatile uint ThreadsSMRSupport::_smr_deleted_thread_cnt = 0;
|
||||
volatile uint ThreadsSMRSupport::_deleted_thread_cnt = 0;
|
||||
|
||||
// Max time in millis to delete a thread.
|
||||
// Impl note: 16-bit might be too small on an overloaded machine. Use
|
||||
// unsigned since this is a time value. Set via Atomic::cmpxchg() in a
|
||||
// loop for correctness.
|
||||
volatile uint ThreadsSMRSupport::_smr_deleted_thread_time_max = 0;
|
||||
volatile uint ThreadsSMRSupport::_deleted_thread_time_max = 0;
|
||||
|
||||
// Cumulative time in millis to delete threads.
|
||||
// Impl note: Atomically added to over VM lifetime so use unsigned for more
|
||||
// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
|
||||
// isn't available everywhere (or is it?).
|
||||
volatile uint ThreadsSMRSupport::_smr_deleted_thread_times = 0;
|
||||
volatile uint ThreadsSMRSupport::_deleted_thread_times = 0;
|
||||
|
||||
ThreadsList* volatile ThreadsSMRSupport::_smr_java_thread_list = new ThreadsList(0);
|
||||
ThreadsList* volatile ThreadsSMRSupport::_java_thread_list = new ThreadsList(0);
|
||||
|
||||
// # of ThreadsLists allocated over VM lifetime.
|
||||
// Impl note: We allocate a new ThreadsList for every thread create and
|
||||
// every thread delete so we need a bigger type than the
|
||||
// _smr_deleted_thread_cnt field.
|
||||
uint64_t ThreadsSMRSupport::_smr_java_thread_list_alloc_cnt = 1;
|
||||
// _deleted_thread_cnt field.
|
||||
uint64_t ThreadsSMRSupport::_java_thread_list_alloc_cnt = 1;
|
||||
|
||||
// # of ThreadsLists freed over VM lifetime.
|
||||
// Impl note: See _smr_java_thread_list_alloc_cnt note.
|
||||
uint64_t ThreadsSMRSupport::_smr_java_thread_list_free_cnt = 0;
|
||||
// Impl note: See _java_thread_list_alloc_cnt note.
|
||||
uint64_t ThreadsSMRSupport::_java_thread_list_free_cnt = 0;
|
||||
|
||||
// Max size ThreadsList allocated.
|
||||
// Impl note: Max # of threads alive at one time should fit in unsigned 32-bit.
|
||||
uint ThreadsSMRSupport::_smr_java_thread_list_max = 0;
|
||||
uint ThreadsSMRSupport::_java_thread_list_max = 0;
|
||||
|
||||
// Max # of nested ThreadsLists for a thread.
|
||||
// Impl note: Hard to imagine > 64K nested ThreadsLists so this could be
|
||||
// 16-bit, but there is no nice 16-bit _FORMAT support.
|
||||
uint ThreadsSMRSupport::_smr_nested_thread_list_max = 0;
|
||||
uint ThreadsSMRSupport::_nested_thread_list_max = 0;
|
||||
|
||||
// # of ThreadsListHandles deleted over VM lifetime.
|
||||
// Impl note: Atomically incremented over VM lifetime so use unsigned for
|
||||
// more range. There will be fewer ThreadsListHandles than threads so
|
||||
// unsigned 32-bit should be fine.
|
||||
volatile uint ThreadsSMRSupport::_smr_tlh_cnt = 0;
|
||||
volatile uint ThreadsSMRSupport::_tlh_cnt = 0;
|
||||
|
||||
// Max time in millis to delete a ThreadsListHandle.
|
||||
// Impl note: 16-bit might be too small on an overloaded machine. Use
|
||||
// unsigned since this is a time value. Set via Atomic::cmpxchg() in a
|
||||
// loop for correctness.
|
||||
volatile uint ThreadsSMRSupport::_smr_tlh_time_max = 0;
|
||||
volatile uint ThreadsSMRSupport::_tlh_time_max = 0;
|
||||
|
||||
// Cumulative time in millis to delete ThreadsListHandles.
|
||||
// Impl note: Atomically added to over VM lifetime so use unsigned for more
|
||||
// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
|
||||
// isn't available everywhere (or is it?).
|
||||
volatile uint ThreadsSMRSupport::_smr_tlh_times = 0;
|
||||
volatile uint ThreadsSMRSupport::_tlh_times = 0;
|
||||
|
||||
ThreadsList* ThreadsSMRSupport::_smr_to_delete_list = NULL;
|
||||
ThreadsList* ThreadsSMRSupport::_to_delete_list = NULL;
|
||||
|
||||
// # of parallel ThreadsLists on the to-delete list.
|
||||
// Impl note: Hard to imagine > 64K ThreadsLists needing to be deleted so
|
||||
// this could be 16-bit, but there is no nice 16-bit _FORMAT support.
|
||||
uint ThreadsSMRSupport::_smr_to_delete_list_cnt = 0;
|
||||
uint ThreadsSMRSupport::_to_delete_list_cnt = 0;
|
||||
|
||||
// Max # of parallel ThreadsLists on the to-delete list.
|
||||
// Impl note: See _smr_to_delete_list_cnt note.
|
||||
uint ThreadsSMRSupport::_smr_to_delete_list_max = 0;
|
||||
// Impl note: See _to_delete_list_cnt note.
|
||||
uint ThreadsSMRSupport::_to_delete_list_max = 0;
|
||||
|
||||
|
||||
// 'inline' functions first so the definitions are before first use:
|
||||
|
||||
inline void ThreadsSMRSupport::add_smr_deleted_thread_times(uint add_value) {
|
||||
Atomic::add(add_value, &_smr_deleted_thread_times);
|
||||
inline void ThreadsSMRSupport::add_deleted_thread_times(uint add_value) {
|
||||
Atomic::add(add_value, &_deleted_thread_times);
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::inc_smr_deleted_thread_cnt() {
|
||||
Atomic::inc(&_smr_deleted_thread_cnt);
|
||||
inline void ThreadsSMRSupport::inc_deleted_thread_cnt() {
|
||||
Atomic::inc(&_deleted_thread_cnt);
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt() {
|
||||
_smr_java_thread_list_alloc_cnt++;
|
||||
inline void ThreadsSMRSupport::inc_java_thread_list_alloc_cnt() {
|
||||
_java_thread_list_alloc_cnt++;
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::update_smr_deleted_thread_time_max(uint new_value) {
|
||||
inline void ThreadsSMRSupport::update_deleted_thread_time_max(uint new_value) {
|
||||
while (true) {
|
||||
uint cur_value = _smr_deleted_thread_time_max;
|
||||
uint cur_value = _deleted_thread_time_max;
|
||||
if (new_value <= cur_value) {
|
||||
// No need to update max value so we're done.
|
||||
break;
|
||||
}
|
||||
if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
|
||||
if (Atomic::cmpxchg(new_value, &_deleted_thread_time_max, cur_value) == cur_value) {
|
||||
// Updated max value so we're done. Otherwise try it all again.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::update_smr_java_thread_list_max(uint new_value) {
|
||||
if (new_value > _smr_java_thread_list_max) {
|
||||
_smr_java_thread_list_max = new_value;
|
||||
inline void ThreadsSMRSupport::update_java_thread_list_max(uint new_value) {
|
||||
if (new_value > _java_thread_list_max) {
|
||||
_java_thread_list_max = new_value;
|
||||
}
|
||||
}
|
||||
|
||||
inline ThreadsList* ThreadsSMRSupport::xchg_smr_java_thread_list(ThreadsList* new_list) {
|
||||
return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
|
||||
inline ThreadsList* ThreadsSMRSupport::xchg_java_thread_list(ThreadsList* new_list) {
|
||||
return (ThreadsList*)Atomic::xchg(new_list, &_java_thread_list);
|
||||
}
|
||||
|
||||
|
||||
@ -268,7 +268,7 @@ class ScanHazardPtrGatherProtectedThreadsClosure : public ThreadClosure {
|
||||
}
|
||||
|
||||
// The current JavaThread has a hazard ptr (ThreadsList reference)
|
||||
// which might be _smr_java_thread_list or it might be an older
|
||||
// which might be _java_thread_list or it might be an older
|
||||
// ThreadsList that has been removed but not freed. In either case,
|
||||
// the hazard ptr is protecting all the JavaThreads on that
|
||||
// ThreadsList.
|
||||
@ -347,7 +347,7 @@ class ScanHazardPtrPrintMatchingThreadsClosure : public ThreadClosure {
|
||||
if (Thread::is_hazard_ptr_tagged(current_list)) return;
|
||||
|
||||
// The current JavaThread has a hazard ptr (ThreadsList reference)
|
||||
// which might be _smr_java_thread_list or it might be an older
|
||||
// which might be _java_thread_list or it might be an older
|
||||
// ThreadsList that has been removed but not freed. In either case,
|
||||
// the hazard ptr is protecting all the JavaThreads on that
|
||||
// ThreadsList, but we only care about matching a specific JavaThread.
|
||||
@ -476,7 +476,7 @@ ThreadsListHandle::~ThreadsListHandle() {
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_timer.stop();
|
||||
uint millis = (uint)_timer.milliseconds();
|
||||
ThreadsSMRSupport::update_smr_tlh_stats(millis);
|
||||
ThreadsSMRSupport::update_tlh_stats(millis);
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,12 +574,12 @@ ThreadsList *ThreadsSMRSupport::acquire_stable_list_fast_path(Thread *self) {
|
||||
ThreadsList* threads;
|
||||
|
||||
// Stable recording of a hazard ptr for SMR. This code does not use
|
||||
// locks so its use of the _smr_java_thread_list & _threads_hazard_ptr
|
||||
// locks so its use of the _java_thread_list & _threads_hazard_ptr
|
||||
// fields is racy relative to code that uses those fields with locks.
|
||||
// OrderAccess and Atomic functions are used to deal with those races.
|
||||
//
|
||||
while (true) {
|
||||
threads = get_smr_java_thread_list();
|
||||
threads = get_java_thread_list();
|
||||
|
||||
// Publish a tagged hazard ptr to denote that the hazard ptr is not
|
||||
// yet verified as being stable. Due to the fence after the hazard
|
||||
@ -590,9 +590,9 @@ ThreadsList *ThreadsSMRSupport::acquire_stable_list_fast_path(Thread *self) {
|
||||
ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads);
|
||||
self->set_threads_hazard_ptr(unverified_threads);
|
||||
|
||||
// If _smr_java_thread_list has changed, we have lost a race with
|
||||
// If _java_thread_list has changed, we have lost a race with
|
||||
// Threads::add() or Threads::remove() and have to try again.
|
||||
if (get_smr_java_thread_list() != threads) {
|
||||
if (get_java_thread_list() != threads) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -634,15 +634,15 @@ ThreadsList *ThreadsSMRSupport::acquire_stable_list_nested_path(Thread *self) {
|
||||
{
|
||||
// Only grab the Threads_lock if we don't already own it.
|
||||
MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
|
||||
node = new NestedThreadsList(get_smr_java_thread_list());
|
||||
node = new NestedThreadsList(get_java_thread_list());
|
||||
// We insert at the front of the list to match up with the delete
|
||||
// in release_stable_list().
|
||||
node->set_next(self->get_nested_threads_hazard_ptr());
|
||||
self->set_nested_threads_hazard_ptr(node);
|
||||
if (EnableThreadSMRStatistics) {
|
||||
self->inc_nested_threads_hazard_ptr_cnt();
|
||||
if (self->nested_threads_hazard_ptr_cnt() > _smr_nested_thread_list_max) {
|
||||
_smr_nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
|
||||
if (self->nested_threads_hazard_ptr_cnt() > _nested_thread_list_max) {
|
||||
_nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,25 +652,101 @@ ThreadsList *ThreadsSMRSupport::acquire_stable_list_nested_path(Thread *self) {
|
||||
}
|
||||
|
||||
void ThreadsSMRSupport::add_thread(JavaThread *thread){
|
||||
ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_smr_java_thread_list(), thread);
|
||||
ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_java_thread_list(), thread);
|
||||
if (EnableThreadSMRStatistics) {
|
||||
ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt();
|
||||
ThreadsSMRSupport::update_smr_java_thread_list_max(new_list->length());
|
||||
ThreadsSMRSupport::inc_java_thread_list_alloc_cnt();
|
||||
ThreadsSMRSupport::update_java_thread_list_max(new_list->length());
|
||||
}
|
||||
// Initial _smr_java_thread_list will not generate a "Threads::add" mesg.
|
||||
// Initial _java_thread_list will not generate a "Threads::add" mesg.
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::add: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
|
||||
|
||||
ThreadsList *old_list = ThreadsSMRSupport::xchg_smr_java_thread_list(new_list);
|
||||
ThreadsSMRSupport::smr_free_list(old_list);
|
||||
ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list);
|
||||
ThreadsSMRSupport::free_list(old_list);
|
||||
}
|
||||
|
||||
// set_smr_delete_notify() and clear_smr_delete_notify() are called
|
||||
// under the protection of the smr_delete_lock, but we also use an
|
||||
// set_delete_notify() and clear_delete_notify() are called
|
||||
// under the protection of the delete_lock, but we also use an
|
||||
// Atomic operation to ensure the memory update is seen earlier than
|
||||
// when the smr_delete_lock is dropped.
|
||||
// when the delete_lock is dropped.
|
||||
//
|
||||
void ThreadsSMRSupport::clear_smr_delete_notify() {
|
||||
Atomic::dec(&_smr_delete_notify);
|
||||
void ThreadsSMRSupport::clear_delete_notify() {
|
||||
Atomic::dec(&_delete_notify);
|
||||
}
|
||||
|
||||
bool ThreadsSMRSupport::delete_notify() {
|
||||
// Use load_acquire() in order to see any updates to _delete_notify
|
||||
// earlier than when delete_lock is grabbed.
|
||||
return (OrderAccess::load_acquire(&_delete_notify) != 0);
|
||||
}
|
||||
|
||||
// Safely free a ThreadsList after a Threads::add() or Threads::remove().
|
||||
// The specified ThreadsList may not get deleted during this call if it
|
||||
// is still in-use (referenced by a hazard ptr). Other ThreadsLists
|
||||
// in the chain may get deleted by this call if they are no longer in-use.
|
||||
void ThreadsSMRSupport::free_list(ThreadsList* threads) {
|
||||
assert_locked_or_safepoint(Threads_lock);
|
||||
|
||||
threads->set_next_list(_to_delete_list);
|
||||
_to_delete_list = threads;
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_to_delete_list_cnt++;
|
||||
if (_to_delete_list_cnt > _to_delete_list_max) {
|
||||
_to_delete_list_max = _to_delete_list_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
// Hash table size should be first power of two higher than twice the length of the ThreadsList
|
||||
int hash_table_size = MIN2((int)get_java_thread_list()->length(), 32) << 1;
|
||||
hash_table_size--;
|
||||
hash_table_size |= hash_table_size >> 1;
|
||||
hash_table_size |= hash_table_size >> 2;
|
||||
hash_table_size |= hash_table_size >> 4;
|
||||
hash_table_size |= hash_table_size >> 8;
|
||||
hash_table_size |= hash_table_size >> 16;
|
||||
hash_table_size++;
|
||||
|
||||
// Gather a hash table of the current hazard ptrs:
|
||||
ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
|
||||
ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
|
||||
Threads::threads_do(&scan_cl);
|
||||
|
||||
// Walk through the linked list of pending freeable ThreadsLists
|
||||
// and free the ones that are not referenced from hazard ptrs.
|
||||
ThreadsList* current = _to_delete_list;
|
||||
ThreadsList* prev = NULL;
|
||||
ThreadsList* next = NULL;
|
||||
bool threads_is_freed = false;
|
||||
while (current != NULL) {
|
||||
next = current->next_list();
|
||||
if (!scan_table->has_entry((void*)current)) {
|
||||
// This ThreadsList is not referenced by a hazard ptr.
|
||||
if (prev != NULL) {
|
||||
prev->set_next_list(next);
|
||||
}
|
||||
if (_to_delete_list == current) {
|
||||
_to_delete_list = next;
|
||||
}
|
||||
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current));
|
||||
if (current == threads) threads_is_freed = true;
|
||||
delete current;
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_java_thread_list_free_cnt++;
|
||||
_to_delete_list_cnt--;
|
||||
}
|
||||
} else {
|
||||
prev = current;
|
||||
}
|
||||
current = next;
|
||||
}
|
||||
|
||||
if (!threads_is_freed) {
|
||||
// Only report "is not freed" on the original call to
|
||||
// free_list() for this ThreadsList.
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads));
|
||||
}
|
||||
|
||||
delete scan_table;
|
||||
}
|
||||
|
||||
// Return true if the specified JavaThread is protected by a hazard
|
||||
@ -681,7 +757,7 @@ bool ThreadsSMRSupport::is_a_protected_JavaThread(JavaThread *thread) {
|
||||
|
||||
// Hash table size should be first power of two higher than twice
|
||||
// the length of the Threads list.
|
||||
int hash_table_size = MIN2((int)get_smr_java_thread_list()->length(), 32) << 1;
|
||||
int hash_table_size = MIN2((int)get_java_thread_list()->length(), 32) << 1;
|
||||
hash_table_size--;
|
||||
hash_table_size |= hash_table_size >> 1;
|
||||
hash_table_size |= hash_table_size >> 2;
|
||||
@ -736,10 +812,10 @@ void ThreadsSMRSupport::release_stable_list_fast_path(Thread *self) {
|
||||
self->set_threads_hazard_ptr(NULL);
|
||||
|
||||
// We use double-check locking to reduce traffic on the system
|
||||
// wide smr_delete_lock.
|
||||
if (ThreadsSMRSupport::smr_delete_notify()) {
|
||||
// wide Thread-SMR delete_lock.
|
||||
if (ThreadsSMRSupport::delete_notify()) {
|
||||
// An exiting thread might be waiting in smr_delete(); we need to
|
||||
// check with smr_delete_lock to be sure.
|
||||
// check with delete_lock to be sure.
|
||||
release_stable_list_wake_up((char *) "regular hazard ptr");
|
||||
}
|
||||
}
|
||||
@ -772,7 +848,7 @@ void ThreadsSMRSupport::release_stable_list_nested_path(Thread *self) {
|
||||
}
|
||||
|
||||
// An exiting thread might be waiting in smr_delete(); we need to
|
||||
// check with smr_delete_lock to be sure.
|
||||
// check with delete_lock to be sure.
|
||||
release_stable_list_wake_up((char *) "nested hazard ptr");
|
||||
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list: delete NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
|
||||
@ -781,21 +857,21 @@ void ThreadsSMRSupport::release_stable_list_nested_path(Thread *self) {
|
||||
}
|
||||
|
||||
// Wake up portion of the release stable ThreadsList protocol;
|
||||
// uses the smr_delete_lock().
|
||||
// uses the delete_lock().
|
||||
//
|
||||
void ThreadsSMRSupport::release_stable_list_wake_up(char *log_str) {
|
||||
assert(log_str != NULL, "sanity check");
|
||||
|
||||
// Note: smr_delete_lock is held in smr_delete() for the entire
|
||||
// Note: delete_lock is held in smr_delete() for the entire
|
||||
// hazard ptr search so that we do not lose this notify() if
|
||||
// the exiting thread has to wait. That code path also holds
|
||||
// Threads_lock (which was grabbed before smr_delete_lock) so that
|
||||
// Threads_lock (which was grabbed before delete_lock) so that
|
||||
// threads_do() can be called. This means the system can't start a
|
||||
// safepoint which means this thread can't take too long to get to
|
||||
// a safepoint because of being blocked on smr_delete_lock.
|
||||
// a safepoint because of being blocked on delete_lock.
|
||||
//
|
||||
MonitorLockerEx ml(ThreadsSMRSupport::smr_delete_lock(), Monitor::_no_safepoint_check_flag);
|
||||
if (ThreadsSMRSupport::smr_delete_notify()) {
|
||||
MonitorLockerEx ml(ThreadsSMRSupport::delete_lock(), Monitor::_no_safepoint_check_flag);
|
||||
if (ThreadsSMRSupport::delete_notify()) {
|
||||
// Notify any exiting JavaThreads that are waiting in smr_delete()
|
||||
// that we've released a ThreadsList.
|
||||
ml.notify_all();
|
||||
@ -804,23 +880,23 @@ void ThreadsSMRSupport::release_stable_list_wake_up(char *log_str) {
|
||||
}
|
||||
|
||||
void ThreadsSMRSupport::remove_thread(JavaThread *thread) {
|
||||
ThreadsList *new_list = ThreadsList::remove_thread(ThreadsSMRSupport::get_smr_java_thread_list(), thread);
|
||||
ThreadsList *new_list = ThreadsList::remove_thread(ThreadsSMRSupport::get_java_thread_list(), thread);
|
||||
if (EnableThreadSMRStatistics) {
|
||||
ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt();
|
||||
ThreadsSMRSupport::inc_java_thread_list_alloc_cnt();
|
||||
// This list is smaller so no need to check for a "longest" update.
|
||||
}
|
||||
|
||||
// Final _smr_java_thread_list will not generate a "Threads::remove" mesg.
|
||||
// Final _java_thread_list will not generate a "Threads::remove" mesg.
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::remove: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
|
||||
|
||||
ThreadsList *old_list = ThreadsSMRSupport::xchg_smr_java_thread_list(new_list);
|
||||
ThreadsSMRSupport::smr_free_list(old_list);
|
||||
ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list);
|
||||
ThreadsSMRSupport::free_list(old_list);
|
||||
}
|
||||
|
||||
// See note for clear_smr_delete_notify().
|
||||
// See note for clear_delete_notify().
|
||||
//
|
||||
void ThreadsSMRSupport::set_smr_delete_notify() {
|
||||
Atomic::inc(&_smr_delete_notify);
|
||||
void ThreadsSMRSupport::set_delete_notify() {
|
||||
Atomic::inc(&_delete_notify);
|
||||
}
|
||||
|
||||
// Safely delete a JavaThread when it is no longer in use by a
|
||||
@ -842,16 +918,16 @@ void ThreadsSMRSupport::smr_delete(JavaThread *thread) {
|
||||
MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
|
||||
// Cannot use a MonitorLockerEx helper here because we have
|
||||
// to drop the Threads_lock first if we wait.
|
||||
ThreadsSMRSupport::smr_delete_lock()->lock_without_safepoint_check();
|
||||
// Set the smr_delete_notify flag after we grab smr_delete_lock
|
||||
ThreadsSMRSupport::delete_lock()->lock_without_safepoint_check();
|
||||
// Set the delete_notify flag after we grab delete_lock
|
||||
// and before we scan hazard ptrs because we're doing
|
||||
// double-check locking in release_stable_list().
|
||||
ThreadsSMRSupport::set_smr_delete_notify();
|
||||
ThreadsSMRSupport::set_delete_notify();
|
||||
|
||||
if (!is_a_protected_JavaThread(thread)) {
|
||||
// This is the common case.
|
||||
ThreadsSMRSupport::clear_smr_delete_notify();
|
||||
ThreadsSMRSupport::smr_delete_lock()->unlock();
|
||||
ThreadsSMRSupport::clear_delete_notify();
|
||||
ThreadsSMRSupport::delete_lock()->unlock();
|
||||
break;
|
||||
}
|
||||
if (!has_logged_once) {
|
||||
@ -865,22 +941,22 @@ void ThreadsSMRSupport::smr_delete(JavaThread *thread) {
|
||||
} // We have to drop the Threads_lock to wait or delete the thread
|
||||
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_smr_delete_lock_wait_cnt++;
|
||||
if (_smr_delete_lock_wait_cnt > _smr_delete_lock_wait_max) {
|
||||
_smr_delete_lock_wait_max = _smr_delete_lock_wait_cnt;
|
||||
_delete_lock_wait_cnt++;
|
||||
if (_delete_lock_wait_cnt > _delete_lock_wait_max) {
|
||||
_delete_lock_wait_max = _delete_lock_wait_cnt;
|
||||
}
|
||||
}
|
||||
// Wait for a release_stable_list() call before we check again. No
|
||||
// safepoint check, no timeout, and not as suspend equivalent flag
|
||||
// because this JavaThread is not on the Threads list.
|
||||
ThreadsSMRSupport::smr_delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
|
||||
ThreadsSMRSupport::delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
|
||||
!Mutex::_as_suspend_equivalent_flag);
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_smr_delete_lock_wait_cnt--;
|
||||
_delete_lock_wait_cnt--;
|
||||
}
|
||||
|
||||
ThreadsSMRSupport::clear_smr_delete_notify();
|
||||
ThreadsSMRSupport::smr_delete_lock()->unlock();
|
||||
ThreadsSMRSupport::clear_delete_notify();
|
||||
ThreadsSMRSupport::delete_lock()->unlock();
|
||||
// Retry the whole scenario.
|
||||
}
|
||||
|
||||
@ -893,166 +969,89 @@ void ThreadsSMRSupport::smr_delete(JavaThread *thread) {
|
||||
if (EnableThreadSMRStatistics) {
|
||||
timer.stop();
|
||||
uint millis = (uint)timer.milliseconds();
|
||||
ThreadsSMRSupport::inc_smr_deleted_thread_cnt();
|
||||
ThreadsSMRSupport::add_smr_deleted_thread_times(millis);
|
||||
ThreadsSMRSupport::update_smr_deleted_thread_time_max(millis);
|
||||
ThreadsSMRSupport::inc_deleted_thread_cnt();
|
||||
ThreadsSMRSupport::add_deleted_thread_times(millis);
|
||||
ThreadsSMRSupport::update_deleted_thread_time_max(millis);
|
||||
}
|
||||
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
|
||||
}
|
||||
|
||||
bool ThreadsSMRSupport::smr_delete_notify() {
|
||||
// Use load_acquire() in order to see any updates to _smr_delete_notify
|
||||
// earlier than when smr_delete_lock is grabbed.
|
||||
return (OrderAccess::load_acquire(&_smr_delete_notify) != 0);
|
||||
}
|
||||
|
||||
// Safely free a ThreadsList after a Threads::add() or Threads::remove().
|
||||
// The specified ThreadsList may not get deleted during this call if it
|
||||
// is still in-use (referenced by a hazard ptr). Other ThreadsLists
|
||||
// in the chain may get deleted by this call if they are no longer in-use.
|
||||
void ThreadsSMRSupport::smr_free_list(ThreadsList* threads) {
|
||||
assert_locked_or_safepoint(Threads_lock);
|
||||
|
||||
threads->set_next_list(_smr_to_delete_list);
|
||||
_smr_to_delete_list = threads;
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_smr_to_delete_list_cnt++;
|
||||
if (_smr_to_delete_list_cnt > _smr_to_delete_list_max) {
|
||||
_smr_to_delete_list_max = _smr_to_delete_list_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
// Hash table size should be first power of two higher than twice the length of the ThreadsList
|
||||
int hash_table_size = MIN2((int)get_smr_java_thread_list()->length(), 32) << 1;
|
||||
hash_table_size--;
|
||||
hash_table_size |= hash_table_size >> 1;
|
||||
hash_table_size |= hash_table_size >> 2;
|
||||
hash_table_size |= hash_table_size >> 4;
|
||||
hash_table_size |= hash_table_size >> 8;
|
||||
hash_table_size |= hash_table_size >> 16;
|
||||
hash_table_size++;
|
||||
|
||||
// Gather a hash table of the current hazard ptrs:
|
||||
ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
|
||||
ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
|
||||
Threads::threads_do(&scan_cl);
|
||||
|
||||
// Walk through the linked list of pending freeable ThreadsLists
|
||||
// and free the ones that are not referenced from hazard ptrs.
|
||||
ThreadsList* current = _smr_to_delete_list;
|
||||
ThreadsList* prev = NULL;
|
||||
ThreadsList* next = NULL;
|
||||
bool threads_is_freed = false;
|
||||
while (current != NULL) {
|
||||
next = current->next_list();
|
||||
if (!scan_table->has_entry((void*)current)) {
|
||||
// This ThreadsList is not referenced by a hazard ptr.
|
||||
if (prev != NULL) {
|
||||
prev->set_next_list(next);
|
||||
}
|
||||
if (_smr_to_delete_list == current) {
|
||||
_smr_to_delete_list = next;
|
||||
}
|
||||
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current));
|
||||
if (current == threads) threads_is_freed = true;
|
||||
delete current;
|
||||
if (EnableThreadSMRStatistics) {
|
||||
_smr_java_thread_list_free_cnt++;
|
||||
_smr_to_delete_list_cnt--;
|
||||
}
|
||||
} else {
|
||||
prev = current;
|
||||
}
|
||||
current = next;
|
||||
}
|
||||
|
||||
if (!threads_is_freed) {
|
||||
// Only report "is not freed" on the original call to
|
||||
// smr_free_list() for this ThreadsList.
|
||||
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads));
|
||||
}
|
||||
|
||||
delete scan_table;
|
||||
}
|
||||
|
||||
|
||||
// Debug, logging, and printing stuff at the end:
|
||||
|
||||
// Log Threads class SMR info.
|
||||
void ThreadsSMRSupport::log_smr_statistics() {
|
||||
void ThreadsSMRSupport::log_statistics() {
|
||||
LogTarget(Info, thread, smr) log;
|
||||
if (log.is_enabled()) {
|
||||
LogStream out(log);
|
||||
print_smr_info_on(&out);
|
||||
print_info_on(&out);
|
||||
}
|
||||
}
|
||||
|
||||
// Print Threads class SMR info.
|
||||
void ThreadsSMRSupport::print_smr_info_on(outputStream* st) {
|
||||
void ThreadsSMRSupport::print_info_on(outputStream* st) {
|
||||
// Only grab the Threads_lock if we don't already own it
|
||||
// and if we are not reporting an error.
|
||||
MutexLockerEx ml((Threads_lock->owned_by_self() || VMError::is_error_reported()) ? NULL : Threads_lock);
|
||||
|
||||
st->print_cr("Threads class SMR info:");
|
||||
st->print_cr("_smr_java_thread_list=" INTPTR_FORMAT ", length=%u, "
|
||||
"elements={", p2i(_smr_java_thread_list),
|
||||
_smr_java_thread_list->length());
|
||||
print_smr_info_elements_on(st, _smr_java_thread_list);
|
||||
st->print_cr("_java_thread_list=" INTPTR_FORMAT ", length=%u, "
|
||||
"elements={", p2i(_java_thread_list),
|
||||
_java_thread_list->length());
|
||||
print_info_elements_on(st, _java_thread_list);
|
||||
st->print_cr("}");
|
||||
if (_smr_to_delete_list != NULL) {
|
||||
st->print_cr("_smr_to_delete_list=" INTPTR_FORMAT ", length=%u, "
|
||||
"elements={", p2i(_smr_to_delete_list),
|
||||
_smr_to_delete_list->length());
|
||||
print_smr_info_elements_on(st, _smr_to_delete_list);
|
||||
if (_to_delete_list != NULL) {
|
||||
st->print_cr("_to_delete_list=" INTPTR_FORMAT ", length=%u, "
|
||||
"elements={", p2i(_to_delete_list),
|
||||
_to_delete_list->length());
|
||||
print_info_elements_on(st, _to_delete_list);
|
||||
st->print_cr("}");
|
||||
for (ThreadsList *t_list = _smr_to_delete_list->next_list();
|
||||
for (ThreadsList *t_list = _to_delete_list->next_list();
|
||||
t_list != NULL; t_list = t_list->next_list()) {
|
||||
st->print("next-> " INTPTR_FORMAT ", length=%u, "
|
||||
"elements={", p2i(t_list), t_list->length());
|
||||
print_smr_info_elements_on(st, t_list);
|
||||
print_info_elements_on(st, t_list);
|
||||
st->print_cr("}");
|
||||
}
|
||||
}
|
||||
if (!EnableThreadSMRStatistics) {
|
||||
return;
|
||||
}
|
||||
st->print_cr("_smr_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
|
||||
"_smr_java_thread_list_free_cnt=" UINT64_FORMAT ","
|
||||
"_smr_java_thread_list_max=%u, "
|
||||
"_smr_nested_thread_list_max=%u",
|
||||
_smr_java_thread_list_alloc_cnt,
|
||||
_smr_java_thread_list_free_cnt,
|
||||
_smr_java_thread_list_max,
|
||||
_smr_nested_thread_list_max);
|
||||
if (_smr_tlh_cnt > 0) {
|
||||
st->print_cr("_smr_tlh_cnt=%u"
|
||||
", _smr_tlh_times=%u"
|
||||
", avg_smr_tlh_time=%0.2f"
|
||||
", _smr_tlh_time_max=%u",
|
||||
_smr_tlh_cnt, _smr_tlh_times,
|
||||
((double) _smr_tlh_times / _smr_tlh_cnt),
|
||||
_smr_tlh_time_max);
|
||||
st->print_cr("_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
|
||||
"_java_thread_list_free_cnt=" UINT64_FORMAT ","
|
||||
"_java_thread_list_max=%u, "
|
||||
"_nested_thread_list_max=%u",
|
||||
_java_thread_list_alloc_cnt,
|
||||
_java_thread_list_free_cnt,
|
||||
_java_thread_list_max,
|
||||
_nested_thread_list_max);
|
||||
if (_tlh_cnt > 0) {
|
||||
st->print_cr("_tlh_cnt=%u"
|
||||
", _tlh_times=%u"
|
||||
", avg_tlh_time=%0.2f"
|
||||
", _tlh_time_max=%u",
|
||||
_tlh_cnt, _tlh_times,
|
||||
((double) _tlh_times / _tlh_cnt),
|
||||
_tlh_time_max);
|
||||
}
|
||||
if (_smr_deleted_thread_cnt > 0) {
|
||||
st->print_cr("_smr_deleted_thread_cnt=%u"
|
||||
", _smr_deleted_thread_times=%u"
|
||||
", avg_smr_deleted_thread_time=%0.2f"
|
||||
", _smr_deleted_thread_time_max=%u",
|
||||
_smr_deleted_thread_cnt, _smr_deleted_thread_times,
|
||||
((double) _smr_deleted_thread_times / _smr_deleted_thread_cnt),
|
||||
_smr_deleted_thread_time_max);
|
||||
if (_deleted_thread_cnt > 0) {
|
||||
st->print_cr("_deleted_thread_cnt=%u"
|
||||
", _deleted_thread_times=%u"
|
||||
", avg_deleted_thread_time=%0.2f"
|
||||
", _deleted_thread_time_max=%u",
|
||||
_deleted_thread_cnt, _deleted_thread_times,
|
||||
((double) _deleted_thread_times / _deleted_thread_cnt),
|
||||
_deleted_thread_time_max);
|
||||
}
|
||||
st->print_cr("_smr_delete_lock_wait_cnt=%u, _smr_delete_lock_wait_max=%u",
|
||||
_smr_delete_lock_wait_cnt, _smr_delete_lock_wait_max);
|
||||
st->print_cr("_smr_to_delete_list_cnt=%u, _smr_to_delete_list_max=%u",
|
||||
_smr_to_delete_list_cnt, _smr_to_delete_list_max);
|
||||
st->print_cr("_delete_lock_wait_cnt=%u, _delete_lock_wait_max=%u",
|
||||
_delete_lock_wait_cnt, _delete_lock_wait_max);
|
||||
st->print_cr("_to_delete_list_cnt=%u, _to_delete_list_max=%u",
|
||||
_to_delete_list_cnt, _to_delete_list_max);
|
||||
}
|
||||
|
||||
// Print ThreadsList elements (4 per line).
|
||||
void ThreadsSMRSupport::print_smr_info_elements_on(outputStream* st,
|
||||
ThreadsList* t_list) {
|
||||
void ThreadsSMRSupport::print_info_elements_on(outputStream* st, ThreadsList* t_list) {
|
||||
uint cnt = 0;
|
||||
JavaThreadIterator jti(t_list);
|
||||
for (JavaThread *jt = jti.first(); jt != NULL; jt = jti.next()) {
|
||||
|
||||
@ -81,67 +81,68 @@
|
||||
//
|
||||
class ThreadsSMRSupport : AllStatic {
|
||||
// The coordination between ThreadsSMRSupport::release_stable_list() and
|
||||
// ThreadsSMRSupport::smr_delete() uses the smr_delete_lock in order to
|
||||
// ThreadsSMRSupport::smr_delete() uses the delete_lock in order to
|
||||
// reduce the traffic on the Threads_lock.
|
||||
static Monitor* _smr_delete_lock;
|
||||
static Monitor* _delete_lock;
|
||||
// The '_cnt', '_max' and '_times" fields are enabled via
|
||||
// -XX:+EnableThreadSMRStatistics (see thread.cpp for a
|
||||
// description about each field):
|
||||
static uint _smr_delete_lock_wait_cnt;
|
||||
static uint _smr_delete_lock_wait_max;
|
||||
// The smr_delete_notify flag is used for proper double-check
|
||||
// locking in order to reduce the traffic on the smr_delete_lock.
|
||||
static volatile uint _smr_delete_notify;
|
||||
static volatile uint _smr_deleted_thread_cnt;
|
||||
static volatile uint _smr_deleted_thread_time_max;
|
||||
static volatile uint _smr_deleted_thread_times;
|
||||
static ThreadsList* volatile _smr_java_thread_list;
|
||||
static uint64_t _smr_java_thread_list_alloc_cnt;
|
||||
static uint64_t _smr_java_thread_list_free_cnt;
|
||||
static uint _smr_java_thread_list_max;
|
||||
static uint _smr_nested_thread_list_max;
|
||||
static volatile uint _smr_tlh_cnt;
|
||||
static volatile uint _smr_tlh_time_max;
|
||||
static volatile uint _smr_tlh_times;
|
||||
static ThreadsList* _smr_to_delete_list;
|
||||
static uint _smr_to_delete_list_cnt;
|
||||
static uint _smr_to_delete_list_max;
|
||||
static uint _delete_lock_wait_cnt;
|
||||
static uint _delete_lock_wait_max;
|
||||
// The delete_notify flag is used for proper double-check
|
||||
// locking in order to reduce the traffic on the system wide
|
||||
// Thread-SMR delete_lock.
|
||||
static volatile uint _delete_notify;
|
||||
static volatile uint _deleted_thread_cnt;
|
||||
static volatile uint _deleted_thread_time_max;
|
||||
static volatile uint _deleted_thread_times;
|
||||
static ThreadsList* volatile _java_thread_list;
|
||||
static uint64_t _java_thread_list_alloc_cnt;
|
||||
static uint64_t _java_thread_list_free_cnt;
|
||||
static uint _java_thread_list_max;
|
||||
static uint _nested_thread_list_max;
|
||||
static volatile uint _tlh_cnt;
|
||||
static volatile uint _tlh_time_max;
|
||||
static volatile uint _tlh_times;
|
||||
static ThreadsList* _to_delete_list;
|
||||
static uint _to_delete_list_cnt;
|
||||
static uint _to_delete_list_max;
|
||||
|
||||
static ThreadsList *acquire_stable_list_fast_path(Thread *self);
|
||||
static ThreadsList *acquire_stable_list_nested_path(Thread *self);
|
||||
static void add_smr_deleted_thread_times(uint add_value);
|
||||
static void add_smr_tlh_times(uint add_value);
|
||||
static void clear_smr_delete_notify();
|
||||
static void inc_smr_deleted_thread_cnt();
|
||||
static void inc_smr_java_thread_list_alloc_cnt();
|
||||
static void inc_smr_tlh_cnt();
|
||||
static void add_deleted_thread_times(uint add_value);
|
||||
static void add_tlh_times(uint add_value);
|
||||
static void clear_delete_notify();
|
||||
static Monitor* delete_lock() { return _delete_lock; }
|
||||
static bool delete_notify();
|
||||
static void free_list(ThreadsList* threads);
|
||||
static void inc_deleted_thread_cnt();
|
||||
static void inc_java_thread_list_alloc_cnt();
|
||||
static void inc_tlh_cnt();
|
||||
static bool is_a_protected_JavaThread(JavaThread *thread);
|
||||
static void release_stable_list_fast_path(Thread *self);
|
||||
static void release_stable_list_nested_path(Thread *self);
|
||||
static void release_stable_list_wake_up(char *log_str);
|
||||
static void set_smr_delete_notify();
|
||||
static Monitor* smr_delete_lock() { return _smr_delete_lock; }
|
||||
static bool smr_delete_notify();
|
||||
static void smr_free_list(ThreadsList* threads);
|
||||
static void update_smr_deleted_thread_time_max(uint new_value);
|
||||
static void update_smr_java_thread_list_max(uint new_value);
|
||||
static void update_smr_tlh_time_max(uint new_value);
|
||||
static ThreadsList* xchg_smr_java_thread_list(ThreadsList* new_list);
|
||||
static void set_delete_notify();
|
||||
static void update_deleted_thread_time_max(uint new_value);
|
||||
static void update_java_thread_list_max(uint new_value);
|
||||
static void update_tlh_time_max(uint new_value);
|
||||
static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
|
||||
|
||||
public:
|
||||
static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
|
||||
static void add_thread(JavaThread *thread);
|
||||
static ThreadsList* get_smr_java_thread_list();
|
||||
static ThreadsList* get_java_thread_list();
|
||||
static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
|
||||
static void release_stable_list(Thread *self);
|
||||
static void remove_thread(JavaThread *thread);
|
||||
static void smr_delete(JavaThread *thread);
|
||||
static void update_smr_tlh_stats(uint millis);
|
||||
static void update_tlh_stats(uint millis);
|
||||
|
||||
// Logging and printing support:
|
||||
static void log_smr_statistics();
|
||||
static void print_smr_info_elements_on(outputStream* st, ThreadsList* t_list);
|
||||
static void print_smr_info_on(outputStream* st);
|
||||
static void log_statistics();
|
||||
static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
|
||||
static void print_info_on(outputStream* st);
|
||||
};
|
||||
|
||||
// A fast list of JavaThreads.
|
||||
|
||||
@ -53,24 +53,24 @@ inline void ThreadsList::threads_do(T *cl) const {
|
||||
}
|
||||
|
||||
// These three inlines are private to ThreadsSMRSupport, but
|
||||
// they are called by public inline update_smr_tlh_stats() below:
|
||||
// they are called by public inline update_tlh_stats() below:
|
||||
|
||||
inline void ThreadsSMRSupport::add_smr_tlh_times(uint add_value) {
|
||||
Atomic::add(add_value, &_smr_tlh_times);
|
||||
inline void ThreadsSMRSupport::add_tlh_times(uint add_value) {
|
||||
Atomic::add(add_value, &_tlh_times);
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::inc_smr_tlh_cnt() {
|
||||
Atomic::inc(&_smr_tlh_cnt);
|
||||
inline void ThreadsSMRSupport::inc_tlh_cnt() {
|
||||
Atomic::inc(&_tlh_cnt);
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::update_smr_tlh_time_max(uint new_value) {
|
||||
inline void ThreadsSMRSupport::update_tlh_time_max(uint new_value) {
|
||||
while (true) {
|
||||
uint cur_value = _smr_tlh_time_max;
|
||||
uint cur_value = _tlh_time_max;
|
||||
if (new_value <= cur_value) {
|
||||
// No need to update max value so we're done.
|
||||
break;
|
||||
}
|
||||
if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
|
||||
if (Atomic::cmpxchg(new_value, &_tlh_time_max, cur_value) == cur_value) {
|
||||
// Updated max value so we're done. Otherwise try it all again.
|
||||
break;
|
||||
}
|
||||
@ -85,8 +85,8 @@ inline ThreadsList* ThreadsListSetter::list() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline ThreadsList* ThreadsSMRSupport::get_smr_java_thread_list() {
|
||||
return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
|
||||
inline ThreadsList* ThreadsSMRSupport::get_java_thread_list() {
|
||||
return (ThreadsList*)OrderAccess::load_acquire(&_java_thread_list);
|
||||
}
|
||||
|
||||
inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
|
||||
@ -94,10 +94,10 @@ inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *t
|
||||
return is_a_protected_JavaThread(thread);
|
||||
}
|
||||
|
||||
inline void ThreadsSMRSupport::update_smr_tlh_stats(uint millis) {
|
||||
ThreadsSMRSupport::inc_smr_tlh_cnt();
|
||||
ThreadsSMRSupport::add_smr_tlh_times(millis);
|
||||
ThreadsSMRSupport::update_smr_tlh_time_max(millis);
|
||||
inline void ThreadsSMRSupport::update_tlh_stats(uint millis) {
|
||||
ThreadsSMRSupport::inc_tlh_cnt();
|
||||
ThreadsSMRSupport::add_tlh_times(millis);
|
||||
ThreadsSMRSupport::update_tlh_time_max(millis);
|
||||
}
|
||||
|
||||
#endif // SHARE_VM_RUNTIME_THREADSMR_INLINE_HPP
|
||||
|
||||
@ -183,6 +183,9 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
jobject ret = NULL;
|
||||
jstring jVMVal = NULL;
|
||||
|
||||
if ((*env)->EnsureLocalCapacity(env, 50) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
sprops = GetJavaProperties(env);
|
||||
CHECK_NULL_RETURN(sprops, NULL);
|
||||
|
||||
|
||||
@ -107,7 +107,6 @@ suite = {
|
||||
"subDir" : "share/classes",
|
||||
"dependencies" : ["JVMCI_SERVICES", "JVMCI_API", "org.graalvm.util"],
|
||||
"sourceDirs" : ["src"],
|
||||
"dependencies" : ["org.graalvm.util"],
|
||||
"checkstyle" : "org.graalvm.compiler.graph",
|
||||
"uses" : ["org.graalvm.compiler.options.OptionDescriptors"],
|
||||
"javaCompliance" : "1.8",
|
||||
@ -148,6 +147,7 @@ suite = {
|
||||
"dependencies" : [
|
||||
"JVMCI_API",
|
||||
"org.graalvm.compiler.serviceprovider",
|
||||
"org.graalvm.graphio",
|
||||
"org.graalvm.compiler.options"
|
||||
],
|
||||
"annotationProcessors" : ["GRAAL_OPTIONS_PROCESSOR"],
|
||||
@ -291,7 +291,6 @@ suite = {
|
||||
"subDir" : "share/classes",
|
||||
"sourceDirs" : ["src"],
|
||||
"dependencies" : [
|
||||
"org.graalvm.compiler.core.aarch64",
|
||||
"org.graalvm.compiler.hotspot",
|
||||
"org.graalvm.compiler.replacements.aarch64",
|
||||
],
|
||||
@ -435,6 +434,7 @@ suite = {
|
||||
"mx:JUNIT",
|
||||
"org.graalvm.compiler.api.test",
|
||||
"org.graalvm.compiler.graph",
|
||||
"org.graalvm.graphio",
|
||||
],
|
||||
"annotationProcessors" : ["GRAAL_NODEINFO_PROCESSOR"],
|
||||
"javaCompliance" : "1.8",
|
||||
@ -945,6 +945,7 @@ suite = {
|
||||
"dependencies" : [
|
||||
"org.graalvm.compiler.lir.jtt",
|
||||
"org.graalvm.compiler.lir.amd64",
|
||||
"org.graalvm.compiler.core.amd64",
|
||||
"JVMCI_HOTSPOT"
|
||||
],
|
||||
"checkstyle" : "org.graalvm.compiler.graph",
|
||||
@ -1019,7 +1020,6 @@ suite = {
|
||||
"subDir" : "share/classes",
|
||||
"sourceDirs" : ["src"],
|
||||
"dependencies" : [
|
||||
"org.graalvm.graphio",
|
||||
"org.graalvm.compiler.core",
|
||||
"org.graalvm.compiler.java",
|
||||
],
|
||||
|
||||
@ -68,7 +68,7 @@ public class AArch64LIRKindTool implements LIRKindTool {
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(AArch64Kind.DWORD);
|
||||
return LIRKind.compressedReference(AArch64Kind.DWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -33,8 +33,9 @@ import jdk.vm.ci.meta.ValueKind;
|
||||
|
||||
/**
|
||||
* Represents the type of values in the LIR. It is composed of a {@link PlatformKind} that gives the
|
||||
* low level representation of the value, and a {@link #referenceMask} that describes the location
|
||||
* of object references in the value, and optionally a {@link #derivedReferenceBase}.
|
||||
* low level representation of the value, a {@link #referenceMask} that describes the location of
|
||||
* object references in the value, a {@link #referenceCompressionMask} that indicates which of these
|
||||
* references are compressed references, and for derived references a {@link #derivedReferenceBase}.
|
||||
*
|
||||
* <h2>Constructing {@link LIRKind} instances</h2>
|
||||
*
|
||||
@ -52,7 +53,7 @@ import jdk.vm.ci.meta.ValueKind;
|
||||
* compare-and-swap. For convert operations, {@link LIRKind#combine} should be used.
|
||||
* <p>
|
||||
* If it is known that the result will be a reference (e.g. pointer arithmetic where the end result
|
||||
* is a valid oop), {@link LIRKind#reference} should be used.
|
||||
* is a valid oop), {@link #reference} or {@link LIRKind#compressedReference} should be used.
|
||||
* <p>
|
||||
* If it is known that the result will neither be a reference nor be derived from a reference,
|
||||
* {@link LIRKind#value} can be used. If the operation producing this value has inputs, this is very
|
||||
@ -64,19 +65,28 @@ import jdk.vm.ci.meta.ValueKind;
|
||||
*/
|
||||
public final class LIRKind extends ValueKind<LIRKind> {
|
||||
|
||||
/**
|
||||
* The location of object references in the value. If the value is a vector type, each bit
|
||||
* represents one component of the vector.
|
||||
*/
|
||||
private final int referenceMask;
|
||||
|
||||
/** Mask with 1-bits indicating which references in {@link #referenceMask} are compressed. */
|
||||
private final int referenceCompressionMask;
|
||||
|
||||
private AllocatableValue derivedReferenceBase;
|
||||
|
||||
private static final int UNKNOWN_REFERENCE = -1;
|
||||
|
||||
public static final LIRKind Illegal = unknownReference(ValueKind.Illegal.getPlatformKind());
|
||||
|
||||
private LIRKind(PlatformKind platformKind, int referenceMask, AllocatableValue derivedReferenceBase) {
|
||||
private LIRKind(PlatformKind platformKind, int referenceMask, int referenceCompressionMask, AllocatableValue derivedReferenceBase) {
|
||||
super(platformKind);
|
||||
this.referenceMask = referenceMask;
|
||||
this.referenceCompressionMask = referenceCompressionMask;
|
||||
this.derivedReferenceBase = derivedReferenceBase;
|
||||
|
||||
assert this.referenceCompressionMask == 0 || this.referenceMask == this.referenceCompressionMask : "mixing compressed and uncompressed references is untested";
|
||||
assert derivedReferenceBase == null || !derivedReferenceBase.getValueKind(LIRKind.class).isDerivedReference() : "derived reference can't have another derived reference as base";
|
||||
}
|
||||
|
||||
@ -86,15 +96,23 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
* reference. Otherwise, {@link #combine(Value...)} should be used instead.
|
||||
*/
|
||||
public static LIRKind value(PlatformKind platformKind) {
|
||||
return new LIRKind(platformKind, 0, null);
|
||||
return new LIRKind(platformKind, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link LIRKind} of type {@code platformKind} that contains a single tracked oop
|
||||
* reference.
|
||||
* Create a {@link LIRKind} of type {@code platformKind} that contains a single, tracked,
|
||||
* uncompressed oop reference.
|
||||
*/
|
||||
public static LIRKind reference(PlatformKind platformKind) {
|
||||
return derivedReference(platformKind, null);
|
||||
return derivedReference(platformKind, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link LIRKind} of type {@code platformKind} that contains a single, tracked,
|
||||
* compressed oop reference.
|
||||
*/
|
||||
public static LIRKind compressedReference(PlatformKind platformKind) {
|
||||
return derivedReference(platformKind, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,10 +130,12 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
/**
|
||||
* Create a {@link LIRKind} of type {@code platformKind} that contains a derived reference.
|
||||
*/
|
||||
public static LIRKind derivedReference(PlatformKind platformKind, AllocatableValue base) {
|
||||
public static LIRKind derivedReference(PlatformKind platformKind, AllocatableValue base, boolean compressed) {
|
||||
int length = platformKind.getVectorLength();
|
||||
assert 0 < length && length < 32 : "vector of " + length + " references not supported";
|
||||
return new LIRKind(platformKind, (1 << length) - 1, base);
|
||||
int referenceMask = (1 << length) - 1;
|
||||
int referenceCompressionMask = (compressed ? referenceMask : 0);
|
||||
return new LIRKind(platformKind, referenceMask, referenceCompressionMask, base);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +145,7 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
* used instead to automatically propagate this information.
|
||||
*/
|
||||
public static LIRKind unknownReference(PlatformKind platformKind) {
|
||||
return new LIRKind(platformKind, UNKNOWN_REFERENCE, null);
|
||||
return new LIRKind(platformKind, UNKNOWN_REFERENCE, UNKNOWN_REFERENCE, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,9 +159,9 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
return makeUnknownReference();
|
||||
} else {
|
||||
if (isValue()) {
|
||||
return derivedReference(getPlatformKind(), base);
|
||||
return derivedReference(getPlatformKind(), base, false);
|
||||
} else {
|
||||
return new LIRKind(getPlatformKind(), referenceMask, base);
|
||||
return new LIRKind(getPlatformKind(), referenceMask, referenceCompressionMask, base);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -240,7 +260,7 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
return mergeKind;
|
||||
}
|
||||
/* {@code mergeKind} is a reference. */
|
||||
if (mergeKind.referenceMask != inputKind.referenceMask) {
|
||||
if (mergeKind.referenceMask != inputKind.referenceMask || mergeKind.referenceCompressionMask != inputKind.referenceCompressionMask) {
|
||||
/*
|
||||
* Reference masks do not match so the result can only be an unknown reference.
|
||||
*/
|
||||
@ -284,9 +304,11 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
} else {
|
||||
// reference type
|
||||
int newLength = Math.min(32, newPlatformKind.getVectorLength());
|
||||
int newReferenceMask = referenceMask & (0xFFFFFFFF >>> (32 - newLength));
|
||||
int lengthMask = 0xFFFFFFFF >>> (32 - newLength);
|
||||
int newReferenceMask = referenceMask & lengthMask;
|
||||
int newReferenceCompressionMask = referenceCompressionMask & lengthMask;
|
||||
assert newReferenceMask != UNKNOWN_REFERENCE;
|
||||
return new LIRKind(newPlatformKind, newReferenceMask, derivedReferenceBase);
|
||||
return new LIRKind(newPlatformKind, newReferenceMask, newReferenceCompressionMask, derivedReferenceBase);
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,12 +330,14 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
|
||||
// repeat reference mask to fill new kind
|
||||
int newReferenceMask = 0;
|
||||
int newReferenceCompressionMask = 0;
|
||||
for (int i = 0; i < newLength; i += getPlatformKind().getVectorLength()) {
|
||||
newReferenceMask |= referenceMask << i;
|
||||
newReferenceCompressionMask |= referenceCompressionMask << i;
|
||||
}
|
||||
|
||||
assert newReferenceMask != UNKNOWN_REFERENCE;
|
||||
return new LIRKind(newPlatformKind, newReferenceMask, derivedReferenceBase);
|
||||
return new LIRKind(newPlatformKind, newReferenceMask, newReferenceCompressionMask, derivedReferenceBase);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +346,7 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
* {@link LIRKind#unknownReference}.
|
||||
*/
|
||||
public LIRKind makeUnknownReference() {
|
||||
return new LIRKind(getPlatformKind(), UNKNOWN_REFERENCE, null);
|
||||
return new LIRKind(getPlatformKind(), UNKNOWN_REFERENCE, UNKNOWN_REFERENCE, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,6 +408,17 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
return !isUnknownReference() && (referenceMask & 1 << idx) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the {@code idx}th part of this value is a <b>compressed</b> reference.
|
||||
*
|
||||
* @param idx The index into the vector if this is a vector kind. Must be 0 if this is a scalar
|
||||
* kind.
|
||||
*/
|
||||
public boolean isCompressedReference(int idx) {
|
||||
assert 0 <= idx && idx < getPlatformKind().getVectorLength() : "invalid index " + idx + " in " + this;
|
||||
return !isUnknownReference() && (referenceCompressionMask & (1 << idx)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this kind is a value type that doesn't need to be tracked at safepoints.
|
||||
*/
|
||||
@ -432,6 +467,7 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
result = prime * result + ((getPlatformKind() == null) ? 0 : getPlatformKind().hashCode());
|
||||
result = prime * result + ((getDerivedReferenceBase() == null) ? 0 : getDerivedReferenceBase().hashCode());
|
||||
result = prime * result + referenceMask;
|
||||
result = prime * result + referenceCompressionMask;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -445,7 +481,7 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
}
|
||||
|
||||
LIRKind other = (LIRKind) obj;
|
||||
if (getPlatformKind() != other.getPlatformKind() || referenceMask != other.referenceMask) {
|
||||
if (getPlatformKind() != other.getPlatformKind() || referenceMask != other.referenceMask || referenceCompressionMask != other.referenceCompressionMask) {
|
||||
return false;
|
||||
}
|
||||
if (isDerivedReference()) {
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
*/
|
||||
package org.graalvm.compiler.core.common.util;
|
||||
|
||||
import org.graalvm.compiler.debug.Assertions;
|
||||
import org.graalvm.compiler.options.Option;
|
||||
import org.graalvm.compiler.options.OptionKey;
|
||||
import org.graalvm.compiler.options.OptionType;
|
||||
@ -34,7 +35,8 @@ public final class CompilationAlarm implements AutoCloseable {
|
||||
|
||||
public static class Options {
|
||||
// @formatter:off
|
||||
@Option(help = "Time limit in seconds before a compilation expires (0 to disable the limit).", type = OptionType.Debug)
|
||||
@Option(help = "Time limit in seconds before a compilation expires (0 to disable the limit). " +
|
||||
"The compilation alarm will be implicitly disabled if assertions are enabled.", type = OptionType.Debug)
|
||||
public static final OptionKey<Integer> CompilationExpirationPeriod = new OptionKey<>(300);
|
||||
// @formatter:on
|
||||
}
|
||||
@ -85,15 +87,16 @@ public final class CompilationAlarm implements AutoCloseable {
|
||||
|
||||
/**
|
||||
* Starts an alarm for setting a time limit on a compilation if there isn't already an active
|
||||
* alarm and {@link CompilationAlarm.Options#CompilationExpirationPeriod}{@code > 0}. The
|
||||
* returned value can be used in a try-with-resource statement to disable the alarm once the
|
||||
* compilation is finished.
|
||||
* alarm, if assertions are disabled and
|
||||
* {@link CompilationAlarm.Options#CompilationExpirationPeriod}{@code > 0}. The returned value
|
||||
* can be used in a try-with-resource statement to disable the alarm once the compilation is
|
||||
* finished.
|
||||
*
|
||||
* @return a {@link CompilationAlarm} if there was no current alarm for the calling thread
|
||||
* before this call otherwise {@code null}
|
||||
*/
|
||||
public static CompilationAlarm trackCompilationPeriod(OptionValues options) {
|
||||
int period = Options.CompilationExpirationPeriod.getValue(options);
|
||||
int period = Assertions.assertionsEnabled() ? 0 : Options.CompilationExpirationPeriod.getValue(options);
|
||||
if (period > 0) {
|
||||
CompilationAlarm current = currentAlarm.get();
|
||||
if (current == null) {
|
||||
@ -105,4 +108,5 @@ public final class CompilationAlarm implements AutoCloseable {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class SPARCLIRKindTool implements LIRKindTool {
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(SPARCKind.WORD);
|
||||
return LIRKind.compressedReference(SPARCKind.WORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import static org.graalvm.compiler.core.common.util.CompilationAlarm.Options.CompilationExpirationPeriod;
|
||||
|
||||
import org.graalvm.compiler.core.common.RetryableBailoutException;
|
||||
import org.graalvm.compiler.core.common.util.CompilationAlarm;
|
||||
import org.graalvm.compiler.debug.GraalError;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.options.OptionValues;
|
||||
import org.graalvm.compiler.phases.Phase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CooperativePhaseTest extends GraalCompilerTest {
|
||||
|
||||
public static void snippet() {
|
||||
// dummy snippet
|
||||
}
|
||||
|
||||
private static class CooperativePhase extends Phase {
|
||||
|
||||
@Override
|
||||
protected void run(StructuredGraph graph) {
|
||||
CompilationAlarm compilationAlarm = CompilationAlarm.current();
|
||||
while (true) {
|
||||
sleep(200);
|
||||
if (compilationAlarm.hasExpired()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class UnCooperativePhase extends Phase {
|
||||
|
||||
@Override
|
||||
protected void run(StructuredGraph graph) {
|
||||
CompilationAlarm compilationAlarm = CompilationAlarm.current();
|
||||
while (true) {
|
||||
sleep(200);
|
||||
if (compilationAlarm.hasExpired()) {
|
||||
throw new RetryableBailoutException("Expiring...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class PartiallyCooperativePhase extends Phase {
|
||||
|
||||
@Override
|
||||
protected void run(StructuredGraph graph) {
|
||||
CompilationAlarm compilationAlarm = CompilationAlarm.current();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sleep(200);
|
||||
if (compilationAlarm.hasExpired()) {
|
||||
throw new RuntimeException("Phase must not exit in the timeout path");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class CooperativePhaseWithoutAlarm extends Phase {
|
||||
|
||||
@Override
|
||||
protected void run(StructuredGraph graph) {
|
||||
CompilationAlarm compilationAlarm = CompilationAlarm.current();
|
||||
if (compilationAlarm.hasExpired()) {
|
||||
throw new RuntimeException("Phase must not exit in the timeout path");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sleep(long millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {
|
||||
GraalError.shouldNotReachHere(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 60_000)
|
||||
@SuppressWarnings("try")
|
||||
public void test01() {
|
||||
initializeForTimeout();
|
||||
OptionValues initialOptions = getInitialOptions();
|
||||
OptionValues options = new OptionValues(initialOptions, CompilationExpirationPeriod, 1/* sec */);
|
||||
try (CompilationAlarm c1 = CompilationAlarm.trackCompilationPeriod(options)) {
|
||||
StructuredGraph g = parseEager("snippet", AllowAssumptions.NO, options);
|
||||
new CooperativePhase().apply(g);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = RetryableBailoutException.class, timeout = 60_000)
|
||||
@SuppressWarnings("try")
|
||||
public void test02() {
|
||||
initializeForTimeout();
|
||||
OptionValues initialOptions = getInitialOptions();
|
||||
OptionValues options = new OptionValues(initialOptions, CompilationExpirationPeriod, 1/* sec */);
|
||||
try (CompilationAlarm c1 = CompilationAlarm.trackCompilationPeriod(options)) {
|
||||
StructuredGraph g = parseEager("snippet", AllowAssumptions.NO, options);
|
||||
new UnCooperativePhase().apply(g);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 60_000)
|
||||
@SuppressWarnings("try")
|
||||
public void test03() {
|
||||
initializeForTimeout();
|
||||
// 0 disables alarm utility
|
||||
OptionValues initialOptions = getInitialOptions();
|
||||
OptionValues options = new OptionValues(initialOptions, CompilationExpirationPeriod, 0);
|
||||
try (CompilationAlarm c1 = CompilationAlarm.trackCompilationPeriod(options)) {
|
||||
StructuredGraph g = parseEager("snippet", AllowAssumptions.NO, options);
|
||||
new PartiallyCooperativePhase().apply(g);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 60_000)
|
||||
@SuppressWarnings("try")
|
||||
public void test04() {
|
||||
initializeForTimeout();
|
||||
StructuredGraph g = parseEager("snippet", AllowAssumptions.NO);
|
||||
new CooperativePhaseWithoutAlarm().apply(g);
|
||||
}
|
||||
}
|
||||
@ -264,7 +264,7 @@ public class CountedLoopTest extends GraalCompilerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkMidTierGraph(StructuredGraph graph) {
|
||||
protected boolean checkHighTierGraph(StructuredGraph graph) {
|
||||
LoopsData loops = new LoopsData(graph);
|
||||
loops.detectedCountedLoops();
|
||||
for (IVPropertyNode node : graph.getNodes().filter(IVPropertyNode.class)) {
|
||||
|
||||
@ -54,8 +54,8 @@ public class Assertions {
|
||||
// @formatter:off
|
||||
public static class Options {
|
||||
|
||||
@Option(help = "Enable expensive assertions. (Require normal assertions enabled)", type = OptionType.Debug)
|
||||
public static final OptionKey<Boolean> DetailedAsserts = new OptionKey<>(true);
|
||||
@Option(help = "Enable expensive assertions if normal assertions (i.e. -ea or -esa) are enabled.", type = OptionType.Debug)
|
||||
public static final OptionKey<Boolean> DetailedAsserts = new OptionKey<>(false);
|
||||
|
||||
}
|
||||
// @formatter:on
|
||||
|
||||
@ -472,6 +472,11 @@ public class Graph {
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Node> T addWithoutUniqueWithInputs(T node) {
|
||||
addInputs(node);
|
||||
return addHelper(node);
|
||||
}
|
||||
|
||||
private final class AddInputsFilter extends Node.EdgeVisitor {
|
||||
|
||||
@Override
|
||||
|
||||
@ -30,6 +30,7 @@ import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.JUMP_ADDRES
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.RegisterEffect.PRESERVES_REGISTERS;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF;
|
||||
import static org.graalvm.compiler.hotspot.replacements.CRC32Substitutions.UPDATE_BYTES_CRC32;
|
||||
import static org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions.UPDATE_BYTES_CRC32C;
|
||||
import static org.graalvm.word.LocationIdentity.any;
|
||||
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
@ -79,6 +80,9 @@ public class AArch64HotSpotForeignCallsProvider extends HotSpotHostForeignCallsP
|
||||
if (config.useCRC32Intrinsics) {
|
||||
registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
|
||||
}
|
||||
if (config.useCRC32CIntrinsics) {
|
||||
registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
|
||||
}
|
||||
|
||||
super.initialize(providers, options);
|
||||
}
|
||||
|
||||
@ -30,8 +30,8 @@ import java.util.function.Function;
|
||||
|
||||
import org.graalvm.compiler.asm.Label;
|
||||
import org.graalvm.compiler.asm.aarch64.AArch64Address.AddressingMode;
|
||||
import org.graalvm.compiler.asm.aarch64.AArch64Assembler.PrefetchMode;
|
||||
import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag;
|
||||
import org.graalvm.compiler.asm.aarch64.AArch64Assembler.PrefetchMode;
|
||||
import org.graalvm.compiler.core.aarch64.AArch64ArithmeticLIRGenerator;
|
||||
import org.graalvm.compiler.core.aarch64.AArch64LIRGenerator;
|
||||
import org.graalvm.compiler.core.aarch64.AArch64LIRKindTool;
|
||||
@ -202,7 +202,7 @@ public class AArch64HotSpotLIRGenerator extends AArch64LIRGenerator implements H
|
||||
assert inputKind.getPlatformKind() == AArch64Kind.QWORD;
|
||||
if (inputKind.isReference(0)) {
|
||||
// oop
|
||||
Variable result = newVariable(LIRKind.reference(AArch64Kind.DWORD));
|
||||
Variable result = newVariable(LIRKind.compressedReference(AArch64Kind.DWORD));
|
||||
append(new AArch64HotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
|
||||
return result;
|
||||
} else {
|
||||
|
||||
@ -33,6 +33,7 @@ import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.RegisterEff
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF_NOFP;
|
||||
import static org.graalvm.compiler.hotspot.replacements.CRC32Substitutions.UPDATE_BYTES_CRC32;
|
||||
import static org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions.UPDATE_BYTES_CRC32C;
|
||||
import static org.graalvm.word.LocationIdentity.any;
|
||||
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
@ -99,6 +100,9 @@ public class AMD64HotSpotForeignCallsProvider extends HotSpotHostForeignCallsPro
|
||||
// This stub does callee saving
|
||||
registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
|
||||
}
|
||||
if (config.useCRC32CIntrinsics) {
|
||||
registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
|
||||
}
|
||||
|
||||
super.initialize(providers, options);
|
||||
}
|
||||
|
||||
@ -22,14 +22,15 @@
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.amd64;
|
||||
|
||||
import jdk.vm.ci.amd64.AMD64Kind;
|
||||
import org.graalvm.compiler.core.amd64.AMD64LIRKindTool;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
|
||||
import jdk.vm.ci.amd64.AMD64Kind;
|
||||
|
||||
public class AMD64HotSpotLIRKindTool extends AMD64LIRKindTool {
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(AMD64Kind.DWORD);
|
||||
return LIRKind.compressedReference(AMD64Kind.DWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -34,6 +34,7 @@ import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.JUMP_ADDRES
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.RegisterEffect.PRESERVES_REGISTERS;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF_NOFP;
|
||||
import static org.graalvm.compiler.hotspot.replacements.CRC32Substitutions.UPDATE_BYTES_CRC32;
|
||||
import static org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions.UPDATE_BYTES_CRC32C;
|
||||
import static org.graalvm.word.LocationIdentity.any;
|
||||
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
@ -87,6 +88,9 @@ public class SPARCHotSpotForeignCallsProvider extends HotSpotHostForeignCallsPro
|
||||
// This stub does callee saving
|
||||
registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
|
||||
}
|
||||
if (config.useCRC32CIntrinsics) {
|
||||
registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
|
||||
}
|
||||
|
||||
super.initialize(providers, options);
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ public class SPARCHotSpotLIRGenerator extends SPARCLIRGenerator implements HotSp
|
||||
assert inputKind.getPlatformKind() == XWORD : inputKind;
|
||||
if (inputKind.isReference(0)) {
|
||||
// oop
|
||||
Variable result = newVariable(LIRKind.reference(WORD));
|
||||
Variable result = newVariable(LIRKind.compressedReference(WORD));
|
||||
append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
|
||||
return result;
|
||||
} else {
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2017, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
|
||||
import org.graalvm.compiler.test.GraalTest;
|
||||
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
|
||||
/**
|
||||
* Tests compiled calls to {@link java.util.zip.CRC32C}.
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class CRC32CSubstitutionsTest extends GraalCompilerTest {
|
||||
|
||||
public static long updateBytes(byte[] input, int offset, int end) throws Throwable {
|
||||
Class<?> crcClass = Class.forName("java.util.zip.CRC32C");
|
||||
MethodHandle newMH = MethodHandles.publicLookup().findConstructor(crcClass, MethodType.methodType(void.class));
|
||||
Checksum crc = (Checksum) newMH.invoke();
|
||||
crc.update(input, offset, end);
|
||||
return crc.getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() throws Throwable {
|
||||
assumeFalse(GraalTest.Java8OrEarlier);
|
||||
String classfileName = CRC32CSubstitutionsTest.class.getSimpleName().replace('.', '/') + ".class";
|
||||
InputStream s = CRC32CSubstitutionsTest.class.getResourceAsStream(classfileName);
|
||||
byte[] buf = new byte[s.available()];
|
||||
new DataInputStream(s).readFully(buf);
|
||||
int end = buf.length;
|
||||
for (int offset = 0; offset < buf.length; offset++) {
|
||||
test("updateBytes", buf, offset, end);
|
||||
}
|
||||
}
|
||||
|
||||
public static long updateByteBuffer(ByteBuffer buffer) throws Throwable {
|
||||
Class<?> crcClass = Class.forName("java.util.zip.CRC32C");
|
||||
MethodHandle newMH = MethodHandles.publicLookup().findConstructor(crcClass, MethodType.methodType(void.class));
|
||||
MethodHandle updateMH = MethodHandles.publicLookup().findVirtual(crcClass, "update", MethodType.methodType(void.class, ByteBuffer.class));
|
||||
Checksum crc = (Checksum) newMH.invoke();
|
||||
buffer.rewind();
|
||||
updateMH.invokeExact(crc, buffer); // Checksum.update(ByteBuffer) is also available since 9
|
||||
return crc.getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws Throwable {
|
||||
assumeFalse(GraalTest.Java8OrEarlier);
|
||||
String classfileName = CRC32CSubstitutionsTest.class.getSimpleName().replace('.', '/') + ".class";
|
||||
InputStream s = CRC32CSubstitutionsTest.class.getResourceAsStream(classfileName);
|
||||
byte[] buf = new byte[s.available()];
|
||||
new DataInputStream(s).readFully(buf);
|
||||
|
||||
ByteBuffer directBuf = ByteBuffer.allocateDirect(buf.length);
|
||||
directBuf.put(buf);
|
||||
ByteBuffer heapBuf = ByteBuffer.wrap(buf);
|
||||
|
||||
test("updateByteBuffer", directBuf);
|
||||
test("updateByteBuffer", heapBuf);
|
||||
}
|
||||
|
||||
}
|
||||
@ -466,6 +466,13 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
}
|
||||
}
|
||||
|
||||
// CRC32C intrinsics
|
||||
if (!config.useCRC32CIntrinsics) {
|
||||
add(IGNORE,
|
||||
"java/util/zip/CRC32C.updateBytes(I[BII)I",
|
||||
"java/util/zip/CRC32C.updateDirectByteBuffer(IJII)I");
|
||||
}
|
||||
|
||||
// AES intrinsics
|
||||
if (!config.useAESIntrinsics) {
|
||||
if (isJDK9OrHigher()) {
|
||||
|
||||
@ -33,9 +33,9 @@ import org.graalvm.compiler.code.CompilationResult;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.core.common.type.StampFactory;
|
||||
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
||||
import org.graalvm.compiler.debug.DebugHandlersFactory;
|
||||
import org.graalvm.compiler.debug.DebugContext;
|
||||
import org.graalvm.compiler.debug.DebugContext.Scope;
|
||||
import org.graalvm.compiler.debug.DebugHandlersFactory;
|
||||
import org.graalvm.compiler.graph.NodeClass;
|
||||
import org.graalvm.compiler.hotspot.HotSpotCompiledCodeBuilder;
|
||||
import org.graalvm.compiler.lir.FullInfopointOp;
|
||||
@ -150,7 +150,7 @@ public class JVMCIInfopointErrorTest extends GraalCompilerTest {
|
||||
codeCache.addCode(method, compiledCode, null, null);
|
||||
}
|
||||
|
||||
@Test(expected = JVMCIError.class)
|
||||
@Test(expected = Error.class)
|
||||
public void testInvalidShortOop() {
|
||||
test((tool, state, safepoint) -> {
|
||||
PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
|
||||
@ -163,14 +163,14 @@ public class JVMCIInfopointErrorTest extends GraalCompilerTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = JVMCIError.class)
|
||||
@Test(expected = Error.class)
|
||||
public void testInvalidShortDerivedOop() {
|
||||
test((tool, state, safepoint) -> {
|
||||
Variable baseOop = tool.newVariable(LIRKind.fromJavaKind(tool.target().arch, JavaKind.Object));
|
||||
tool.append(new ValueDef(baseOop));
|
||||
|
||||
PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
|
||||
LIRKind lirKind = LIRKind.derivedReference(kind, baseOop);
|
||||
LIRKind lirKind = LIRKind.derivedReference(kind, baseOop, false);
|
||||
|
||||
Variable var = tool.newVariable(lirKind);
|
||||
tool.append(new ValueDef(var));
|
||||
|
||||
@ -165,6 +165,7 @@ public class GraalHotSpotVMConfig extends HotSpotVMConfigAccess {
|
||||
public final boolean usePopCountInstruction = getFlag("UsePopCountInstruction", Boolean.class);
|
||||
public final boolean useAESIntrinsics = getFlag("UseAESIntrinsics", Boolean.class);
|
||||
public final boolean useCRC32Intrinsics = getFlag("UseCRC32Intrinsics", Boolean.class);
|
||||
public final boolean useCRC32CIntrinsics = isJDK8 ? false : getFlag("UseCRC32CIntrinsics", Boolean.class);
|
||||
public final boolean threadLocalHandshakes = getFlag("ThreadLocalHandshakes", Boolean.class, false);
|
||||
|
||||
private final boolean useMultiplyToLenIntrinsic = getFlag("UseMultiplyToLenIntrinsic", Boolean.class);
|
||||
|
||||
@ -45,6 +45,7 @@ import jdk.vm.ci.code.CallingConvention;
|
||||
import jdk.vm.ci.common.InitTimer;
|
||||
import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
|
||||
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.meta.JavaType;
|
||||
import jdk.vm.ci.runtime.JVMCICompiler;
|
||||
|
||||
@ -142,7 +143,8 @@ public abstract class HotSpotHostBackend extends HotSpotBackend {
|
||||
|
||||
@Override
|
||||
public ReferenceMapBuilder newReferenceMapBuilder(int totalFrameSize) {
|
||||
return new HotSpotReferenceMapBuilder(totalFrameSize, config.maxOopMapStackOffset);
|
||||
int uncompressedReferenceSize = getTarget().arch.getPlatformKind(JavaKind.Object).getSizeInBytes();
|
||||
return new HotSpotReferenceMapBuilder(totalFrameSize, config.maxOopMapStackOffset, uncompressedReferenceSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,15 +22,15 @@
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot;
|
||||
|
||||
import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
|
||||
import static jdk.vm.ci.code.ValueUtil.asRegister;
|
||||
import static jdk.vm.ci.code.ValueUtil.asStackSlot;
|
||||
import static jdk.vm.ci.code.ValueUtil.isRegister;
|
||||
import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.graalvm.compiler.core.common.PermanentBailoutException;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.core.common.PermanentBailoutException;
|
||||
import org.graalvm.compiler.debug.GraalError;
|
||||
import org.graalvm.compiler.lir.LIRFrameState;
|
||||
import org.graalvm.compiler.lir.Variable;
|
||||
@ -52,8 +52,10 @@ public final class HotSpotReferenceMapBuilder extends ReferenceMapBuilder {
|
||||
|
||||
private final int totalFrameSize;
|
||||
private final int maxOopMapStackOffset;
|
||||
private final int uncompressedReferenceSize;
|
||||
|
||||
public HotSpotReferenceMapBuilder(int totalFrameSize, int maxOopMapStackOffset) {
|
||||
public HotSpotReferenceMapBuilder(int totalFrameSize, int maxOopMapStackOffset, int uncompressedReferenceSize) {
|
||||
this.uncompressedReferenceSize = uncompressedReferenceSize;
|
||||
this.objectValues = new ArrayList<>();
|
||||
this.objectCount = 0;
|
||||
this.maxOopMapStackOffset = maxOopMapStackOffset;
|
||||
@ -116,6 +118,7 @@ public final class HotSpotReferenceMapBuilder extends ReferenceMapBuilder {
|
||||
|
||||
for (int i = 0; i < kind.getPlatformKind().getVectorLength(); i++) {
|
||||
if (kind.isReference(i)) {
|
||||
assert kind.isCompressedReference(i) ? (bytes < uncompressedReferenceSize) : (bytes == uncompressedReferenceSize);
|
||||
objects[idx] = toLocation(obj, i * bytes);
|
||||
derivedBase[idx] = base;
|
||||
sizeInBytes[idx] = bytes;
|
||||
|
||||
@ -46,6 +46,7 @@ import org.graalvm.compiler.hotspot.nodes.CurrentJavaThreadNode;
|
||||
import org.graalvm.compiler.hotspot.replacements.AESCryptSubstitutions;
|
||||
import org.graalvm.compiler.hotspot.replacements.BigIntegerSubstitutions;
|
||||
import org.graalvm.compiler.hotspot.replacements.CRC32Substitutions;
|
||||
import org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions;
|
||||
import org.graalvm.compiler.hotspot.replacements.CallSiteTargetNode;
|
||||
import org.graalvm.compiler.hotspot.replacements.CipherBlockChainingSubstitutions;
|
||||
import org.graalvm.compiler.hotspot.replacements.ClassGetHubNode;
|
||||
@ -165,6 +166,7 @@ public class HotSpotGraphBuilderPlugins {
|
||||
registerConstantPoolPlugins(invocationPlugins, wordTypes, config, replacementBytecodeProvider);
|
||||
registerAESPlugins(invocationPlugins, config, replacementBytecodeProvider);
|
||||
registerCRC32Plugins(invocationPlugins, config, replacementBytecodeProvider);
|
||||
registerCRC32CPlugins(invocationPlugins, config, replacementBytecodeProvider);
|
||||
registerBigIntegerPlugins(invocationPlugins, config, replacementBytecodeProvider);
|
||||
registerSHAPlugins(invocationPlugins, config, replacementBytecodeProvider);
|
||||
registerUnsafePlugins(invocationPlugins, replacementBytecodeProvider);
|
||||
@ -530,4 +532,12 @@ public class HotSpotGraphBuilderPlugins {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerCRC32CPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
|
||||
if (config.useCRC32CIntrinsics) {
|
||||
Registration r = new Registration(plugins, "java.util.zip.CRC32C", bytecodeProvider);
|
||||
r.registerMethodSubstitution(CRC32CSubstitutions.class, "updateBytes", int.class, byte[].class, int.class, int.class);
|
||||
r.registerMethodSubstitution(CRC32CSubstitutions.class, "updateDirectByteBuffer", int.class, long.class, int.class, int.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2017, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.replacements;
|
||||
|
||||
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.arrayBaseOffset;
|
||||
|
||||
import org.graalvm.compiler.api.replacements.ClassSubstitution;
|
||||
import org.graalvm.compiler.api.replacements.MethodSubstitution;
|
||||
import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
|
||||
import org.graalvm.compiler.graph.Node.ConstantNodeParameter;
|
||||
import org.graalvm.compiler.graph.Node.NodeIntrinsic;
|
||||
import org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode;
|
||||
import org.graalvm.compiler.nodes.extended.ForeignCallNode;
|
||||
import org.graalvm.compiler.word.Word;
|
||||
import org.graalvm.word.WordBase;
|
||||
import org.graalvm.word.WordFactory;
|
||||
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
|
||||
// JaCoCo Exclude
|
||||
|
||||
/**
|
||||
* Substitutions for java.util.zip.CRC32C.
|
||||
*/
|
||||
@ClassSubstitution(className = "java.util.zip.CRC32C", optional = true)
|
||||
public class CRC32CSubstitutions {
|
||||
|
||||
@MethodSubstitution
|
||||
static int updateBytes(int crc, byte[] b, int off, int end) {
|
||||
Word bufAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(b, arrayBaseOffset(JavaKind.Byte) + off));
|
||||
return updateBytesCRC32(UPDATE_BYTES_CRC32C, crc, bufAddr, end - off);
|
||||
}
|
||||
|
||||
@MethodSubstitution
|
||||
static int updateDirectByteBuffer(int crc, long addr, int off, int end) {
|
||||
WordBase bufAddr = WordFactory.unsigned(addr).add(off);
|
||||
return updateBytesCRC32(UPDATE_BYTES_CRC32C, crc, bufAddr, end - off);
|
||||
}
|
||||
|
||||
public static final ForeignCallDescriptor UPDATE_BYTES_CRC32C = new ForeignCallDescriptor("updateBytesCRC32C", int.class, int.class, WordBase.class, int.class);
|
||||
|
||||
@NodeIntrinsic(ForeignCallNode.class)
|
||||
public static native int updateBytesCRC32(@ConstantNodeParameter ForeignCallDescriptor descriptor, int crc, WordBase buf, int length);
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.jtt.bytecode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.jtt.JTTTest;
|
||||
|
||||
/*
|
||||
*/
|
||||
public class BC_idiv_overflow extends JTTTest {
|
||||
|
||||
public static int test(int a, int b) {
|
||||
return a / (b | 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run0() throws Throwable {
|
||||
runTest("test", Integer.MIN_VALUE, -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run1() throws Throwable {
|
||||
runTest("test", Integer.MIN_VALUE, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.jtt.bytecode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.jtt.JTTTest;
|
||||
|
||||
/*
|
||||
*/
|
||||
public class BC_ldiv_overflow extends JTTTest {
|
||||
|
||||
public static long test(long a, long b) {
|
||||
return a / (b | 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run0() throws Throwable {
|
||||
runTest("test", Long.MIN_VALUE, -1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run1() throws Throwable {
|
||||
runTest("test", Long.MIN_VALUE, 1L);
|
||||
}
|
||||
|
||||
}
|
||||
@ -30,8 +30,6 @@ import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.meta.ResolvedJavaType;
|
||||
import org.graalvm.compiler.core.common.calc.Condition;
|
||||
import org.graalvm.compiler.core.common.type.IntegerStamp;
|
||||
import org.graalvm.compiler.core.common.type.Stamp;
|
||||
@ -67,7 +65,9 @@ import org.graalvm.util.Equivalence;
|
||||
import jdk.vm.ci.meta.Constant;
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.meta.PrimitiveConstant;
|
||||
import jdk.vm.ci.meta.ResolvedJavaType;
|
||||
|
||||
/**
|
||||
* The {@code IfNode} represents a branch that can go one of two directions depending on the outcome
|
||||
@ -416,6 +416,7 @@ public final class IfNode extends ControlSplitNode implements Simplifiable, LIRL
|
||||
if (result.graph() == null) {
|
||||
result = graph().addOrUniqueWithInputs(result);
|
||||
}
|
||||
result = proxyReplacement(result);
|
||||
/*
|
||||
* This optimization can be performed even if multiple values merge at this phi
|
||||
* since the two inputs get simplified into one.
|
||||
@ -698,6 +699,7 @@ public final class IfNode extends ControlSplitNode implements Simplifiable, LIRL
|
||||
ValueNode falseValue = singlePhi.valueAt(falseEnd);
|
||||
ValueNode conditional = canonicalizeConditionalCascade(tool, trueValue, falseValue);
|
||||
if (conditional != null) {
|
||||
conditional = proxyReplacement(conditional);
|
||||
singlePhi.setValueAt(trueEnd, conditional);
|
||||
removeThroughFalseBranch(tool, merge);
|
||||
return true;
|
||||
@ -729,6 +731,36 @@ public final class IfNode extends ControlSplitNode implements Simplifiable, LIRL
|
||||
return false;
|
||||
}
|
||||
|
||||
private ValueNode proxyReplacement(ValueNode replacement) {
|
||||
/*
|
||||
* Special case: Every empty diamond we collapse to a conditional node can potentially
|
||||
* contain loop exit nodes on both branches. See the graph below: The two loop exits
|
||||
* (instanceof begin node) exit the same loop. The resulting phi is defined outside the
|
||||
* loop, but the resulting conditional node will be inside the loop, so we need to proxy the
|
||||
* resulting conditional node. Callers of this method ensure that true and false successor
|
||||
* have no usages, therefore a and b in the graph below can never be proxies themselves.
|
||||
*/
|
||||
// @formatter:off
|
||||
// +--+
|
||||
// |If|
|
||||
// +--+ +-----+ +-----+
|
||||
// +----+ +----+ | a | | b |
|
||||
// |Lex | |Lex | +----^+ +^----+
|
||||
// +----+ +----+ | |
|
||||
// +-------+ +---+
|
||||
// | Merge +---------+Phi|
|
||||
// +-------+ +---+
|
||||
// @formatter:on
|
||||
if (this.graph().hasValueProxies()) {
|
||||
if (trueSuccessor instanceof LoopExitNode && falseSuccessor instanceof LoopExitNode) {
|
||||
assert ((LoopExitNode) trueSuccessor).loopBegin() == ((LoopExitNode) falseSuccessor).loopBegin();
|
||||
assert trueSuccessor.usages().isEmpty() && falseSuccessor.usages().isEmpty();
|
||||
return this.graph().addOrUnique(new ValueProxyNode(replacement, (LoopExitNode) trueSuccessor));
|
||||
}
|
||||
}
|
||||
return replacement;
|
||||
}
|
||||
|
||||
protected void removeThroughFalseBranch(SimplifierTool tool, AbstractMergeNode merge) {
|
||||
AbstractBeginNode trueBegin = trueSuccessor();
|
||||
LogicNode conditionNode = condition();
|
||||
|
||||
@ -60,7 +60,8 @@ public abstract class IntegerDivRemNode extends FixedBinaryNode implements Lower
|
||||
|
||||
// Assigning canDeopt during constructor, because it must never change during lifetime of
|
||||
// the node.
|
||||
this.canDeopt = ((IntegerStamp) getY().stamp(NodeView.DEFAULT)).contains(0);
|
||||
IntegerStamp yStamp = (IntegerStamp) getY().stamp(NodeView.DEFAULT);
|
||||
this.canDeopt = yStamp.contains(0) || yStamp.contains(-1);
|
||||
}
|
||||
|
||||
public final Op getOp() {
|
||||
|
||||
@ -121,7 +121,7 @@ public class ProfileCompiledMethodsPhase extends Phase {
|
||||
|
||||
private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
|
||||
HashSet<Block> blocks = new HashSet<>(sectionBlocks);
|
||||
for (Loop<?> loop : childLoops) {
|
||||
for (Loop<Block> loop : childLoops) {
|
||||
blocks.removeAll(loop.getBlocks());
|
||||
}
|
||||
double weight = getSectionWeight(schedule, blocks) / cfg.blockFor(start).probability();
|
||||
|
||||
@ -194,15 +194,26 @@ interface GraphPrinter extends Closeable, JavaConstantFormatter {
|
||||
|
||||
static String constantToString(Object value) {
|
||||
Class<?> c = value.getClass();
|
||||
String suffix = "";
|
||||
if (c.isArray()) {
|
||||
return constantArrayToString(value);
|
||||
} else if (value instanceof Enum) {
|
||||
return ((Enum<?>) value).name();
|
||||
} else if (isToStringTrusted(c)) {
|
||||
return value.toString();
|
||||
try {
|
||||
return value.toString();
|
||||
} catch (Throwable t) {
|
||||
suffix = "[toString error: " + t.getClass().getName() + "]";
|
||||
if (isToStringTrusted(t.getClass())) {
|
||||
try {
|
||||
suffix = "[toString error: " + t + "]";
|
||||
} catch (Throwable t2) {
|
||||
// No point in going further
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return MetaUtil.getSimpleName(c, true) + "@" + Integer.toHexString(System.identityHashCode(value));
|
||||
|
||||
return MetaUtil.getSimpleName(c, true) + "@" + Integer.toHexString(System.identityHashCode(value)) + suffix;
|
||||
}
|
||||
|
||||
static String constantArrayToString(Object array) {
|
||||
|
||||
@ -141,6 +141,7 @@ public class StandardGraphBuilderPlugins {
|
||||
registerJMHBlackholePlugins(plugins, bytecodeProvider);
|
||||
registerJFRThrowablePlugins(plugins, bytecodeProvider);
|
||||
registerMethodHandleImplPlugins(plugins, snippetReflection, bytecodeProvider);
|
||||
registerJcovCollectPlugins(plugins, bytecodeProvider);
|
||||
}
|
||||
|
||||
private static final Field STRING_VALUE_FIELD;
|
||||
@ -910,4 +911,21 @@ public class StandardGraphBuilderPlugins {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a plugin to ignore {@code com.sun.tdk.jcov.runtime.Collect.hit} within an
|
||||
* intrinsic.
|
||||
*/
|
||||
private static void registerJcovCollectPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
|
||||
Registration r = new Registration(plugins, "com.sun.tdk.jcov.runtime.Collect", bytecodeProvider);
|
||||
r.register1("hit", int.class, new InvocationPlugin() {
|
||||
@Override
|
||||
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
|
||||
if (b.parsingIntrinsic()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ import org.graalvm.compiler.nodes.IfNode;
|
||||
import org.graalvm.compiler.nodes.NodeView;
|
||||
import org.graalvm.compiler.nodes.PhiNode;
|
||||
import org.graalvm.compiler.nodes.PiNode;
|
||||
import org.graalvm.compiler.nodes.ProxyNode;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.debug.DynamicCounterNode;
|
||||
@ -116,14 +115,7 @@ public final class GraphEffectList extends EffectList {
|
||||
*/
|
||||
public void addFloatingNode(ValueNode node, @SuppressWarnings("unused") String cause) {
|
||||
add("add floating node", graph -> {
|
||||
if (node instanceof ProxyNode) {
|
||||
ProxyNode proxyNode = (ProxyNode) node;
|
||||
ValueNode value = proxyNode.value();
|
||||
if (!value.isAlive()) {
|
||||
graph.addWithoutUnique(value);
|
||||
}
|
||||
}
|
||||
graph.addWithoutUnique(node);
|
||||
graph.addWithoutUniqueWithInputs(node);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
|
||||
compiler/ciReplay/TestSAServer.java 8029528 generic-all
|
||||
compiler/codecache/stress/OverloadCompileQueueTest.java 8166554 generic-all
|
||||
compiler/codegen/Test6896617.java 8193479 generic-all
|
||||
compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java 8140405 generic-all
|
||||
compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java 8158860 generic-all
|
||||
compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java 8163894 generic-all
|
||||
@ -50,6 +51,7 @@ compiler/startup/SmallCodeCacheStartup.java 8134286 generic-all
|
||||
compiler/tiered/LevelTransitionTest.java 8067651 generic-all
|
||||
compiler/types/correctness/CorrectnessTest.java 8066173 generic-all
|
||||
compiler/types/correctness/OffTest.java 8066173 generic-all
|
||||
compiler/c2/Test8007294.java 8192992 generic-all
|
||||
|
||||
# aot test intermittently failing in jprt 8175791
|
||||
compiler/aot/DeoptimizationTest.java 8175791 windows-all
|
||||
@ -77,7 +79,6 @@ runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all
|
||||
# This test is disabled since it will stress NMT and timeout during normal testing
|
||||
runtime/NMT/MallocStressTest.java 8166548 generic-all
|
||||
runtime/SharedArchiveFile/DefaultUseWithClient.java 8154204 generic-all
|
||||
runtime/AppCDS/UseAppCDS.java 8165603 windows-all
|
||||
|
||||
#############################################################################
|
||||
|
||||
|
||||
@ -27,7 +27,8 @@
|
||||
* @modules java.base/jdk.internal.misc:+open
|
||||
* @build sun.hotspot.WhiteBox
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions
|
||||
* -Xbootclasspath/a:. -XX:+WhiteBoxAPI
|
||||
* -Xbatch -XX:-TieredCompilation -XX:+AlwaysIncrementalInline
|
||||
* -XX:CompileCommand=compileonly,compiler.ciReplay.TestDumpReplay::*
|
||||
* compiler.ciReplay.TestDumpReplay
|
||||
|
||||
@ -89,7 +89,7 @@ public class NestedThreadsListHandleInErrorHandlingTest {
|
||||
// We should have a section of Threads class SMR info:
|
||||
Pattern.compile("Threads class SMR info:"),
|
||||
// We should have one nested ThreadsListHandle:
|
||||
Pattern.compile(".*, _smr_nested_thread_list_max=1"),
|
||||
Pattern.compile(".*, _nested_thread_list_max=1"),
|
||||
// The current thread (marked with '=>') in the threads list
|
||||
// should show a hazard ptr:
|
||||
Pattern.compile("=>.* JavaThread \"main\" .*_threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=1, _nested_threads_hazard_ptrs=0x.*"),
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
* attempting to use CDS archive. JVM should exit gracefully
|
||||
* when sharing mode is ON, and continue w/o sharing if sharing
|
||||
* mode is AUTO.
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @requires vm.cds
|
||||
* @requires vm.cds & !vm.graal.enabled
|
||||
* @summary Testing -Xbootclasspath/a support for CDS
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @requires vm.cds
|
||||
* @summary CDS (class data sharing) requires the same -XX:[+-]CompactStrings
|
||||
* setting between archive creation time and load time.
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* This is a negative test; using object alignment for loading that
|
||||
* is different from object alignment for creating a CDS file
|
||||
* should fail when loading.
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @bug 8025642
|
||||
* @modules java.base/jdk.internal.misc
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @requires vm.cds
|
||||
* @summary Testing CDS (class data sharing) using varying object alignment.
|
||||
* Using same object alignment for each dump/load pair
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/*
|
||||
* @test DefaultUseWithClient
|
||||
* @summary Test default behavior of sharing with -client
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
* Feature support: compressed oops/kptrs, 64-bit os, not on windows
|
||||
* @requires vm.cds
|
||||
* @requires (sun.arch.data.model != "32") & (os.family != "windows")
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @run main DumpSharedDictionary
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/*
|
||||
* @test NonBootLoaderClasses
|
||||
* @summary Test to ensure platform and app classes are not being archived
|
||||
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
||||
* @requires vm.cds
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user