Skip to content

Commit dd0bf5e

Browse files
committed
Slightly optimize the footprint of coverage instrumentation nodes
1 parent 0a32b61 commit dd0bf5e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/truffleruby/stdlib/CoverageManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,22 @@ public synchronized void enable() {
8282
.build(),
8383
eventContext -> new ExecutionEventNode() {
8484

85-
@CompilationFinal private boolean configured;
86-
@CompilationFinal private int lineNumber;
85+
@CompilationFinal private int lineNumber = -2;
8786
@CompilationFinal private AtomicLongArray counters;
8887

8988
@Override
9089
protected void onEnter(VirtualFrame frame) {
91-
if (!configured) {
90+
if (lineNumber == -2) { // not yet initialized
9291
CompilerDirectives.transferToInterpreterAndInvalidate();
9392
final SourceSection sourceSection = eventContext.getInstrumentedSourceSection();
9493

9594
if (getLineHasCode(sourceSection.getSource(), sourceSection.getStartLine())) {
9695
lineNumber = lineToIndex(sourceSection.getStartLine());
9796
counters = getCounters(sourceSection.getSource());
97+
} else {
98+
lineNumber = -1;
9899
}
99-
100-
configured = true;
100+
assert lineNumber != -2;
101101
}
102102

103103
if (counters != null) {

0 commit comments

Comments
 (0)