Skip to content
Permalink
Browse files
8280844: Epoch shift synchronization point for Compiler threads is in…
…adequate

Reviewed-by: egahlin
  • Loading branch information
Markus Grönlund committed May 18, 2022
1 parent 44b243a commit d936c3024acf428df6d1fb3064a1d8aa5038d277
Showing 6 changed files with 16 additions and 88 deletions.
@@ -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.");
@@ -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);");
@@ -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.
@@ -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.
// 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);
@@ -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) {
@@ -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) {
@@ -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" />
@@ -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" />
@@ -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">

This file was deleted.

This file was deleted.

1 comment on commit d936c30

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on d936c30 May 18, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.