This commit is contained in:
Jesper Wilhelmsson 2021-01-15 03:10:55 +00:00
commit d701babb06
11 changed files with 79 additions and 76 deletions

View file

@ -47,6 +47,8 @@ bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state(); ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state();
if ((state->enqueue_barriers_count() + if ((state->enqueue_barriers_count() +
state->load_reference_barriers_count()) > 0) { state->load_reference_barriers_count()) > 0) {
assert(C->post_loop_opts_phase(), "no loop opts allowed");
C->reset_post_loop_opts_phase(); // ... but we know what we are doing
bool attempt_more_loopopts = ShenandoahLoopOptsAfterExpansion; bool attempt_more_loopopts = ShenandoahLoopOptsAfterExpansion;
C->clear_major_progress(); C->clear_major_progress();
PhaseIdealLoop::optimize(igvn, LoopOptsShenandoahExpand); PhaseIdealLoop::optimize(igvn, LoopOptsShenandoahExpand);
@ -59,7 +61,10 @@ bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
return false; return false;
} }
C->clear_major_progress(); C->clear_major_progress();
C->process_for_post_loop_opts_igvn(igvn);
} }
C->set_post_loop_opts_phase(); // now for real!
} }
return true; return true;
} }

View file

@ -1831,16 +1831,21 @@ void Compile::remove_from_post_loop_opts_igvn(Node* n) {
} }
void Compile::process_for_post_loop_opts_igvn(PhaseIterGVN& igvn) { void Compile::process_for_post_loop_opts_igvn(PhaseIterGVN& igvn) {
if (_for_post_loop_igvn.length() == 0) { // Verify that all previous optimizations produced a valid graph
return; // no work to do // at least to this point, even if no loop optimizations were done.
PhaseIdealLoop::verify(igvn);
C->set_post_loop_opts_phase(); // no more loop opts allowed
if (_for_post_loop_igvn.length() > 0) {
while (_for_post_loop_igvn.length() > 0) {
Node* n = _for_post_loop_igvn.pop();
n->remove_flag(Node::NodeFlags::Flag_for_post_loop_opts_igvn);
igvn._worklist.push(n);
}
igvn.optimize();
assert(_for_post_loop_igvn.length() == 0, "no more delayed nodes allowed");
} }
while (_for_post_loop_igvn.length() > 0) {
Node* n = _for_post_loop_igvn.pop();
n->remove_flag(Node::NodeFlags::Flag_for_post_loop_opts_igvn);
igvn._worklist.push(n);
}
igvn.optimize();
assert(_for_post_loop_igvn.length() == 0, "no more delayed nodes allowed");
} }
// StringOpts and late inlining of string methods // StringOpts and late inlining of string methods
@ -2249,7 +2254,6 @@ void Compile::Optimize() {
} }
if (!failing()) { if (!failing()) {
// Verify that last round of loop opts produced a valid graph // Verify that last round of loop opts produced a valid graph
TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
PhaseIdealLoop::verify(igvn); PhaseIdealLoop::verify(igvn);
} }
} }
@ -2284,15 +2288,9 @@ void Compile::Optimize() {
if (failing()) return; if (failing()) return;
// Ensure that major progress is now clear C->clear_major_progress(); // ensure that major progress is now clear
C->clear_major_progress();
{ process_for_post_loop_opts_igvn(igvn);
// Verify that all previous optimizations produced a valid graph
// at least to this point, even if no loop optimizations were done.
TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
PhaseIdealLoop::verify(igvn);
}
#ifdef ASSERT #ifdef ASSERT
bs->verify_gc_barriers(this, BarrierSetC2::BeforeMacroExpand); bs->verify_gc_barriers(this, BarrierSetC2::BeforeMacroExpand);
@ -2317,10 +2315,6 @@ void Compile::Optimize() {
print_method(PHASE_BARRIER_EXPANSION, 2); print_method(PHASE_BARRIER_EXPANSION, 2);
} }
C->set_post_loop_opts_phase(); // no more loop opts allowed
process_for_post_loop_opts_igvn(igvn);
if (C->max_vector_size() > 0) { if (C->max_vector_size() > 0) {
C->optimize_logic_cones(igvn); C->optimize_logic_cones(igvn);
igvn.optimize(); igvn.optimize();

View file

@ -690,8 +690,9 @@ class Compile : public Phase {
_predicate_opaqs.append(n); _predicate_opaqs.append(n);
} }
bool post_loop_opts_phase() { return _post_loop_opts_phase; } bool post_loop_opts_phase() { return _post_loop_opts_phase; }
void set_post_loop_opts_phase() { _post_loop_opts_phase = true; } void set_post_loop_opts_phase() { _post_loop_opts_phase = true; }
void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }
void record_for_post_loop_opts_igvn(Node* n); void record_for_post_loop_opts_igvn(Node* n);
void remove_from_post_loop_opts_igvn(Node* n); void remove_from_post_loop_opts_igvn(Node* n);

