Skip to content

Commit d936c30

Browse files
author
Markus Grönlund
committed
8280844: Epoch shift synchronization point for Compiler threads is inadequate
Reviewed-by: egahlin
1 parent 44b243a commit d936c30

File tree

6 files changed

+16
-88
lines changed

6 files changed

+16
-88
lines changed

make/src/classes/build/tools/jfr/GenerateJfrFiles.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ private static void printJfrEventClassesHpp(Metadata metadata, File outputFile)
739739
out.write("#include \"utilities/ticks.hpp\"");
740740
out.write("#if INCLUDE_JFR");
741741
out.write("#include \"jfr/recorder/service/jfrEvent.hpp\"");
742-
out.write("#include \"jfr/support/jfrEpochSynchronization.hpp\"");
743742
out.write("/*");
744743
out.write(" * Each event class has an assert member function verify() which is invoked");
745744
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) {
869868
if (type.isEvent && type.internal) {
870869
out.write(" JfrEventSetting::unhide_internal_types();");
871870
}
872-
if (("_thread_in_native").equals(type.commitState)) {
873-
out.write(" // explicit epoch synchronization check");
874-
out.write(" JfrEpochSynchronization sync;");
875-
}
876871
for (FieldElement field : type.fields) {
877872
if (field.struct) {
878873
out.write(" _" + field.name + ".writeData(w);");

src/hotspot/share/compiler/compilerEvent.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#include "jfr/jfr.hpp"
2828
#include "jfr/jfrEvents.hpp"
2929
#include "jfr/metadata/jfrSerializer.hpp"
30+
#include "runtime/interfaceSupport.inline.hpp"
3031
#include "runtime/semaphore.inline.hpp"
32+
#include "runtime/thread.inline.hpp"
3133
#include "utilities/growableArray.hpp"
3234

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

119+
// As part of event commit, a Method* is tagged as a function of an epoch.
120+
// Epochs evolve during safepoints. To ensure the event is tagged in the correct epoch,
121+
// that is, to avoid a race, the thread will participate in the safepoint protocol
122+
// by transitioning from _thread_in_native to _thread_in_vm.
123+
template <typename EventType>
124+
static inline void commit(EventType& event) {
125+
ThreadInVMfromNative transition(JavaThread::current());
126+
event.commit();
127+
}
128+
117129
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) {
118130
event.set_compileId(compile_id);
119131
event.set_compiler(compiler_type);
@@ -123,7 +135,7 @@ void CompilerEvent::CompilationEvent::post(EventCompilation& event, int compile_
123135
event.set_isOsr(is_osr);
124136
event.set_codeSize(code_size);
125137
event.set_inlinedBytes(inlined_bytecodes);
126-
event.commit();
138+
commit(event);
127139
}
128140

129141
void CompilerEvent::CompilationFailureEvent::post(EventCompilationFailure& event, int compile_id, const char* reason) {
@@ -147,7 +159,7 @@ void CompilerEvent::InlineEvent::post(EventCompilerInlining& event, int compile_
147159
event.set_succeeded(success);
148160
event.set_message(msg);
149161
event.set_bci(bci);
150-
event.commit();
162+
commit(event);
151163
}
152164

153165
void CompilerEvent::InlineEvent::post(EventCompilerInlining& event, int compile_id, Method* caller, Method* callee, bool success, const char* msg, int bci) {

src/hotspot/share/jfr/metadata/metadata.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@
558558
<Field type="ulong" contentType="bytes" name="used" label="Used" />
559559
</Event>
560560

561-
<Event name="Compilation" category="Java Virtual Machine, Compiler" label="Compilation" thread="true" commitState="_thread_in_native">
561+
<Event name="Compilation" category="Java Virtual Machine, Compiler" label="Compilation" thread="true">
562562
<Field type="uint" name="compileId" label="Compilation Identifier" relation="CompileId" />
563563
<Field type="CompilerType" name="compiler" label="Compiler" />
564564
<Field type="Method" name="method" label="Method" />
@@ -586,7 +586,7 @@
586586
<Field type="string" name="descriptor" label="Method Descriptor" />
587587
</Type>
588588

589-
<Event name="CompilerInlining" category="Java Virtual Machine, Compiler, Optimization" label="Method Inlining" thread="true" startTime="false" commitState="_thread_in_native">
589+
<Event name="CompilerInlining" category="Java Virtual Machine, Compiler, Optimization" label="Method Inlining" thread="true" startTime="false">
590590
<Field type="uint" name="compileId" label="Compilation Identifier" relation="CompileId" />
591591
<Field type="Method" name="caller" label="Caller Method" />
592592
<Field type="CalleeMethod" name="callee" struct="true" label="Callee Method" />

src/hotspot/share/jfr/metadata/metadata.xsd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
<xs:attribute name="period" type="periodType" use="optional" />
7373
<xs:attribute name="cutoff" type="xs:boolean" use="optional" />
7474
<xs:attribute name="throttle" type="xs:boolean" use="optional" />
75-
<xs:attribute name="commitState" type="xs:string" use="optional" />
7675
</xs:complexType>
7776
</xs:element>
7877
<xs:element maxOccurs="unbounded" name="Type">

src/hotspot/share/jfr/support/jfrEpochSynchronization.cpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/hotspot/share/jfr/support/jfrEpochSynchronization.hpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)