Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8280844: Epoch shift synchronization point for Compiler threads is inadequate #8724

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions make/src/classes/build/tools/jfr/GenerateJfrFiles.java
Expand Up @@ -739,7 +739,6 @@ private static void printJfrEventClassesHpp(Metadata metadata, File outputFile)
out.write("#include \"utilities/ticks.hpp\"");
out.write("#if INCLUDE_JFR");
out.write("#include \"jfr/recorder/service/jfrEvent.hpp\"");
out.write("#include \"jfr/support/jfrEpochSynchronization.hpp\"");
out.write("/*");
out.write(" * Each event class has an assert member function verify() which is invoked");
out.write(" * just before the engine writes the event and its fields to the data stream.");
Expand Down Expand Up @@ -869,10 +868,6 @@ private static void printWriteData(Printer out, TypeElement type) {
if (type.isEvent && type.internal) {
out.write(" JfrEventSetting::unhide_internal_types();");
}
if (("_thread_in_native").equals(type.commitState)) {
out.write(" // explicit epoch synchronization check");
out.write(" JfrEpochSynchronization sync;");
}
for (FieldElement field : type.fields) {
if (field.struct) {
out.write(" _" + field.name + ".writeData(w);");
Expand Down
16 changes: 14 additions & 2 deletions src/hotspot/share/compiler/compilerEvent.cpp
Expand Up @@ -27,7 +27,9 @@
#include "jfr/jfr.hpp"
#include "jfr/jfrEvents.hpp"
#include "jfr/metadata/jfrSerializer.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/semaphore.inline.hpp"
#include "runtime/thread.inline.hpp"
#include "utilities/growableArray.hpp"

// Synchronizes access to phases_names.
Expand Down Expand Up @@ -114,6 +116,16 @@ int CompilerEvent::PhaseEvent::get_phase_id(const char* phase_name, bool may_exi
return index;
}

// As part of event commit, a Method* is tagged as a function of an epoch.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This transition is not necessary for JVMCI compiler threads: #12787

// Epochs evolve during safepoints. To ensure the event is tagged in the correct epoch,
// that is, to avoid a race, the thread will participate in the safepoint protocol
// by transitioning from _thread_in_native to _thread_in_vm.
template <typename EventType>
static inline void commit(EventType& event) {
ThreadInVMfromNative transition(JavaThread::current());
event.commit();
}

void CompilerEvent::CompilationEvent::post(EventCompilation& event, int compile_id, CompilerType compiler_type, Method* method, int compile_level, bool success, bool is_osr, int code_size, int inlined_bytecodes) {
event.set_compileId(compile_id);
event.set_compiler(compiler_type);
Expand All @@ -123,7 +135,7 @@ void CompilerEvent::CompilationEvent::post(EventCompilation& event, int compile_
event.set_isOsr(is_osr);
event.set_codeSize(code_size);
event.set_inlinedBytes(inlined_bytecodes);
event.commit();
commit(event);
}

void CompilerEvent::CompilationFailureEvent::post(EventCompilationFailure& event, int compile_id, const char* reason) {
Expand All @@ -147,7 +159,7 @@ void CompilerEvent::InlineEvent::post(EventCompilerInlining& event, int compile_
event.set_succeeded(success);
event.set_message(msg);
event.set_bci(bci);
event.commit();
commit(event);
}

void CompilerEvent::InlineEvent::post(EventCompilerInlining& event, int compile_id, Method* caller, Method* callee, bool success, const char* msg, int bci) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jfr/metadata/metadata.xml
Expand Up @@ -558,7 +558,7 @@
<Field type="ulong" contentType="bytes" name="used" label="Used" />
</Event>

<Event name="Compilation" category="Java Virtual Machine, Compiler" label="Compilation" thread="true" commitState="_thread_in_native">
<Event name="Compilation" category="Java Virtual Machine, Compiler" label="Compilation" thread="true">
<Field type="uint" name="compileId" label="Compilation Identifier" relation="CompileId" />
<Field type="CompilerType" name="compiler" label="Compiler" />
<Field type="Method" name="method" label="Method" />
Expand Down Expand Up @@ -586,7 +586,7 @@
<Field type="string" name="descriptor" label="Method Descriptor" />
</Type>

<Event name="CompilerInlining" category="Java Virtual Machine, Compiler, Optimization" label="Method Inlining" thread="true" startTime="false" commitState="_thread_in_native">
<Event name="CompilerInlining" category="Java Virtual Machine, Compiler, Optimization" label="Method Inlining" thread="true" startTime="false">
<Field type="uint" name="compileId" label="Compilation Identifier" relation="CompileId" />
<Field type="Method" name="caller" label="Caller Method" />
<Field type="CalleeMethod" name="callee" struct="true" label="Callee Method" />
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/jfr/metadata/metadata.xsd
Expand Up @@ -72,7 +72,6 @@
<xs:attribute name="period" type="periodType" use="optional" />
<xs:attribute name="cutoff" type="xs:boolean" use="optional" />
<xs:attribute name="throttle" type="xs:boolean" use="optional" />
<xs:attribute name="commitState" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="Type">
Expand Down
39 changes: 0 additions & 39 deletions src/hotspot/share/jfr/support/jfrEpochSynchronization.cpp

This file was deleted.

39 changes: 0 additions & 39 deletions src/hotspot/share/jfr/support/jfrEpochSynchronization.hpp

This file was deleted.