View file

@ -1132,6 +1132,7 @@ public:
static void verify(PhaseIterGVN& igvn) { static void verify(PhaseIterGVN& igvn) {
#ifdef ASSERT #ifdef ASSERT
ResourceMark rm; ResourceMark rm;
Compile::TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
PhaseIdealLoop v(igvn); PhaseIdealLoop v(igvn);
#endif #endif
} }

View file

@ -103,6 +103,9 @@ public final class RecordingFile implements Closeable {
isLastEventInChunk = false; isLastEventInChunk = false;
RecordedEvent event = nextEvent; RecordedEvent event = nextEvent;
nextEvent = chunkParser.readEvent(); nextEvent = chunkParser.readEvent();
while (nextEvent == ChunkParser.FLUSH_MARKER) {
nextEvent = chunkParser.readEvent();
}
if (nextEvent == null) { if (nextEvent == null) {
isLastEventInChunk = true; isLastEventInChunk = true;
findNext(); findNext();
@ -251,6 +254,9 @@ public final class RecordingFile implements Closeable {
return; return;
} }
nextEvent = chunkParser.readEvent(); nextEvent = chunkParser.readEvent();
while (nextEvent == ChunkParser.FLUSH_MARKER) {
nextEvent = chunkParser.readEvent();
}
} }
} }

View file

