diff options
author | Oliver Nguyen <olivernguyen@google.com> | 2020-07-09 15:11:30 -0700 |
---|---|---|
committer | Oliver Nguyen <olivernguyen@google.com> | 2020-08-11 10:58:54 -0700 |
commit | 28558ef2ec7635c0a7e10fbb1fe9b8a80d32b636 (patch) | |
tree | ff121ba8fcc1140f854ff568722192877ffeae6a /org.jacoco.core/src/org/jacoco/core/internal | |
parent | bdbfb7047d87e8e790260a0fffb1afdf37ed3dc8 (diff) | |
download | jacoco-28558ef2ec7635c0a7e10fbb1fe9b8a80d32b636.tar.gz |
Add IExecutionData interface and move all usage to the interface.
Abstracts the underlying execution data implementation to allow for more
complex execution data storage mechanisms.
For offline instrumentation, classes store the IExecutionData object and
make calls into it to set probe data. This results in additional
overhead of looking up the vtable for the interface and making the
method call, rather than just directly setting the value in the boolean
array.
Bug: 147904124
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true and verify
Java coverage collection and parsing
Change-Id: I41235626b1040a6a21c6aef300f2dfe064393e1f
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/internal')
-rw-r--r-- | org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java | 8 | ||||
-rw-r--r-- | org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java | 17 |
2 files changed, 12 insertions, 13 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java index 85e83a3a..4d4e1ba1 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/InstrSupport.java @@ -77,7 +77,9 @@ public final class InstrSupport { * Data type of the field that stores coverage information for a class ( * <code>boolean[]</code>). */ - public static final String DATAFIELD_DESC = "[Z"; + // BEGIN android-change + public static final String DATAFIELD_DESC = "Lorg/jacoco/core/data/IExecutionData;"; + // END android-change // === Init Method === @@ -89,7 +91,9 @@ public final class InstrSupport { /** * Descriptor of the initialization method. */ - public static final String INITMETHOD_DESC = "()[Z"; + // BEGIN android-change + public static final String INITMETHOD_DESC = "()Lorg/jacoco/core/data/IExecutionData;"; + // END android-change /** * Access modifiers of the initialization method. diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java index 63fbf765..0cac8f8f 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java @@ -67,25 +67,20 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter { public void insertProbe(final int id) { - // For a probe we set the corresponding position in the boolean[] array - // to true. + // BEGIN android-change + // For a probe we call setProbe on the IExecutionData object. mv.visitVarInsn(Opcodes.ALOAD, variable); - // Stack[0]: [Z + // Stack[0]: Lorg/jacoco/core/data/IExecutionData; InstrSupport.push(mv, id); // Stack[1]: I - // Stack[0]: [Z + // Stack[0]: Lorg/jacoco/core/data/IExecutionData; - mv.visitInsn(Opcodes.ICONST_1); - - // Stack[2]: I - // Stack[1]: I - // Stack[0]: [Z - - mv.visitInsn(Opcodes.BASTORE); + mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "org/jacoco/core/data/IExecutionData", "setProbe", "(I)V", true); + // END android-change } @Override |