8220049: Obsolete ThreadLocalHandshakes

Reviewed-by: dholmes, dcubed, mdoerr
This commit is contained in:
Robbin Ehn 2019-12-11 15:30:07 +01:00
parent f5929f55cc
commit 0df5be808d
28 changed files with 38 additions and 135 deletions
src
hotspot
jdk.aot/share/classes
jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat
jdk.tools.jaotc/src/jdk/tools/jaotc
jdk.internal.vm.compiler/share/classes
org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64
org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64
org.graalvm.compiler.hotspot.sparc.test/src/org/graalvm/compiler/hotspot/sparc/test
org.graalvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc
org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot

@ -71,8 +71,6 @@ define_pd_global(bool, CompactStrings, true);
// Clear short arrays bigger than one word in an arch-specific way
define_pd_global(intx, InitArrayShortSize, BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, true);
#if defined(COMPILER1) || defined(COMPILER2)
define_pd_global(intx, InlineSmallCode, 1000);
#endif

@ -70,8 +70,6 @@ define_pd_global(bool, CompactStrings, false);
define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, false);
#define ARCH_FLAGS(develop, \
product, \
diagnostic, \

@ -74,8 +74,6 @@ define_pd_global(bool, CompactStrings, true);
// 2x unrolled loop is shorter with more than 9 HeapWords.
define_pd_global(intx, InitArrayShortSize, 9*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, true);
// Platform dependent flag handling: flags only defined on this platform.
#define ARCH_FLAGS(develop, \
product, \

@ -76,8 +76,6 @@ define_pd_global(bool, CompactStrings, true);
// 8146801 (Short Array Allocation): No performance work done here yet.
define_pd_global(intx, InitArrayShortSize, 1*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, true);
#define ARCH_FLAGS(develop, \
product, \
diagnostic, \

@ -80,8 +80,6 @@ define_pd_global(bool, CompactStrings, true);
define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, true);
#define ARCH_FLAGS(develop, \
product, \
diagnostic, \

@ -89,8 +89,6 @@ define_pd_global(bool, PreserveFramePointer, false);
define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
define_pd_global(bool, ThreadLocalHandshakes, true);
#define ARCH_FLAGS(develop, \
product, \
diagnostic, \

@ -73,8 +73,6 @@ define_pd_global(bool, PreserveFramePointer, false);
// No performance work done here yet.
define_pd_global(bool, CompactStrings, false);
define_pd_global(bool, ThreadLocalHandshakes, true);
#define ARCH_FLAGS(develop, \
product, \
diagnostic, \