@ -233,6 +233,14 @@ public abstract class AbstractEventStream implements EventStream {
return flushOperation; return flushOperation;
} }
final protected void onFlush() {
Runnable r = getFlushOperation();
if (r != null) {
r.run();
}
}
private void startInternal(long startNanos) { private void startInternal(long startNanos) {
synchronized (streamConfiguration) { synchronized (streamConfiguration) {
if (streamConfiguration.started) { if (streamConfiguration.started) {
@ -290,7 +298,7 @@ public abstract class AbstractEventStream implements EventStream {
streamConfiguration.addMetadataAction(action); streamConfiguration.addMetadataAction(action);
} }
protected final void emitMetadataEvent(ChunkParser parser) { protected final void onMetadata(ChunkParser parser) {
if (parser.hasStaleMetadata()) { if (parser.hasStaleMetadata()) {
if (dispatcher.hasMetadataHandler()) { if (dispatcher.hasMetadataHandler()) {
List<EventType> ce = parser.getEventTypes(); List<EventType> ce = parser.getEventTypes();

View file

@ -91,6 +91,7 @@ public final class ChunkParser {
return (mask & flags) != 0; return (mask & flags) != 0;
} }
} }
public final static RecordedEvent FLUSH_MARKER = JdkJfrConsumer.instance().newRecordedEvent(null, null, 0L, 0L);
private static final long CONSTANT_POOL_TYPE_ID = 1; private static final long CONSTANT_POOL_TYPE_ID = 1;
private static final String CHUNKHEADER = "jdk.types.ChunkHeader"; private static final String CHUNKHEADER = "jdk.types.ChunkHeader";
@ -104,7 +105,6 @@ public final class ChunkParser {
private LongMap<Parser> parsers; private LongMap<Parser> parsers;
private boolean chunkFinished; private boolean chunkFinished;
private Runnable flushOperation;
private ParserConfiguration configuration; private ParserConfiguration configuration;
private volatile boolean closed; private volatile boolean closed;
private MetadataDescriptor previousMetadata; private MetadataDescriptor previousMetadata;
@ -194,6 +194,9 @@ public final class ChunkParser {
RecordedEvent readStreamingEvent() throws IOException { RecordedEvent readStreamingEvent() throws IOException {
long absoluteChunkEnd = chunkHeader.getEnd(); long absoluteChunkEnd = chunkHeader.getEnd();
RecordedEvent event = readEvent(); RecordedEvent event = readEvent();
if (event == ChunkParser.FLUSH_MARKER) {
return null;
}
if (event != null) { if (event != null) {
return event; return event;
} }
@ -253,8 +256,9 @@ public final class ChunkParser {
// Not accepted by filter // Not accepted by filter
} else { } else {
if (typeId == 1) { // checkpoint event if (typeId == 1) { // checkpoint event
if (flushOperation != null) { if (CheckPointType.FLUSH.is(parseCheckpointType())) {
parseCheckpoint(); input.position(pos + size);
return FLUSH_MARKER;
} }
} else { } else {
if (typeId != 0) { // Not metadata event if (typeId != 0) { // Not metadata event
@ -267,16 +271,11 @@ public final class ChunkParser {
return null; return null;
} }
private void parseCheckpoint() throws IOException { private byte parseCheckpointType() throws IOException {
// Content has been parsed previously. This
// is to trigger flush
input.readLong(); // timestamp input.readLong(); // timestamp
input.readLong(); // duration input.readLong(); // duration
input.readLong(); // delta input.readLong(); // delta
byte typeFlags = input.readByte(); return input.readByte();
if (CheckPointType.FLUSH.is(typeFlags)) {
flushOperation.run();
}
} }
private boolean awaitUpdatedHeader(long absoluteChunkEnd, long filterEnd) throws IOException { private boolean awaitUpdatedHeader(long absoluteChunkEnd, long filterEnd) throws IOException {
@ -451,10 +450,6 @@ public final class ChunkParser {
return chunkFinished; return chunkFinished;
} }
public void setFlushOperation(Runnable flushOperation) {
this.flushOperation = flushOperation;
}
public long getChunkDuration() { public long getChunkDuration() {
return chunkHeader.getDurationNanos(); return chunkHeader.getDurationNanos();
} }

View file

@ -38,8 +38,6 @@ import jdk.jfr.internal.consumer.ChunkParser.ParserConfiguration;
final class Dispatcher { final class Dispatcher {
public final static RecordedEvent FLUSH_MARKER = JdkJfrConsumer.instance().newRecordedEvent(null, null, 0L, 0L);
final static class EventDispatcher { final static class EventDispatcher {
private final static EventDispatcher[] NO_DISPATCHERS = new EventDispatcher[0]; private final static EventDispatcher[] NO_DISPATCHERS = new EventDispatcher[0];

View file

@ -143,7 +143,7 @@ public class EventDirectoryStream extends AbstractEventStream {
long filterEnd = disp.endTime != null ? disp.endNanos : Long.MAX_VALUE; long filterEnd = disp.endTime != null ? disp.endNanos : Long.MAX_VALUE;
while (!isClosed()) { while (!isClosed()) {
emitMetadataEvent(currentParser); onMetadata(currentParser);
while (!isClosed() && !currentParser.isChunkFinished()) { while (!isClosed() && !currentParser.isChunkFinished()) {
disp = dispatcher(); disp = dispatcher();
if (disp != lastDisp) { if (disp != lastDisp) {
@ -151,7 +151,6 @@ public class EventDirectoryStream extends AbstractEventStream {
pc.filterStart = filterStart; pc.filterStart = filterStart;
pc.filterEnd = filterEnd; pc.filterEnd = filterEnd;
currentParser.updateConfiguration(pc, true); currentParser.updateConfiguration(pc, true);
currentParser.setFlushOperation(getFlushOperation());
lastDisp = disp; lastDisp = disp;
} }
if (disp.parserConfiguration.isOrdered()) { if (disp.parserConfiguration.isOrdered()) {
@ -221,9 +220,10 @@ public class EventDirectoryStream extends AbstractEventStream {
} }
sortedCache[index++] = e; sortedCache[index++] = e;
} }
emitMetadataEvent(currentParser); onMetadata(currentParser);
// no events found // no events found
if (index == 0 && currentParser.isChunkFinished()) { if (index == 0 && currentParser.isChunkFinished()) {
onFlush();
return; return;
} }
// at least 2 events, sort them // at least 2 events, sort them
@ -233,6 +233,7 @@ public class EventDirectoryStream extends AbstractEventStream {
for (int i = 0; i < index; i++) { for (int i = 0; i < index; i++) {
c.dispatch(sortedCache[i]); c.dispatch(sortedCache[i]);
} }
onFlush();
return; return;
} }
@ -240,11 +241,11 @@ public class EventDirectoryStream extends AbstractEventStream {
while (true) { while (true) {
RecordedEvent e = currentParser.readStreamingEvent(); RecordedEvent e = currentParser.readStreamingEvent();
if (e == null) { if (e == null) {
emitMetadataEvent(currentParser); onFlush();
return true; return true;
} else {
c.dispatch(e);
} }
onMetadata(currentParser);
c.dispatch(e);
} }
} }

View file

@ -28,6 +28,7 @@ package jdk.jfr.internal.consumer;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.security.AccessControlContext; import java.security.AccessControlContext;
import java.time.Duration;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@ -87,7 +88,7 @@ public final class EventFileStream extends AbstractEventStream {
currentParser = new ChunkParser(input, disp.parserConfiguration); currentParser = new ChunkParser(input, disp.parserConfiguration);
while (!isClosed()) { while (!isClosed()) {
emitMetadataEvent(currentParser); onMetadata(currentParser);
if (currentParser.getStartNanos() > end) { if (currentParser.getStartNanos() > end) {
close(); close();
return; return;
@ -96,7 +97,6 @@ public final class EventFileStream extends AbstractEventStream {
disp.parserConfiguration.filterStart = start; disp.parserConfiguration.filterStart = start;
disp.parserConfiguration.filterEnd = end; disp.parserConfiguration.filterEnd = end;
currentParser.updateConfiguration(disp.parserConfiguration, true); currentParser.updateConfiguration(disp.parserConfiguration, true);
currentParser.setFlushOperation(getFlushOperation());
if (disp.parserConfiguration.isOrdered()) { if (disp.parserConfiguration.isOrdered()) {
processOrdered(disp); processOrdered(disp);
} else { } else {
@ -116,46 +116,42 @@ public final class EventFileStream extends AbstractEventStream {
} }
RecordedEvent event; RecordedEvent event;
int index = 0; int index = 0;
while (true) { while (!currentParser.isChunkFinished()) {
event = currentParser.readEvent(); while ((event = currentParser.readStreamingEvent()) != null) {
if (event == Dispatcher.FLUSH_MARKER) { if (index == cacheSorted.length) {
emitMetadataEvent(currentParser); RecordedEvent[] tmp = cacheSorted;
dispatchOrdered(c, index); cacheSorted = new RecordedEvent[2 * tmp.length];
index = 0; System.arraycopy(tmp, 0, cacheSorted, 0, tmp.length);
continue; }
cacheSorted[index++] = event;
} }
dispatchOrdered(c, index);
if (event == null) { index = 0;
emitMetadataEvent(currentParser);
dispatchOrdered(c, index);
return;
}
if (index == cacheSorted.length) {
RecordedEvent[] tmp = cacheSorted;
cacheSorted = new RecordedEvent[2 * tmp.length];
System.arraycopy(tmp, 0, cacheSorted, 0, tmp.length);
}
cacheSorted[index++] = event;
} }
} }
private void dispatchOrdered(Dispatcher c, int index) { private void dispatchOrdered(Dispatcher c, int index) {
onMetadata(currentParser);
Arrays.sort(cacheSorted, 0, index, EVENT_COMPARATOR); Arrays.sort(cacheSorted, 0, index, EVENT_COMPARATOR);
for (int i = 0; i < index; i++) { for (int i = 0; i < index; i++) {
c.dispatch(cacheSorted[i]); c.dispatch(cacheSorted[i]);
} }
onFlush();
} }
private void processUnordered(Dispatcher c) throws IOException { private void processUnordered(Dispatcher c) throws IOException {
onMetadata(currentParser);
while (!isClosed()) { while (!isClosed()) {
RecordedEvent event = currentParser.readEvent(); RecordedEvent event = currentParser.readStreamingEvent();
if (event == null) { if (event == null) {
emitMetadataEvent(currentParser); onFlush();
return; if (currentParser.isChunkFinished()) {
} return;
if (event != Dispatcher.FLUSH_MARKER) { }
c.dispatch(event); continue;
} }
onMetadata(currentParser);
c.dispatch(event);
} }
} }
} }

View file

@ -64,8 +64,6 @@ compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java 8183263 generic-x64
compiler/c2/Test8004741.java 8235801 generic-all compiler/c2/Test8004741.java 8235801 generic-all
compiler/loopstripmining/BackedgeNodeWithOutOfLoopControl.java 8255120 generic-all
############################################################################# #############################################################################
# :hotspot_gc # :hotspot_gc