Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ http_archive(
"//third_party:jacoco-make-probe-inserter-subclassable.patch",
"//third_party:jacoco-ignore-offline-instrumentation.patch",
],
sha256 = "5c72dea2d13eef33a4d972d157186fc12d85149bc042186953efe1be50c220ee",
strip_prefix = "jacoco-0.8.10",
url = "https://github.com/jacoco/jacoco/archive/refs/tags/v0.8.10.tar.gz",
sha256 = "764d75713a41473241b2bb88a69f813f786c87c8a6a5e6f7372b819f70e90bd4",
strip_prefix = "jacoco-0.8.14",
url = "https://github.com/jacoco/jacoco/archive/refs/tags/v0.8.14.tar.gz",
)

http_archive(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ class EdgeCoverageInstrumentor(
maxLocals: Int,
) {
val newMaxStack = max(maxStack + strategy.instrumentControlFlowEdgeStackSize, strategy.loadLocalVariableStackSize)
val newMaxLocals = maxLocals + if (strategy.localVariableType != null) 1 else 0
// Since JaCoCo 0.8.11, ProbeInserter reserves two local variable slots immediately
// after the method parameters: a "safety slot" and the probe array itself.
// See: https://github.com/jacoco/jacoco/commit/1a1db3bc1e51d6320ed8eb7da086ad401aef1ff7
val newMaxLocals = maxLocals + if (strategy.localVariableType != null) 2 else 0
mv.visitMaxs(newMaxStack, newMaxLocals)
}

Expand Down
41 changes: 21 additions & 20 deletions third_party/jacoco-make-probe-inserter-subclassable.patch
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ index 00000000..19c2a7e2
+ MethodVisitor mv, IProbeArrayStrategy arrayStrategy);
+}
diff --git org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
index 0f5b99ff..80965dfe 100644
index a00894d0..cc32839c 100644
--- org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
+++ org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
@@ -25,7 +25,7 @@ import org.objectweb.asm.TypePath;
* addition the probe array has to be retrieved at the beginning of the method
* and stored in a local variable.
@@ -31,7 +31,7 @@ import org.objectweb.asm.TypePath;
* "https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.10.2.3">a
* value of type long or double which occupy two variables</a>.
*/
-class ProbeInserter extends MethodVisitor implements IProbeInserter {
+public class ProbeInserter extends MethodVisitor implements IProbeInserter {
Expand All @@ -85,7 +85,7 @@ index 0f5b99ff..80965dfe 100644

/** Label for the new beginning of the method */
private final Label beginLabel;
@@ -56,7 +56,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
@@ -65,7 +65,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
* callback to create the code that retrieves the reference to
* the probe array
*/
Expand All @@ -94,7 +94,7 @@ index 0f5b99ff..80965dfe 100644
final MethodVisitor mv, final IProbeArrayStrategy arrayStrategy) {
super(InstrSupport.ASM_API_VERSION, mv);
this.clinit = InstrSupport.CLINIT_NAME.equals(name);
@@ -91,6 +91,10 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
@@ -101,6 +101,12 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
mv.visitInsn(Opcodes.BASTORE);
}

Expand All @@ -105,7 +105,7 @@ index 0f5b99ff..80965dfe 100644
@Override
public void visitCode() {
mv.visitLabel(beginLabel);
@@ -118,6 +122,10 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
@@ -136,6 +142,11 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
public AnnotationVisitor visitLocalVariableAnnotation(final int typeRef,
final TypePath typePath, final Label[] start, final Label[] end,
final int[] index, final String descriptor, final boolean visible) {
Expand All @@ -116,17 +116,17 @@ index 0f5b99ff..80965dfe 100644
final int[] newIndex = new int[index.length];
for (int i = 0; i < newIndex.length; i++) {
newIndex[i] = map(index[i]);
@@ -137,6 +145,9 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
@@ -155,6 +166,9 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
}

private int map(final int var) {
+ if (getLocalVariableType() == null) {
+ return var;
+ }
if (var < variable) {
if (var < variable - 1) {
return var;
} else {
@@ -153,13 +164,18 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
@@ -171,6 +185,12 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
"ClassReader.accept() should be called with EXPAND_FRAMES flag");
}

Expand All @@ -135,14 +135,15 @@ index 0f5b99ff..80965dfe 100644
+ return;
+ }
+
final Object[] newLocal = new Object[Math.max(nLocal, variable) + 1];
final Object[] newLocal = new Object[Math.max(nLocal + 2,
variable + 1)];
int idx = 0; // Arrays index for existing locals
int newIdx = 0; // Array index for new locals
int pos = 0; // Current variable position
while (idx < nLocal || pos <= variable) {
if (pos == variable) {
- newLocal[newIdx++] = InstrSupport.DATAFIELD_DESC;
+ newLocal[newIdx++] = getLocalVariableType();
pos++;
} else {
if (idx < nLocal) {
@@ -186,7 +206,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
newLocal[newIdx++] = Opcodes.TOP;
pos++;
}
- newLocal[newIdx++] = InstrSupport.DATAFIELD_DESC;
+ newLocal[newIdx++] = getLocalVariableType();
if (idx < nLocal && safetySlotOccupied) {
newLocal[newIdx++] = Opcodes.TOP;
}