@ -32,14 +32,14 @@
void SafepointMechanism::pd_initialize() {
// No special code needed if we can use SIGTRAP
if (ThreadLocalHandshakes && USE_POLL_BIT_ONLY) {
if (USE_POLL_BIT_ONLY) {
default_initialize();
return;
}
// Allocate one protected page
char* map_address = (char*)MAP_FAILED;
const size_t map_size = ThreadLocalHandshakes ? 2 * os::vm_page_size() : os::vm_page_size();
const size_t map_size = 2 * os::vm_page_size();
const int prot = PROT_READ;
const int flags = MAP_PRIVATE | MAP_ANONYMOUS;
@ -99,13 +99,10 @@ void SafepointMechanism::pd_initialize() {
// Register polling page with NMT.
MemTracker::record_virtual_memory_reserve_and_commit(map_address, map_size, CALLER_PC, mtSafepoint);
// Use same page for ThreadLocalHandshakes without SIGTRAP
if (ThreadLocalHandshakes) {
set_uses_thread_local_poll();
os::make_polling_page_unreadable();
intptr_t bad_page_val = reinterpret_cast<intptr_t>(map_address),
good_page_val = bad_page_val + os::vm_page_size();
_poll_armed_value = reinterpret_cast<void*>(bad_page_val + poll_bit());
_poll_disarmed_value = reinterpret_cast<void*>(good_page_val);
}
// Use same page for thread local handshakes without SIGTRAP
os::make_polling_page_unreadable();
intptr_t bad_page_val = reinterpret_cast<intptr_t>(map_address),
good_page_val = bad_page_val + os::vm_page_size();
_poll_armed_value = reinterpret_cast<void*>(bad_page_val + poll_bit());
_poll_disarmed_value = reinterpret_cast<void*>(good_page_val);
}

@ -185,7 +185,6 @@ void AOTLib::verify_config() {
verify_flag(_config->_compactFields, CompactFields, "CompactFields");
verify_flag(_config->_enableContended, EnableContended, "EnableContended");
verify_flag(_config->_restrictContended, RestrictContended, "RestrictContended");
verify_flag(_config->_threadLocalHandshakes, ThreadLocalHandshakes, "ThreadLocalHandshakes");
if (!TieredCompilation && _config->_tieredAOT) {
handle_config_error("Shared file %s error: Expected to run with tiered compilation on", _name);

@ -92,7 +92,7 @@ typedef struct {
} AOTHeader;
typedef struct {
enum { CONFIG_SIZE = 8 * jintSize + 11 };
enum { CONFIG_SIZE = 8 * jintSize + 10 };
// 8 int values
int _config_size;
int _narrowOopShift;
@ -113,7 +113,6 @@ typedef struct {
bool _enableContended;
bool _restrictContended;
bool _omitAssertions;
bool _threadLocalHandshakes;
} AOTConfiguration;
class AOTLib : public CHeapObj<mtCode> {

@ -45,6 +45,7 @@
#include "runtime/atomic.hpp"
#include "runtime/handshake.hpp"
#include "runtime/prefetch.inline.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/thread.hpp"
#include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"
@ -454,7 +455,7 @@ bool ZMark::flush(bool at_safepoint) {
bool ZMark::try_flush(volatile size_t* nflush) {
// Only flush if handshakes are enabled
if (!ThreadLocalHandshakes) {
if (!SafepointMechanism::uses_thread_local_poll()) {
return false;
}

@ -4205,20 +4205,6 @@ jint Arguments::apply_ergo() {
}
#endif
#if defined(IA32)
// Only server compiler can optimize safepoints well enough.
if (!is_server_compilation_mode_vm()) {
FLAG_SET_ERGO_IF_DEFAULT(ThreadLocalHandshakes, false);
}
#endif
// ThreadLocalHandshakesConstraintFunc handles the constraints.
if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) || !SafepointMechanism::supports_thread_local_poll()) {
log_debug(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled.");
} else {
log_info(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled.");
}
return JNI_OK;
}

@ -36,6 +36,7 @@
#include "runtime/biasedLocking.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/handshake.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/task.hpp"
#include "runtime/threadSMR.hpp"
#include "runtime/vframe.hpp"
@ -665,8 +666,8 @@ BiasedLocking::Condition BiasedLocking::single_revoke_with_handshake(Handle obj,
// Caller should have instantiated a ResourceMark object before calling this method
void BiasedLocking::walk_stack_and_revoke(oop obj, JavaThread* biased_locker) {
assert(!SafepointSynchronize::is_at_safepoint() || !ThreadLocalHandshakes,
"if ThreadLocalHandshakes is enabled this should always be executed outside safepoints");
assert(!SafepointSynchronize::is_at_safepoint() || !SafepointMechanism::uses_thread_local_poll(),
"if SafepointMechanism::uses_thread_local_poll() is enabled this should always be executed outside safepoints");
assert(Thread::current() == biased_locker || Thread::current()->is_VM_thread(), "wrong thread");
markWord mark = obj->mark();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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
@ -130,13 +130,3 @@ JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) {
return JVMFlag::SUCCESS;
}
}
JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) {
if (value) {
if (!SafepointMechanism::supports_thread_local_poll()) {
JVMFlag::printError(verbose, "ThreadLocalHandshakes not yet supported on this platform\n");
return JVMFlag::VIOLATES_CONSTRAINT;
}
}
return JVMFlag::SUCCESS;
}

@ -44,7 +44,4 @@ JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose);
JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose);
JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose);
#endif // SHARE_RUNTIME_FLAGS_JVMFLAGCONSTRAINTSRUNTIME_HPP

@ -163,10 +163,6 @@ const size_t minimumSymbolTableSize = 1024;
develop(bool, CleanChunkPoolAsync, true, \
"Clean the chunk pool asynchronously") \
\
product_pd(bool, ThreadLocalHandshakes, \
"Use thread-local polls instead of global poll for safepoints.") \
constraint(ThreadLocalHandshakesConstraintFunc,AfterErgo) \
\
diagnostic(uint, HandshakeTimeout, 0, \
"If nonzero set a timeout in milliseconds for handshakes") \
\

@ -282,7 +282,7 @@ void HandshakeThreadsOperation::do_handshake(JavaThread* thread) {
}
void Handshake::execute(HandshakeClosure* thread_cl) {
if (ThreadLocalHandshakes) {
if (SafepointMechanism::uses_thread_local_poll()) {
HandshakeThreadsOperation cto(thread_cl);
VM_HandshakeAllThreads handshake(&cto);
VMThread::execute(&handshake);
@ -293,7 +293,7 @@ void Handshake::execute(HandshakeClosure* thread_cl) {
}
bool Handshake::execute(HandshakeClosure* thread_cl, JavaThread* target) {
if (ThreadLocalHandshakes) {
if (SafepointMechanism::uses_thread_local_poll()) {
HandshakeThreadsOperation cto(thread_cl);
VM_HandshakeOneThread handshake(&cto, target);
VMThread::execute(&handshake);

@ -881,7 +881,7 @@ void SafepointSynchronize::block(JavaThread *thread) {
void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
assert(thread->is_Java_thread(), "polling reference encountered by VM thread");
assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
if (!ThreadLocalHandshakes) {
if (!SafepointMechanism::uses_thread_local_poll()) {
assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
}

@ -31,13 +31,11 @@
#include "services/memTracker.hpp"
#include "utilities/globalDefinitions.hpp"
SafepointMechanism::PollingType SafepointMechanism::_polling_type = SafepointMechanism::_global_page_poll;
void* SafepointMechanism::_poll_armed_value;
void* SafepointMechanism::_poll_disarmed_value;
void SafepointMechanism::default_initialize() {
if (ThreadLocalHandshakes) {
set_uses_thread_local_poll();
if (uses_thread_local_poll()) {
// Poll bit values
intptr_t poll_armed_value = poll_bit();

@ -32,14 +32,8 @@
// This is the abstracted interface for the safepoint implementation
class SafepointMechanism : public AllStatic {
enum PollingType {
_global_page_poll,
_thread_local_poll
};
static PollingType _polling_type;
static void* _poll_armed_value;
static void* _poll_disarmed_value;
static void set_uses_thread_local_poll() { _polling_type = _thread_local_poll; }
static void* poll_armed_value() { return _poll_armed_value; }
static void* poll_disarmed_value() { return _poll_disarmed_value; }
@ -65,10 +59,8 @@ class SafepointMechanism : public AllStatic {
public:
static intptr_t poll_bit() { return _poll_bit; }
static bool uses_global_page_poll() { return _polling_type == _global_page_poll; }
static bool uses_thread_local_poll() { return _polling_type == _thread_local_poll; }
static bool supports_thread_local_poll() {
static bool uses_global_page_poll() { return !uses_thread_local_poll(); }
static bool uses_thread_local_poll() {
#ifdef THREAD_LOCAL_POLL
return true;
#else

@ -250,7 +250,7 @@ void NMethodSweeper::mark_active_nmethods() {
CodeBlobClosure* NMethodSweeper::prepare_mark_active_nmethods() {
#ifdef ASSERT
if (ThreadLocalHandshakes) {
if (SafepointMechanism::uses_thread_local_poll()) {
assert(Thread::current()->is_Code_cache_sweeper_thread(), "must be executed under CodeCache_lock and in sweeper thread");
assert_lock_strong(CodeCache_lock);
} else {
@ -317,7 +317,7 @@ CodeBlobClosure* NMethodSweeper::prepare_reset_hotness_counters() {
void NMethodSweeper::do_stack_scanning() {
assert(!CodeCache_lock->owned_by_self(), "just checking");
if (wait_for_stack_scanning()) {
if (ThreadLocalHandshakes) {
if (SafepointMechanism::uses_thread_local_poll()) {
CodeBlobClosure* code_cl;
{
MutexLocker ccl(CodeCache_lock, Mutex::_no_safepoint_check_flag);

@ -67,8 +67,6 @@ public final class BinaryContainer implements SymbolTable {
private final int codeEntryAlignment;
private final boolean threadLocalHandshakes;
/**
* Container holding code bits and any other related information.
*/
@ -294,8 +292,6 @@ public final class BinaryContainer implements SymbolTable {
this.codeEntryAlignment = graalHotSpotVMConfig.codeEntryAlignment;
this.threadLocalHandshakes = graalHotSpotVMConfig.threadLocalHandshakes;
// Section unique name is limited to 8 characters due to limitation on Windows.
// Name could be longer but only first 8 characters are stored on Windows.
@ -341,7 +337,6 @@ public final class BinaryContainer implements SymbolTable {
graalHotSpotVMConfig.enableContended,
graalHotSpotVMConfig.restrictContended,
graphBuilderConfig.omitAssertions(),
graalHotSpotVMConfig.threadLocalHandshakes
};
int[] intFlags = { graalHotSpotVMConfig.getOopEncoding().getShift(),
@ -454,10 +449,6 @@ public final class BinaryContainer implements SymbolTable {
return codeEntryAlignment;
}
public boolean getThreadLocalHandshakes() {
return threadLocalHandshakes;
}
/**
* Gets the global AOT symbol associated with the function name.
*

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2019, 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
@ -56,11 +56,8 @@ final class MarkProcessor {
break;
case POLL_FAR:
case POLL_RETURN_FAR:
if (binaryContainer.getThreadLocalHandshakes()) {
// skip relocation
break;
}
// fallthrough
// skip relocation
break;
case CARD_TABLE_ADDRESS:
case HEAP_TOP_ADDRESS:
case HEAP_END_ADDRESS:

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2019, 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
@ -81,11 +81,7 @@ public class AArch64HotSpotSafepointOp extends AArch64LIRInstruction {
}
public static void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm, GraalHotSpotVMConfig config, boolean onReturn, Register thread, Register scratch, LIRFrameState state) {
if (config.threadLocalHandshakes) {
emitThreadLocalPoll(crb, masm, config, onReturn, thread, scratch, state);
} else {
emitGlobalPoll(crb, masm, config, onReturn, scratch, state);
}
emitThreadLocalPoll(crb, masm, config, onReturn, thread, scratch, state);
}
private static void emitGlobalPoll(CompilationResultBuilder crb, AArch64MacroAssembler masm, GraalHotSpotVMConfig config, boolean onReturn, Register scratch, LIRFrameState state) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@ -67,12 +67,7 @@ public final class AMD64HotSpotSafepointOp extends AMD64LIRInstruction {
this.state = state;
this.config = config;
this.thread = thread;
if (config.threadLocalHandshakes || isPollingPageFar(config) || ImmutableCode.getValue(tool.getOptions())) {
temp = tool.getLIRGeneratorTool().newVariable(LIRKind.value(tool.getLIRGeneratorTool().target().arch.getWordKind()));
} else {
// Don't waste a register if it's unneeded
temp = Value.ILLEGAL;
}
temp = tool.getLIRGeneratorTool().newVariable(LIRKind.value(tool.getLIRGeneratorTool().target().arch.getWordKind()));
}
@Override
@ -81,11 +76,7 @@ public final class AMD64HotSpotSafepointOp extends AMD64LIRInstruction {
}
public static void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm, GraalHotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register thread, Register scratch) {
if (config.threadLocalHandshakes) {
emitThreadLocalPoll(crb, asm, config, atReturn, state, thread, scratch);
} else {
emitGlobalPoll(crb, asm, config, atReturn, state, scratch);
}
emitThreadLocalPoll(crb, asm, config, atReturn, state, thread, scratch);
}
/**

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2019, 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
@ -47,7 +47,7 @@ public class SPARCAllocatorTest extends AllocatorTest {
@Test
public void test1() {
testAllocation("test1snippet", config.threadLocalHandshakes ? 1 : 2, 0, 0);
testAllocation("test1snippet", 1 , 0, 0);
}
public static long test1snippet(long x) {
@ -56,7 +56,7 @@ public class SPARCAllocatorTest extends AllocatorTest {
@Test
public void test2() {
testAllocation("test2snippet", config.threadLocalHandshakes ? 1 : 2, 0, 0);
testAllocation("test2snippet", 1, 0, 0);
}
public static long test2snippet(long x) {
@ -65,7 +65,7 @@ public class SPARCAllocatorTest extends AllocatorTest {
@Test
public void test3() {
testAllocation("test3snippet", config.threadLocalHandshakes ? 3 : 4, 0, 0);
testAllocation("test3snippet", 3, 0, 0);
}
public static long test3snippet(long x) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@ -75,11 +75,7 @@ public class SPARCHotSpotSafepointOp extends SPARCLIRInstruction {
public static void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm, GraalHotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register thread,
Value safepointPollAddress) {
if (config.threadLocalHandshakes) {
emitThreadLocalPoll(crb, masm, config, atReturn, state, thread);
} else {
emitGlobalPoll(crb, masm, config, atReturn, state, asRegister(safepointPollAddress));
}
emitThreadLocalPoll(crb, masm, config, atReturn, state, thread);
}
/**
@ -117,19 +113,10 @@ public class SPARCHotSpotSafepointOp extends SPARCLIRInstruction {
}
static AllocatableValue getSafepointAddressValue(SPARCHotSpotLIRGenerator gen) {
if (gen.config.threadLocalHandshakes) {
return Value.ILLEGAL;
} else {
return gen.newVariable(LIRKind.value(gen.target().arch.getWordKind()));
}
return Value.ILLEGAL;
}
static void emitPrologue(SPARCHotSpotNodeLIRBuilder lir, SPARCHotSpotLIRGenerator gen) {
if (!gen.config.threadLocalHandshakes) {
AllocatableValue var = gen.getSafepointAddressValue();
lir.append(new SPARCHotSpotSafepointOp.SPARCLoadSafepointPollAddress(var, gen.config));
gen.append(((HotSpotDebugInfoBuilder) lir.getDebugInfoBuilder()).lockStack());
}
}
public static class SPARCLoadSafepointPollAddress extends SPARCLIRInstruction {

@ -96,7 +96,6 @@ public class GraalHotSpotVMConfig extends GraalHotSpotVMConfigBase {
public final boolean useAESCTRIntrinsics = getFlag("UseAESCTRIntrinsics", Boolean.class, false);
public final boolean useCRC32Intrinsics = getFlag("UseCRC32Intrinsics", Boolean.class);
public final boolean useCRC32CIntrinsics = versioned.useCRC32CIntrinsics;
public final boolean threadLocalHandshakes = getFlag("ThreadLocalHandshakes", Boolean.class, false);
private final boolean useMultiplyToLenIntrinsic = getFlag("UseMultiplyToLenIntrinsic", Boolean.class);
private final boolean useSHA1Intrinsics = getFlag("UseSHA1Intrinsics", Boolean.class);